GTG

Merge lp:~parinporecha/gtg/bug_fix into lp:~gtg/gtg/old-trunk

Proposed by Parin Porecha
Status: Merged
Merged at revision: 1266
Proposed branch: lp:~parinporecha/gtg/bug_fix
Merge into: lp:~gtg/gtg/old-trunk
Diff against target: 106 lines (+39/-14)
1 file modified
GTG/plugins/urgency_color/urgency_color.py (+39/-14)
To merge this branch: bzr merge lp:~parinporecha/gtg/bug_fix
Reviewer Review Type Date Requested Status
Izidor Matušov code, run Approve
Review via email: mp+141156@code.launchpad.net

Description of the change

Updated the patch for the Bug #1039651. The properties of all the files haven't changed and I've made all the changes Izidor requested

To post a comment you must log in.
Revision history for this message
Izidor Matušov (izidor) wrote :

I found a bug in the code. Let have the following structure:

A (start:tomorrow due:tomorrow)
 B (start:2012-11-10 due:2012-11-11 marked as done)

Task A should be green but after applying your patch it is gray. You should ignore tasks marked as done when computing color.

review: Needs Fixing (code, run)
lp:~parinporecha/gtg/bug_fix updated
1266. By Parin Porecha

Updated Done/Dismissed tasks bug in the patch

Revision history for this message
Parin Porecha (parinporecha) wrote :

Thanks for finding the bug :)
I have fixed it.

Now, the tasks which are marked as Done or Dismissed will be ignored and only Active tasks will be considerd.

> I found a bug in the code. Let have the following structure:
>
> A (start:tomorrow due:tomorrow)
> B (start:2012-11-10 due:2012-11-11 marked as done)
>
> Task A should be green but after applying your patch it is gray. You should
> ignore tasks marked as done when computing color.

Revision history for this message
Parin Porecha (parinporecha) wrote :

Hey Izidor,

I have corrected the bug you showed.
The patch now works better !
plz check it

> I found a bug in the code. Let have the following structure:
>
> A (start:tomorrow due:tomorrow)
> B (start:2012-11-10 due:2012-11-11 marked as done)
>
> Task A should be green but after applying your patch it is gray. You should
> ignore tasks marked as done when computing color.

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

Thank you for your patch. I am sorry it took so long to review it (you know, Xmas holidays)

review: Approve (code, run)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'GTG/plugins/urgency_color/urgency_color.py'
2--- GTG/plugins/urgency_color/urgency_color.py 2012-12-16 14:59:32 +0000
3+++ GTG/plugins/urgency_color/urgency_color.py 2012-12-23 08:49:20 +0000
4@@ -58,14 +58,15 @@
5 return self._pref_data['color_overdue']
6 else:
7 return None
8-
9- def bgcolor(self, node, standard_color):
10+
11+ def get_node_bgcolor(self, node):
12+ """ This method checks the background color of a node and returns the color """
13 sdate = node.get_start_date()
14 ddate = node.get_due_date()
15 if (sdate != Date.no_date() != ddate):
16 dayspan = (ddate - sdate).days
17 daysleft = ddate.days_left()
18-
19+
20 redf = self._pref_data['reddays']
21 reddays = int(ceil(redf*dayspan/100))
22 color = 0
23@@ -75,12 +76,36 @@
24 color = 2
25 if daysleft < 0:
26 color = 3
27+
28+ return color
29+ else:
30+ return None
31+
32+ def bgcolor(self, node, standard_color):
33+ color = self.get_node_bgcolor(node)
34+
35+ def __get_active_child_list(node):
36+ """ This function recursively fetches a list
37+ of all the children of a task which are active
38+ (i.e - the subtasks which are not marked as 'Done' or 'Dismissed' """
39+ child_list = []
40+ for child_id in node.children:
41+ child = node.req.get_task(child_id)
42+ child_list += __get_active_child_list(child)
43+ if child.get_status() in [child.STA_ACTIVE]:
44+ child_list.append(child_id)
45+ return child_list
46+
47+ child_list = __get_active_child_list(node)
48+
49+ for child_id in child_list:
50+ child = self.req.get_task(child_id)
51+ color_of_child = self.get_node_bgcolor(child)
52+ if color_of_child > color:
53+ color = color_of_child
54 # This list should be implemented in the settings
55 #print "Giving color"
56- return self._get_color(color)
57- else:
58- # Return color for this node
59- return None
60+ return self._get_color(color)
61
62 def deactivate(self, plugin_api):
63 """ Plugin is deactivated """
64@@ -115,8 +140,7 @@
65 self.spinbutton_reddays = self.builder.get_object('spinbutton_reddays')
66
67 # Colorbutton - OVERDUE
68- self.colorbutton_overdue = self.builder.get_object(
69- 'colorbutton_overdue')
70+ self.colorbutton_overdue = self.builder.get_object('colorbutton_overdue')
71
72 # Colorbutton - HIGH
73 self.colorbutton_high = self.builder.get_object('colorbutton_high')
74@@ -188,7 +212,7 @@
75 self.prefs_update_widgets()
76
77 def prefs_load(self):
78- data = self._plugin_api.load_configuration_object(
79+ data = self._plugin_api.load_configuration_object( \
80 self.PLUGIN_NAME,
81 'preferences')
82 if not data or not isinstance(data, dict):
83@@ -198,9 +222,9 @@
84 # This is a dirty fix and thus should be removed in a
85 # distant future, when nobody has "red", "yellow" or "green"
86 # settings
87- namepairs = {'red': 'high', 'yellow': 'normal', 'green': 'low'}
88- for key, val in data.iteritems():
89- for oldname, newname in namepairs.iteritems():
90+ namepairs = {'red':'high','yellow':'normal','green':'low'}
91+ for key,val in data.iteritems():
92+ for oldname,newname in namepairs.iteritems():
93 if key == "color_"+oldname:
94 data['color_'+newname] = data.pop(key)
95 # Add new preferences where not present
96@@ -209,8 +233,9 @@
97 data[setting] = self.DEFAULT_PREFS[setting]
98 self._pref_data = dict(data)
99
100+
101 def prefs_store(self):
102- self._plugin_api.save_configuration_object(
103+ self._plugin_api.save_configuration_object( \
104 self.PLUGIN_NAME,
105 'preferences',
106 self._pref_data)

Subscribers

People subscribed via source and target branches

to status/vote changes: