GTG

Merge lp:~bertrand-rousseau/gtg/get_due_date into lp:~gtg/gtg/old-trunk

Proposed by Bertrand Rousseau
Status: Merged
Merged at revision: 1211
Proposed branch: lp:~bertrand-rousseau/gtg/get_due_date
Merge into: lp:~gtg/gtg/old-trunk
Diff against target: 309 lines (+69/-54)
4 files modified
CHANGELOG (+1/-0)
GTG/core/task.py (+44/-18)
GTG/gtk/browser/taskbrowser.glade (+24/-24)
GTG/gtk/editor/editor.py (+0/-12)
To merge this branch: bzr merge lp:~bertrand-rousseau/gtg/get_due_date
Reviewer Review Type Date Requested Status
Izidor Matušov code, running Approve
Review via email: mp+109534@code.launchpad.net

Description of the change

    Remove the implicit interpretation of due date through get_due_date:

    With this patch, GTG uses the actual value of the task object's due date
    when accessing it through get_due_date.

    It seems to me that it's saner than the current mechanism that relies
    on an on-the-fly interpretation when accessing the due date. Indeed,
    this can hide mismatches between the stored value and the returned due
    date.

    Typical example: a parent task with due date A and a child task
    with no due date: the child has no due date set, but get_due_date
    will return 'A'.

    Now, you get what you really have stored, but therefore it's up to the
    code to make sure you store a correct value!

    Therefore, from now on all code dealing with tasks due dates and
    tasks relations MUST be written so that the due dates are always set
    correctly (=they respect the date constraints). This is actually not
    a big deal since most of this is actually cared for by set_due_date().

    set_due_date() has thus been slightly modified (pursuing previous
    work by Nimit Shah), so that when you set/update the due date, all
    related tasks dates are modified to respect the constraints.

    However, D&D'ing tasks can still create situations where a parent task due
    date and its child due date are not compatible. This cannot be fixed
    now since D&D is done in liblarch and there are no hooks available
    from the GTG code to handle tasks updates when reparenting them...

    This patch also means that from now on, undefined due date are presented
    explicitely in the list as not being set, even when constrained by a
    parent. Therefore, it's up to the user to explicitely define it if needed
    (which she/he can do by directly setting the due date of the task, or by
    setting the due date of the parent). It's possibly more work for her/him,
    but at least the outcome is clear and therefore predictable/usable: explicit
    is always better than implicit.

    Note: some code from the task editor that checks if the start and due
    date are compatible has been removed, since it's done in set_due_date
    now.

To post a comment you must log in.
1198. By Bertrand Rousseau

After giving it (even) more thoughts, I think it's better to set the due
date to the most urgent parents due date when clearing it (instead of
setting it to undefine as I did in the previous version of this patch).

Indeed, it reinforces the rule imposing that "task due date < parents
due dates" at all times. Since this the GTG policy, it's probably better
to insist on it (it requires to discover or learn the policy, but it
reduces the confusion once it is learned - a better doc would certainly
help here btw).

Moreover, in order to provide a better feedback on the fact that there
is a "default value" for a task due date depending on related task due
dates, I changed a "set due date" context menu label from "clear due
date" to "reset to default", since it could let one think that this
would actually unset the due date instead of setting it to its current
most constrained value (according to the due date policy).

All that being said, I think this actually corresponds to the previous
behavior, so this should not be a big deal...

Revision history for this message
Izidor Matušov (izidor) wrote :

I reviewed your changes and I like the proposed behavior better. There goes nitpicking:

get_constrained_date() should be a private method (start with '_') or even better a private function (a defined function within function) because it isn't use anywehre but set_due_date() and it is not intended to be a public method

The correct code in editor should be:

if date_kind == GTGCalendar.DATE_KIND_DUE:
    date = self.task.get_due_date()

Otherwise it uses start date for the calendar - regression.

You've changed the description from "clear due date" into "reset to default". I am not sure if it is a good idea:
  1, it is inconsistent within due_date -> the button in calendar is still "clear"
  2, it is inconsistent with start_date -> why you clear start_date but reset due_date? In my opinion, it reveals too much implementation details to a user.

And as usually, the name of the program is intranslatible after using Glade :-/

It looks good, fix those small details and you have my aproval.

review: Needs Fixing (code, running)
1199. By Bertrand Rousseau

Apply modification to fix remarks from Izidor's review

1200. By Bertrand Rousseau

Merge trunk, and fix the self-description in about dialog which was shortened for som reason.

1201. By Bertrand Rousseau

Some pylint fixes

1202. By Bertrand Rousseau

Update CHANGELOG

Revision history for this message
Bertrand Rousseau (bertrand-rousseau) wrote :

Hi Izidor,

I updated the code to take your remarks into account. I also changed some other small things:

 - Used capital letter in the menu items (it's a convention, sort of)
 - Fixed the GTG self-description in the about dialog (it was shortened for some reasons)
 - Fixed lint errors on the modified methods

Revision history for this message
Izidor Matušov (izidor) wrote :

It looks great, merging.

review: Approve (code, running)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CHANGELOG'
2--- CHANGELOG 2012-07-18 12:09:41 +0000
3+++ CHANGELOG 2012-07-20 09:48:37 +0000
4@@ -31,6 +31,7 @@
5 * It is not possible to add another instance of local file synchronization service
6 * Fixes for bugs #906516, #1002160 (task urgency color plugin), by Wolter Hellmund
7 * Fix for bug #1001012: Notification area icon should change color when there are urgent tasks, by Antonio Roquentin
8+ * Saner implementation of set_due_date
9
10 2012-02-13 Getting Things GNOME! 0.2.9
11 * Big refractorization of code, now using liblarch
12
13=== modified file 'GTG/core/task.py'
14--- GTG/core/task.py 2012-07-13 17:27:54 +0000
15+++ GTG/core/task.py 2012-07-20 09:48:37 +0000
16@@ -247,33 +247,59 @@
17 self.last_modified = modified
18
19 def set_due_date(self, fulldate):
20- self.due_date=Date(fulldate)
21- if self.get_start_date() > Date(fulldate) and self.get_start_date() != Date.no_date():
22+ """Defines the task's due date."""
23+ def get_due_date_constraint():
24+ """ Returns the most urgent due date constraint, following
25+ parents' due dates. Return Date.no_date() if no constraint
26+ is applied. """
27+ cur_date = Date.no_date()
28+ for par_id in self.get_parents():
29+ par = self.req.get_task(par_id)
30+ if par.get_due_date() != Date.no_date() and \
31+ par.get_due_date() < cur_date:
32+ cur_date = par.get_due_date()
33+ return cur_date
34+ fulldate_obj = Date(fulldate) # caching the conversion
35+ self.due_date = fulldate_obj
36+ # if the task's start date happens later than the
37+ # new due date, we update it
38+ if self.get_start_date() != Date.no_date() and \
39+ self.get_start_date() > fulldate_obj:
40 self.set_start_date(fulldate)
41- if Date(fulldate)!= Date.no_date():
42+ if fulldate_obj != Date.no_date():
43+ # if the parent's due date happens before the task's new
44+ # due date, we update it
45 for par_id in self.parents:
46 par = self.req.get_task(par_id)
47- if par.due_date != Date.no_date() and par.due_date < Date(fulldate):
48+ if par.get_due_date() != Date.no_date() and \
49+ par.get_due_date() < fulldate_obj:
50 par.set_due_date(fulldate)
51+ # the current task being one of its children's parents, we must
52+ # apply the constraints on their due/start dates as well
53 for sub_id in self.children:
54- sub=self.req.get_task(sub_id)
55- if sub.due_date > Date(fulldate) and sub.due_date != Date.no_date():
56- sub.set_due_date(fulldate)
57- if sub.get_start_date() != Date.no_date() and sub.get_start_date() > Date(fulldate):
58+ sub = self.req.get_task(sub_id)
59+ # child's due date is not set, we use the task's new
60+ # due date
61+ if sub.get_due_date() == Date.no_date():
62+ sub.set_due_date(fulldate)
63+ # child's due date happens later than the task's: we
64+ # update it to the task's new due date
65+ # (= the new most restrictive)
66+ if sub.get_due_date() != Date.no_date() and \
67+ sub.get_due_date() > fulldate_obj:
68+ sub.set_due_date(fulldate)
69+ # if the child's start date happens later than
70+ # the task's new due date, we update it
71+ if sub.get_start_date() != Date.no_date() and \
72+ sub.get_start_date() > fulldate_obj:
73 sub.set_start_date(fulldate)
74+ else:
75+ self.due_date = get_due_date_constraint()
76 self.sync()
77
78 def get_due_date(self):
79- """ Due date return the most urgent date of all parents """
80- zedate = self.due_date
81-
82- for par in self.get_parents():
83- # compare with the parent's due date
84- pardate = self.req.get_task(par).get_due_date()
85- if pardate and zedate > pardate:
86- zedate = pardate
87-
88- return zedate
89+ """ Returns the due date, which always respects all constraints """
90+ return self.due_date
91
92 def set_start_date(self, fulldate):
93 self.start_date = Date(fulldate)
94
95=== modified file 'GTG/gtk/browser/taskbrowser.glade'
96--- GTG/gtk/browser/taskbrowser.glade 2012-07-13 17:24:28 +0000
97+++ GTG/gtk/browser/taskbrowser.glade 2012-07-20 09:48:37 +0000
98@@ -4,7 +4,7 @@
99 <!-- interface-naming-policy toplevel-contextual -->
100 <object class="GtkWindow" id="MainWindow">
101 <property name="can_focus">False</property>
102- <property name="title" translatable="yes">Getting Things Gnome!</property>
103+ <property name="title" translatable="yes">Getting Things GNOME!</property>
104 <property name="default_width">700</property>
105 <property name="default_height">550</property>
106 <signal name="configure-event" handler="on_move" swapped="no"/>
107@@ -796,13 +796,13 @@
108 <property name="type_hint">dialog</property>
109 <property name="program_name" translatable="yes">Getting Things GNOME!</property>
110 <property name="copyright" translatable="yes">Copyright © 2008-2012 Lionel Dricot, Bertrand Rousseau</property>
111- <property name="comments" translatable="yes">GTG is a personal tasks and TODO-list items organizer for the GNOME.</property>
112+ <property name="comments" translatable="yes">GTG is a personal tasks and TODO-list items organizer for the GNOME desktop environment.</property>
113 <property name="website_label" translatable="yes">GTG website</property>
114- <property name="license" translatable="yes">Getting Things Gnome! is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
115-
116-Getting Things Gnome! is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
117-
118-You should have received a copy of the GNU General Public License along with Getting Things Gnome!; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.</property>
119+ <property name="license" translatable="yes">Getting Things GNOME! is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
120+
121+Getting Things GNOME! is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
122+
123+You should have received a copy of the GNU General Public License along with Getting Things GNOME!; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.</property>
124 <property name="authors">Lionel Dricot (ploum@ploum.net),
125 Bertrand Rousseau (bertrand.rousseau@gmail.com)</property>
126 <property name="logo_icon_name">gtg</property>
127@@ -1044,7 +1044,7 @@
128 </child>
129 <child>
130 <object class="GtkImageMenuItem" id="tcm_start_menu">
131- <property name="label" translatable="yes">_Set start date</property>
132+ <property name="label" translatable="yes">_Set Start Date</property>
133 <property name="visible">True</property>
134 <property name="can_focus">False</property>
135 <property name="use_action_appearance">False</property>
136@@ -1056,7 +1056,7 @@
137 <property name="can_focus">False</property>
138 <child>
139 <object class="GtkImageMenuItem" id="tcm_mark_as_started">
140- <property name="label" translatable="yes">t_oday</property>
141+ <property name="label" translatable="yes">T_oday</property>
142 <property name="visible">True</property>
143 <property name="can_focus">False</property>
144 <property name="use_action_appearance">False</property>
145@@ -1067,7 +1067,7 @@
146 </child>
147 <child>
148 <object class="GtkImageMenuItem" id="tcm_start_for_tomorrow">
149- <property name="label" translatable="yes">_tomorrow</property>
150+ <property name="label" translatable="yes">_Tomorrow</property>
151 <property name="visible">True</property>
152 <property name="can_focus">False</property>
153 <property name="use_action_appearance">False</property>
154@@ -1078,7 +1078,7 @@
155 </child>
156 <child>
157 <object class="GtkImageMenuItem" id="tcm_start_for_next_week">
158- <property name="label" translatable="yes">next _week</property>
159+ <property name="label" translatable="yes">Next _Week</property>
160 <property name="visible">True</property>
161 <property name="can_focus">False</property>
162 <property name="use_action_appearance">False</property>
163@@ -1089,7 +1089,7 @@
164 </child>
165 <child>
166 <object class="GtkImageMenuItem" id="tcm_start_for_next_month">
167- <property name="label" translatable="yes">next _month</property>
168+ <property name="label" translatable="yes">Next _Month</property>
169 <property name="visible">True</property>
170 <property name="can_focus">False</property>
171 <property name="use_action_appearance">False</property>
172@@ -1100,7 +1100,7 @@
173 </child>
174 <child>
175 <object class="GtkImageMenuItem" id="tcm_start_for_next_year">
176- <property name="label" translatable="yes">next _year</property>
177+ <property name="label" translatable="yes">Next _Year</property>
178 <property name="visible">True</property>
179 <property name="can_focus">False</property>
180 <property name="use_action_appearance">False</property>
181@@ -1117,7 +1117,7 @@
182 </child>
183 <child>
184 <object class="GtkImageMenuItem" id="tcm_start_clear">
185- <property name="label" translatable="yes">_clear start date</property>
186+ <property name="label" translatable="yes">_Clear Start Date</property>
187 <property name="visible">True</property>
188 <property name="can_focus">False</property>
189 <property name="use_action_appearance">False</property>
190@@ -1132,7 +1132,7 @@
191 </child>
192 <child>
193 <object class="GtkImageMenuItem" id="tcm_due_menu">
194- <property name="label" translatable="yes">Set due date</property>
195+ <property name="label" translatable="yes">Set Due Date</property>
196 <property name="visible">True</property>
197 <property name="can_focus">False</property>
198 <property name="use_action_appearance">False</property>
199@@ -1144,7 +1144,7 @@
200 <property name="can_focus">False</property>
201 <child>
202 <object class="GtkImageMenuItem" id="tcm_due_today">
203- <property name="label" translatable="yes">t_oday</property>
204+ <property name="label" translatable="yes">T_oday</property>
205 <property name="visible">True</property>
206 <property name="can_focus">False</property>
207 <property name="use_action_appearance">False</property>
208@@ -1155,7 +1155,7 @@
209 </child>
210 <child>
211 <object class="GtkImageMenuItem" id="tcm_due_tomorrow">
212- <property name="label" translatable="yes">_tomorrow</property>
213+ <property name="label" translatable="yes">_Tomorrow</property>
214 <property name="visible">True</property>
215 <property name="can_focus">False</property>
216 <property name="use_action_appearance">False</property>
217@@ -1166,7 +1166,7 @@
218 </child>
219 <child>
220 <object class="GtkImageMenuItem" id="tcm_due_next_week">
221- <property name="label" translatable="yes">next _week</property>
222+ <property name="label" translatable="yes">Next _Week</property>
223 <property name="visible">True</property>
224 <property name="can_focus">False</property>
225 <property name="use_action_appearance">False</property>
226@@ -1177,7 +1177,7 @@
227 </child>
228 <child>
229 <object class="GtkImageMenuItem" id="tcm_due_next_month">
230- <property name="label" translatable="yes">next _month</property>
231+ <property name="label" translatable="yes">Next _Month</property>
232 <property name="visible">True</property>
233 <property name="can_focus">False</property>
234 <property name="use_action_appearance">False</property>
235@@ -1188,7 +1188,7 @@
236 </child>
237 <child>
238 <object class="GtkImageMenuItem" id="tcm_due_next_year">
239- <property name="label" translatable="yes">next _year</property>
240+ <property name="label" translatable="yes">Next _Year</property>
241 <property name="visible">True</property>
242 <property name="can_focus">False</property>
243 <property name="use_action_appearance">False</property>
244@@ -1205,7 +1205,7 @@
245 </child>
246 <child>
247 <object class="GtkImageMenuItem" id="tcm_due_now">
248- <property name="label" translatable="yes">_now</property>
249+ <property name="label" translatable="yes">_Now</property>
250 <property name="visible">True</property>
251 <property name="can_focus">False</property>
252 <property name="use_action_appearance">False</property>
253@@ -1216,7 +1216,7 @@
254 </child>
255 <child>
256 <object class="GtkImageMenuItem" id="tcm_due_soon">
257- <property name="label" translatable="yes">_soon</property>
258+ <property name="label" translatable="yes">_Soon</property>
259 <property name="visible">True</property>
260 <property name="can_focus">False</property>
261 <property name="use_action_appearance">False</property>
262@@ -1227,7 +1227,7 @@
263 </child>
264 <child>
265 <object class="GtkImageMenuItem" id="tcm_due_someday">
266- <property name="label" translatable="yes">_someday</property>
267+ <property name="label" translatable="yes">_Someday</property>
268 <property name="visible">True</property>
269 <property name="can_focus">False</property>
270 <property name="use_action_appearance">False</property>
271@@ -1244,7 +1244,7 @@
272 </child>
273 <child>
274 <object class="GtkImageMenuItem" id="tcm_due_clear">
275- <property name="label" translatable="yes">_clear due date</property>
276+ <property name="label" translatable="yes">_Clear Due Date</property>
277 <property name="visible">True</property>
278 <property name="can_focus">False</property>
279 <property name="use_action_appearance">False</property>
280
281=== modified file 'GTG/gtk/editor/editor.py'
282--- GTG/gtk/editor/editor.py 2012-07-13 17:24:28 +0000
283+++ GTG/gtk/editor/editor.py 2012-07-20 09:48:37 +0000
284@@ -366,13 +366,6 @@
285 self.task.set_due_date(datetoset)
286 elif data == "closed":
287 self.task.set_closed_date(datetoset)
288-
289- # Set the due date to be equal to the start date
290- # when it happens that the start date is later than the due date
291- start_date = self.task.get_start_date()
292- due_date = self.task.get_due_date()
293- if start_date and (start_date > due_date):
294- self.task.set_due_date(self.task.get_start_date())
295 else:
296 #We should write in red in the entry if the date is not valid
297 widget.modify_text(gtk.STATE_NORMAL, gtk.gdk.color_parse("#F00"))
298@@ -382,11 +375,6 @@
299 """Called when a date-changing button is clicked."""
300 if date_kind == GTGCalendar.DATE_KIND_DUE:
301 date = self.task.get_due_date()
302- start_date = self.task.get_start_date()
303- due_before_start = start_date and start_date > date
304-
305- if not date or due_before_start:
306- date = self.task.get_start_date()
307 elif date_kind == GTGCalendar.DATE_KIND_START:
308 date = self.task.get_start_date()
309 elif date_kind == GTGCalendar.DATE_KIND_CLOSED:

Subscribers

People subscribed via source and target branches

to status/vote changes: