GTG

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

Proposed by Bertrand Rousseau
Status: Merged
Merged at revision: 1217
Proposed branch: lp:~bertrand-rousseau/gtg/bug-988235
Merge into: lp:~gtg/gtg/old-trunk
Diff against target: 79 lines (+37/-0)
1 file modified
GTG/core/tag.py (+37/-0)
To merge this branch: bzr merge lp:~bertrand-rousseau/gtg/bug-988235
Reviewer Review Type Date Requested Status
Izidor Matušov Approve
Review via email: mp+104853@code.launchpad.net

Description of the change

This branch fixes bug 988235 (task & tag refresh in the browser). This is coupled to another commit in liblarch: https://github.com/liblarch/liblarch/pull/3 (get_nodes() function is required to make this work)

To test it you will need to checkout my liblarch branch on github: https://github.com/broussea/liblarch

To post a comment you must log in.
lp:~bertrand-rousseau/gtg/bug-988235 updated
1180. By Bertrand Rousseau

Fix a bug: forget to notify change when delete an attribute. Add a bit of documentation too

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

You replace all occurrencies of get_n_nodes() with len(get_nodes()) I am against this step because get_n_nodes() allows speed optimizations on the side of liblarch.

I suggest to remove the line 'assert my_task is not None, "Unknown task id: %s" % task_id' - if my_task is None, python would discover that and raise an exception. The result would be the same, just a different name of exception. There shouldn't be any case to catch None at this place. In other words, it is a redundant line which doesn't add anything, just add a redundant check.

review: Needs Fixing (code)
lp:~bertrand-rousseau/gtg/bug-988235 updated
1181. By Bertrand Rousseau

Fix following Izidor's review

1182. By Bertrand Rousseau

Merge trunk

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

Ok, I've made the fix you asked for.

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

Thanks for a good work!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'GTG/core/tag.py'
2--- GTG/core/tag.py 2012-05-20 19:01:02 +0000
3+++ GTG/core/tag.py 2012-06-03 21:03:18 +0000
4@@ -84,17 +84,23 @@
5 @param att_value: The value of the attribute. Will be converted to a
6 string.
7 """
8+ modified = False
9 if att_name == "name":
10 raise Set_Name_Attribute_Error(
11 "The name of tag cannot be set manually")
12 elif att_name == "parent":
13 self.add_parent(att_value)
14+ modified = True
15 else:
16 # Attributes should all be strings.
17 val = unicode(str(att_value), "UTF-8")
18 self._attributes[att_name] = val
19 if self._save:
20 self._save()
21+ modified = True
22+ if modified:
23+ self.modified()
24+ self.notify_related_tasks()
25
26 def get_attribute(self, att_name):
27 """Get the attribute C{att_name}.
28@@ -125,6 +131,8 @@
29 del self._attributes[att_name]
30 if self._save:
31 self._save()
32+ self.modified()
33+ self.notify_related_tasks()
34
35 def get_all_attributes(self, butname=False, withparent=False):
36 """Return a list of all attribute names.
37@@ -151,6 +159,10 @@
38 return self.__get_count()
39
40 def __get_count(self, tasktree=None):
41+ """Returns the number of all related tasks"""
42+ # this method purposefully doesn't rely on get_related_tasks()
43+ # which does a similar job, in order to benefit from liblarch
44+ # optimizations
45 if not tasktree:
46 tasktree = self.req.get_tasks_tree()
47 sp_id = self.get_attribute("special")
48@@ -168,6 +180,31 @@
49 withfilters=[tname], include_transparent=False)
50 return toreturn
51
52+ def get_related_tasks(self, tasktree=None):
53+ """Returns all related tasks node ids"""
54+ if not tasktree:
55+ tasktree = self.req.get_tasks_tree()
56+ sp_id = self.get_attribute("special")
57+ if sp_id == "all":
58+ toreturn = tasktree.get_nodes(\
59+ withfilters=['active'], include_transparent=False)
60+ elif sp_id == "notag":
61+ toreturn = tasktree.get_nodes(\
62+ withfilters=['notag'], include_transparent=False)
63+ elif sp_id == "sep" :
64+ toreturn = []
65+ else:
66+ tname = self.get_name()
67+ toreturn = tasktree.get_nodes(\
68+ withfilters=[tname], include_transparent=False)
69+ return toreturn
70+
71+ def notify_related_tasks(self):
72+ """Notify changes to all related tasks"""
73+ for task_id in self.get_related_tasks():
74+ my_task = self.req.get_task(task_id)
75+ my_task.modified()
76+
77 #is it useful to keep the tag in the tagstore.
78 #if no attributes and no tasks, it is not useful.
79 def is_removable(self):

Subscribers

People subscribed via source and target branches

to status/vote changes: