← Back to team overview

gtg team mailing list archive

[Merge] lp:~bertrand-rousseau/gtg/bugfix-1038662-dont-touch-due-date into lp:gtg

 

Bertrand Rousseau has proposed merging lp:~bertrand-rousseau/gtg/bugfix-1038662-dont-touch-due-date into lp:gtg.

Requested reviews:
  Gtg developers (gtg)
Related bugs:
  Bug #1038662 in Getting Things GNOME!: "Undefined due dates in subtasks should always stay undefined and displayed as such in the editor"
  https://bugs.launchpad.net/gtg/+bug/1038662

For more details, see:
https://code.launchpad.net/~bertrand-rousseau/gtg/bugfix-1038662-dont-touch-due-date/+merge/121929

I changed the due date inheritance mechanism so that due date of children is not altered if it's not set.

Since I can't come up with a good UI to display the constraining date in the task editor, I think the best solution is to leave the due date selector widget blank and not display anything about a constraining date.
-- 
https://code.launchpad.net/~bertrand-rousseau/gtg/bugfix-1038662-dont-touch-due-date/+merge/121929
Your team Gtg developers is requested to review the proposed merge of lp:~bertrand-rousseau/gtg/bugfix-1038662-dont-touch-due-date into lp:gtg.
=== modified file 'GTG/core/task.py'
--- GTG/core/task.py	2012-08-15 15:23:45 +0000
+++ GTG/core/task.py	2012-08-29 19:25:23 +0000
@@ -246,19 +246,20 @@
     def set_modified(self, modified):
         self.last_modified = modified
 
+    def get_constrained_due_date(self):
+        """ Returns the most urgent due date constraint, following
+            parents' due dates. Return Date.no_date() if no constraint
+            is applied. """
+        cur_date = self.due_date
+        for par_id in self.get_parents():
+            par = self.req.get_task(par_id)
+            if par.get_due_date() != Date.no_date() and \
+               par.get_due_date() < cur_date:
+                cur_date = par.get_due_date()
+        return cur_date
+
     def set_due_date(self, fulldate):
         """Defines the task's due date."""
-        def get_due_date_constraint():
-            """ Returns the most urgent due date constraint, following
-                parents' due dates. Return Date.no_date() if no constraint
-                is applied. """
-            cur_date = Date.no_date()
-            for par_id in self.get_parents():
-                par = self.req.get_task(par_id)
-                if par.get_due_date() != Date.no_date() and \
-                   par.get_due_date() < cur_date:
-                    cur_date = par.get_due_date()
-            return cur_date
         fulldate_obj = Date(fulldate) # caching the conversion
         self.due_date = fulldate_obj
         # if the task's start date happens later than the 
@@ -280,10 +281,11 @@
             # apply the constraints on their due/start dates as well
             for sub_id in self.children:
                 sub = self.req.get_task(sub_id)
-                # child's due date is not set, we use the task's new 
-                # due date
+                # child's due date is not set, we don't change it
+                # but since the constraint has changed we notify
+                # a change
                 if sub.get_due_date() == Date.no_date():
-                    sub.set_due_date(fulldate)
+                    sub.sync()
                 # child's due date happens later than the task's: we
                 # update it to the task's new due date
                 # (= the new most restrictive)
@@ -297,8 +299,6 @@
                    not fulldate_obj.is_fuzzy() and \
                    sub.get_start_date() > fulldate_obj:
                     sub.set_start_date(fulldate)
-        else:
-            self.due_date = get_due_date_constraint()
         self.sync()
 
     def get_due_date(self):

=== modified file 'GTG/gtk/browser/treeview_factory.py'
--- GTG/gtk/browser/treeview_factory.py	2012-07-13 17:24:28 +0000
+++ GTG/gtk/browser/treeview_factory.py	2012-08-29 19:25:23 +0000
@@ -142,7 +142,7 @@
         return node.get_start_date().to_readable_string()
         
     def task_duedate_column(self,node):
-        return node.get_due_date().to_readable_string()
+        return node.get_constrained_due_date().to_readable_string()
         
     def task_cdate_column(self,node):
         return node.get_closed_date().to_readable_string()
@@ -172,8 +172,8 @@
                 t1 = task1.get_start_date()
                 t2 = task2.get_start_date()
             elif para == 'due':
-                t1 = task1.get_due_date()
-                t2 = task2.get_due_date()
+                t1 = task1.get_constrained_due_date()
+                t2 = task2.get_constrained_due_date()
             elif para == 'closed':
                 t1 = task1.get_closed_date()
                 t2 = task2.get_closed_date()