equal
deleted
inserted
replaced
13 task.save() |
13 task.save() |
14 return task |
14 return task |
15 |
15 |
16 def addSubTask(main_task, sub_task): |
16 def addSubTask(main_task, sub_task): |
17 """ add the task to subs attribute of the task and update its status. |
17 """ add the task to subs attribute of the task and update its status. |
18 sub task can be added only if a task is in UP/OP/LO/Cd state. |
18 sub task can be added only if a task is in UP/OP/LO state. |
19 """ |
19 """ |
20 |
20 |
21 ## Shall modify after talking to pr about subtasks |
21 ## Shall modify after talking to pr about subtasks |
22 ## I think i might even remove the concept of subtasks |
22 ## I think i might even remove the concept of subtasks |
23 main_task.subs.add(sub_task) |
23 main_task.subs.add(sub_task) |
68 task.credits = credits |
68 task.credits = credits |
69 task.creation_datetime = datetime.now() |
69 task.creation_datetime = datetime.now() |
70 task.save() |
70 task.save() |
71 return task |
71 return task |
72 |
72 |
73 def addSubTask(main_task, sub_task): |
|
74 """ add sub_task to subs list of main_task """ |
|
75 |
|
76 main_task.subs.add(sub_task) |
|
77 main_task.status = "LO" |
|
78 main_task.save() |
|
79 return main_task |
|
80 |
|
81 def addClaim(task, message, user): |
73 def addClaim(task, message, user): |
82 """ add claim data to the database if it does not exist |
74 """ add claim data to the database if it does not exist |
83 and also update the claimed users field of the task. |
75 and also update the claimed users field of the task. |
84 """ |
76 """ |
85 |
77 |
86 task.claimed_users.add(user) |
78 task.claimed_users.add(user) |
87 task.status = "CL" |
|
88 task.save() |
79 task.save() |
89 claim = Claim() |
80 claim = Claim() |
90 claim.message = message |
81 claim.message = message |
91 claim.task = task |
82 claim.task = task |
92 claim.user = user |
83 claim.user = user |
94 claim.save() |
85 claim.save() |
95 |
86 |
96 def assignTask(task, user): |
87 def assignTask(task, user): |
97 """ check for the status of task and assign it to the particular user """ |
88 """ check for the status of task and assign it to the particular user """ |
98 |
89 |
99 task.assigned_users.add(user) |
90 if task.status in ['OP', 'WR']: |
100 task.status = "AS" |
91 task.assigned_users.add(user) |
|
92 task.claimed_users.remove(user) |
|
93 task.status = "WR" |
101 task.save() |
94 task.save() |
102 |
95 |
103 def getTask(tid): |
96 def getTask(tid): |
104 """ retreive the task from database. |
97 """ retreive the task from database. |
105 if the task has deps or subs, update its status correspondingly. |
98 if the task has deps or subs, update its status correspondingly. |
114 if subs and task.status in ["OP", "LO", "CM"]: |
107 if subs and task.status in ["OP", "LO", "CM"]: |
115 task.status = "CM" if all(map(lambda t:t.status=="CM",subs)) else "LO" |
108 task.status = "CM" if all(map(lambda t:t.status=="CM",subs)) else "LO" |
116 |
109 |
117 task.save() |
110 task.save() |
118 return task |
111 return task |
|
112 |
|
113 def updateTask(task, title=None, desc=None, credits=None, tags_field=None): |
|
114 """ update the property accordingly. |
|
115 while updating title, check for uniqueness of title. |
|
116 return None if any error. |
|
117 """ |
|
118 |
|
119 if title: |
|
120 try: |
|
121 task.title = title |
|
122 task.save() |
|
123 except IntegrityError: |
|
124 return None |
|
125 if desc:task.desc = desc |
|
126 if credits:task.credits = credits |
|
127 if tags_field:task.tags_field = tags_field |
|
128 task.save() |
|
129 return task |