author | nishanth |
Fri, 26 Feb 2010 16:15:58 +0530 | |
changeset 120 | aad4e6065d85 |
parent 119 | 39ab7c460143 |
child 124 | 6d92b7cd2a37 |
permissions | -rw-r--r-- |
19 | 1 |
from datetime import datetime |
90
b2426897ff18
our task model does not meet out needs. so modified it and added a model called map. made the changes in views accordingly.phew!!!. this one took the hell out of me :( .
nishanth
parents:
89
diff
changeset
|
2 |
from pytask.taskapp.models import Profile, Task, Comment, Credit, Claim, Map |
120 | 3 |
from pytask.taskapp.utilities.task import getTask |
99
64c34c1f441f
assign_credits event now creates a proper request object .
nishanth
parents:
96
diff
changeset
|
4 |
from pytask.taskapp.utilities.request import create_request |
119 | 5 |
from pytask.taskapp.utilities.helper import get_key |
19 | 6 |
|
113
ea962d5fe99e
added option of specifying if previous mentors and comments must be removed in publish task event.
nishanth
parents:
112
diff
changeset
|
7 |
def publishTask(task, rem_mentors=True, rem_comments=True): |
19 | 8 |
""" set the task status to open """ |
90
b2426897ff18
our task model does not meet out needs. so modified it and added a model called map. made the changes in views accordingly.phew!!!. this one took the hell out of me :( .
nishanth
parents:
89
diff
changeset
|
9 |
|
b2426897ff18
our task model does not meet out needs. so modified it and added a model called map. made the changes in views accordingly.phew!!!. this one took the hell out of me :( .
nishanth
parents:
89
diff
changeset
|
10 |
if task.sub_type == 'D': |
b2426897ff18
our task model does not meet out needs. so modified it and added a model called map. made the changes in views accordingly.phew!!!. this one took the hell out of me :( .
nishanth
parents:
89
diff
changeset
|
11 |
deps, subs = task.map_subs.all(), [] |
b2426897ff18
our task model does not meet out needs. so modified it and added a model called map. made the changes in views accordingly.phew!!!. this one took the hell out of me :( .
nishanth
parents:
89
diff
changeset
|
12 |
else: |
b2426897ff18
our task model does not meet out needs. so modified it and added a model called map. made the changes in views accordingly.phew!!!. this one took the hell out of me :( .
nishanth
parents:
89
diff
changeset
|
13 |
subs, deps = task.map_subs.all(), [] |
b2426897ff18
our task model does not meet out needs. so modified it and added a model called map. made the changes in views accordingly.phew!!!. this one took the hell out of me :( .
nishanth
parents:
89
diff
changeset
|
14 |
|
b2426897ff18
our task model does not meet out needs. so modified it and added a model called map. made the changes in views accordingly.phew!!!. this one took the hell out of me :( .
nishanth
parents:
89
diff
changeset
|
15 |
if subs or any(map(lambda t:t.status!="CM",deps)): |
53 | 16 |
task.status = "LO" |
17 |
else: |
|
18 |
task.status = "OP" |
|
111 | 19 |
|
113
ea962d5fe99e
added option of specifying if previous mentors and comments must be removed in publish task event.
nishanth
parents:
112
diff
changeset
|
20 |
if rem_mentors: |
ea962d5fe99e
added option of specifying if previous mentors and comments must be removed in publish task event.
nishanth
parents:
112
diff
changeset
|
21 |
task.mentors.clear() |
ea962d5fe99e
added option of specifying if previous mentors and comments must be removed in publish task event.
nishanth
parents:
112
diff
changeset
|
22 |
task.mentors.add(task.created_by) |
112
eadff01e395e
now task page displays only undeleted comments. and publish task removes previous comments.
nishanth
parents:
111
diff
changeset
|
23 |
|
113
ea962d5fe99e
added option of specifying if previous mentors and comments must be removed in publish task event.
nishanth
parents:
112
diff
changeset
|
24 |
if rem_comments: |
ea962d5fe99e
added option of specifying if previous mentors and comments must be removed in publish task event.
nishanth
parents:
112
diff
changeset
|
25 |
task.comment_set.update(is_deleted=True) |
ea962d5fe99e
added option of specifying if previous mentors and comments must be removed in publish task event.
nishanth
parents:
112
diff
changeset
|
26 |
task.comment_set.update(deleted_by=task.created_by) |
112
eadff01e395e
now task page displays only undeleted comments. and publish task removes previous comments.
nishanth
parents:
111
diff
changeset
|
27 |
|
19 | 28 |
task.save() |
29 |
return task |
|
30 |
||
54 | 31 |
def addSubTask(main_task, sub_task): |
32 |
""" add the task to subs attribute of the task and update its status. |
|
63
1fc027bf99ee
added events in task.py for adding subtask and dependencies
nishanth
parents:
55
diff
changeset
|
33 |
sub task can be added only if a task is in UP/OP/LO state. |
54 | 34 |
""" |
35 |
||
36 |
## Shall modify after talking to pr about subtasks |
|
37 |
## I think i might even remove the concept of subtasks |
|
90
b2426897ff18
our task model does not meet out needs. so modified it and added a model called map. made the changes in views accordingly.phew!!!. this one took the hell out of me :( .
nishanth
parents:
89
diff
changeset
|
38 |
|
b2426897ff18
our task model does not meet out needs. so modified it and added a model called map. made the changes in views accordingly.phew!!!. this one took the hell out of me :( .
nishanth
parents:
89
diff
changeset
|
39 |
main_task.sub_type = "S" |
b2426897ff18
our task model does not meet out needs. so modified it and added a model called map. made the changes in views accordingly.phew!!!. this one took the hell out of me :( .
nishanth
parents:
89
diff
changeset
|
40 |
main_task.save() |
b2426897ff18
our task model does not meet out needs. so modified it and added a model called map. made the changes in views accordingly.phew!!!. this one took the hell out of me :( .
nishanth
parents:
89
diff
changeset
|
41 |
|
b2426897ff18
our task model does not meet out needs. so modified it and added a model called map. made the changes in views accordingly.phew!!!. this one took the hell out of me :( .
nishanth
parents:
89
diff
changeset
|
42 |
try: |
b2426897ff18
our task model does not meet out needs. so modified it and added a model called map. made the changes in views accordingly.phew!!!. this one took the hell out of me :( .
nishanth
parents:
89
diff
changeset
|
43 |
mapobj = Map.objects.get(main=main_task) |
b2426897ff18
our task model does not meet out needs. so modified it and added a model called map. made the changes in views accordingly.phew!!!. this one took the hell out of me :( .
nishanth
parents:
89
diff
changeset
|
44 |
except Map.DoesNotExist: |
b2426897ff18
our task model does not meet out needs. so modified it and added a model called map. made the changes in views accordingly.phew!!!. this one took the hell out of me :( .
nishanth
parents:
89
diff
changeset
|
45 |
mapobj = Map() |
b2426897ff18
our task model does not meet out needs. so modified it and added a model called map. made the changes in views accordingly.phew!!!. this one took the hell out of me :( .
nishanth
parents:
89
diff
changeset
|
46 |
mapobj.main = main_task |
b2426897ff18
our task model does not meet out needs. so modified it and added a model called map. made the changes in views accordingly.phew!!!. this one took the hell out of me :( .
nishanth
parents:
89
diff
changeset
|
47 |
mapobj.save() |
b2426897ff18
our task model does not meet out needs. so modified it and added a model called map. made the changes in views accordingly.phew!!!. this one took the hell out of me :( .
nishanth
parents:
89
diff
changeset
|
48 |
mapobj.subs.add(sub_task) |
b2426897ff18
our task model does not meet out needs. so modified it and added a model called map. made the changes in views accordingly.phew!!!. this one took the hell out of me :( .
nishanth
parents:
89
diff
changeset
|
49 |
mapobj.save() |
b2426897ff18
our task model does not meet out needs. so modified it and added a model called map. made the changes in views accordingly.phew!!!. this one took the hell out of me :( .
nishanth
parents:
89
diff
changeset
|
50 |
|
b2426897ff18
our task model does not meet out needs. so modified it and added a model called map. made the changes in views accordingly.phew!!!. this one took the hell out of me :( .
nishanth
parents:
89
diff
changeset
|
51 |
sub_tasks = getTask(main_task.id).subs |
54 | 52 |
if main_task.status == "OP": |
53 |
if any(map(lambda t:t.status!="CM",sub_tasks)): |
|
54 |
main_task.status = "LO" |
|
55 |
else: |
|
56 |
"CM" |
|
57 |
main_task.save() |
|
58 |
||
59 |
def addDep(main_task, dependency): |
|
60 |
""" add the dependency task to deps attribute of the task. |
|
61 |
update the status of main_task accordingly. |
|
89
1cc03941ed5d
added the capability of adding subtasks/dependencies .
nishanth
parents:
74
diff
changeset
|
62 |
note that deps can be added only if task is in UP/OP/LO state. |
54 | 63 |
And also if the task doesn't have any subs. |
64 |
""" |
|
65 |
||
90
b2426897ff18
our task model does not meet out needs. so modified it and added a model called map. made the changes in views accordingly.phew!!!. this one took the hell out of me :( .
nishanth
parents:
89
diff
changeset
|
66 |
main_task.sub_type = "D" |
b2426897ff18
our task model does not meet out needs. so modified it and added a model called map. made the changes in views accordingly.phew!!!. this one took the hell out of me :( .
nishanth
parents:
89
diff
changeset
|
67 |
main_task.save() |
b2426897ff18
our task model does not meet out needs. so modified it and added a model called map. made the changes in views accordingly.phew!!!. this one took the hell out of me :( .
nishanth
parents:
89
diff
changeset
|
68 |
|
b2426897ff18
our task model does not meet out needs. so modified it and added a model called map. made the changes in views accordingly.phew!!!. this one took the hell out of me :( .
nishanth
parents:
89
diff
changeset
|
69 |
try: |
b2426897ff18
our task model does not meet out needs. so modified it and added a model called map. made the changes in views accordingly.phew!!!. this one took the hell out of me :( .
nishanth
parents:
89
diff
changeset
|
70 |
mapobj = Map.objects.get(main=main_task) |
b2426897ff18
our task model does not meet out needs. so modified it and added a model called map. made the changes in views accordingly.phew!!!. this one took the hell out of me :( .
nishanth
parents:
89
diff
changeset
|
71 |
except Map.DoesNotExist: |
b2426897ff18
our task model does not meet out needs. so modified it and added a model called map. made the changes in views accordingly.phew!!!. this one took the hell out of me :( .
nishanth
parents:
89
diff
changeset
|
72 |
mapobj = Map() |
b2426897ff18
our task model does not meet out needs. so modified it and added a model called map. made the changes in views accordingly.phew!!!. this one took the hell out of me :( .
nishanth
parents:
89
diff
changeset
|
73 |
mapobj.main = main_task |
b2426897ff18
our task model does not meet out needs. so modified it and added a model called map. made the changes in views accordingly.phew!!!. this one took the hell out of me :( .
nishanth
parents:
89
diff
changeset
|
74 |
mapobj.save() |
b2426897ff18
our task model does not meet out needs. so modified it and added a model called map. made the changes in views accordingly.phew!!!. this one took the hell out of me :( .
nishanth
parents:
89
diff
changeset
|
75 |
|
b2426897ff18
our task model does not meet out needs. so modified it and added a model called map. made the changes in views accordingly.phew!!!. this one took the hell out of me :( .
nishanth
parents:
89
diff
changeset
|
76 |
mapobj.subs.add(dependency) |
b2426897ff18
our task model does not meet out needs. so modified it and added a model called map. made the changes in views accordingly.phew!!!. this one took the hell out of me :( .
nishanth
parents:
89
diff
changeset
|
77 |
mapobj.save() |
b2426897ff18
our task model does not meet out needs. so modified it and added a model called map. made the changes in views accordingly.phew!!!. this one took the hell out of me :( .
nishanth
parents:
89
diff
changeset
|
78 |
|
b2426897ff18
our task model does not meet out needs. so modified it and added a model called map. made the changes in views accordingly.phew!!!. this one took the hell out of me :( .
nishanth
parents:
89
diff
changeset
|
79 |
deps = getTask(main_task.id).deps |
b2426897ff18
our task model does not meet out needs. so modified it and added a model called map. made the changes in views accordingly.phew!!!. this one took the hell out of me :( .
nishanth
parents:
89
diff
changeset
|
80 |
|
54 | 81 |
if main_task.status in ["OP", "LO"]: |
82 |
if all(map(lambda t:t.status=="CM",deps)): |
|
83 |
main_task.status = "OP" |
|
84 |
else: |
|
85 |
main_task.status = "LO" |
|
86 |
||
87 |
main_task.save() |
|
88 |
||
105
091b044a3bf4
now adding mentor for a task happens through request. notifications still pending though
nishanth
parents:
99
diff
changeset
|
89 |
def reqMentor(task, mentor, req_by): |
091b044a3bf4
now adding mentor for a task happens through request. notifications still pending though
nishanth
parents:
99
diff
changeset
|
90 |
""" create a request object with role as MT. |
091b044a3bf4
now adding mentor for a task happens through request. notifications still pending though
nishanth
parents:
99
diff
changeset
|
91 |
""" |
091b044a3bf4
now adding mentor for a task happens through request. notifications still pending though
nishanth
parents:
99
diff
changeset
|
92 |
|
091b044a3bf4
now adding mentor for a task happens through request. notifications still pending though
nishanth
parents:
99
diff
changeset
|
93 |
create_request(sent_by=req_by, role="MT", sent_to=mentor, task=task) |
091b044a3bf4
now adding mentor for a task happens through request. notifications still pending though
nishanth
parents:
99
diff
changeset
|
94 |
|
19 | 95 |
def addMentor(task,mentor): |
96 |
""" add the mentor to mentors list of the task """ |
|
97 |
||
98 |
task.mentors.add(mentor) |
|
99 |
task.save() |
|
119 | 100 |
return task |
101 |
||
102 |
||
103 |
||
19 | 104 |
def createTask(title,desc,created_by,credits): |
105 |
""" creates a bare minimum task with title, description and credits. |
|
106 |
the creator of the task will be assigned as a mentor for the task. |
|
107 |
""" |
|
108 |
||
119 | 109 |
while True: |
110 |
id = get_key() |
|
111 |
try: |
|
112 |
task = Task.objects.get(id__iexact=id) |
|
113 |
continue |
|
114 |
except Task.DoesNotExist: |
|
115 |
break |
|
116 |
||
19 | 117 |
try: |
21
c28774fe7ffd
implemented "add another mentor" functionality to a task.
nishanth
parents:
19
diff
changeset
|
118 |
task = Task.objects.get(title__iexact=title) |
19 | 119 |
return None |
119 | 120 |
except: |
19 | 121 |
task = Task(title=title) |
119 | 122 |
|
123 |
task.id = id |
|
19 | 124 |
task.desc = desc |
125 |
task.created_by = created_by |
|
126 |
task.credits = credits |
|
127 |
task.creation_datetime = datetime.now() |
|
128 |
task.save() |
|
129 |
return task |
|
130 |
||
25
c0e4fc8b8b5b
added the functionality to assign a task to one of the claimed users.
nishanth
parents:
21
diff
changeset
|
131 |
def addClaim(task, message, user): |
c0e4fc8b8b5b
added the functionality to assign a task to one of the claimed users.
nishanth
parents:
21
diff
changeset
|
132 |
""" add claim data to the database if it does not exist |
c0e4fc8b8b5b
added the functionality to assign a task to one of the claimed users.
nishanth
parents:
21
diff
changeset
|
133 |
and also update the claimed users field of the task. |
c0e4fc8b8b5b
added the functionality to assign a task to one of the claimed users.
nishanth
parents:
21
diff
changeset
|
134 |
""" |
c0e4fc8b8b5b
added the functionality to assign a task to one of the claimed users.
nishanth
parents:
21
diff
changeset
|
135 |
|
c0e4fc8b8b5b
added the functionality to assign a task to one of the claimed users.
nishanth
parents:
21
diff
changeset
|
136 |
task.claimed_users.add(user) |
c0e4fc8b8b5b
added the functionality to assign a task to one of the claimed users.
nishanth
parents:
21
diff
changeset
|
137 |
task.save() |
c0e4fc8b8b5b
added the functionality to assign a task to one of the claimed users.
nishanth
parents:
21
diff
changeset
|
138 |
claim = Claim() |
c0e4fc8b8b5b
added the functionality to assign a task to one of the claimed users.
nishanth
parents:
21
diff
changeset
|
139 |
claim.message = message |
c0e4fc8b8b5b
added the functionality to assign a task to one of the claimed users.
nishanth
parents:
21
diff
changeset
|
140 |
claim.task = task |
c0e4fc8b8b5b
added the functionality to assign a task to one of the claimed users.
nishanth
parents:
21
diff
changeset
|
141 |
claim.user = user |
c0e4fc8b8b5b
added the functionality to assign a task to one of the claimed users.
nishanth
parents:
21
diff
changeset
|
142 |
claim.creation_datetime = datetime.now() |
c0e4fc8b8b5b
added the functionality to assign a task to one of the claimed users.
nishanth
parents:
21
diff
changeset
|
143 |
claim.save() |
c0e4fc8b8b5b
added the functionality to assign a task to one of the claimed users.
nishanth
parents:
21
diff
changeset
|
144 |
|
c0e4fc8b8b5b
added the functionality to assign a task to one of the claimed users.
nishanth
parents:
21
diff
changeset
|
145 |
def assignTask(task, user): |
c0e4fc8b8b5b
added the functionality to assign a task to one of the claimed users.
nishanth
parents:
21
diff
changeset
|
146 |
""" check for the status of task and assign it to the particular user """ |
c0e4fc8b8b5b
added the functionality to assign a task to one of the claimed users.
nishanth
parents:
21
diff
changeset
|
147 |
|
63
1fc027bf99ee
added events in task.py for adding subtask and dependencies
nishanth
parents:
55
diff
changeset
|
148 |
if task.status in ['OP', 'WR']: |
1fc027bf99ee
added events in task.py for adding subtask and dependencies
nishanth
parents:
55
diff
changeset
|
149 |
task.assigned_users.add(user) |
1fc027bf99ee
added events in task.py for adding subtask and dependencies
nishanth
parents:
55
diff
changeset
|
150 |
task.claimed_users.remove(user) |
1fc027bf99ee
added events in task.py for adding subtask and dependencies
nishanth
parents:
55
diff
changeset
|
151 |
task.status = "WR" |
25
c0e4fc8b8b5b
added the functionality to assign a task to one of the claimed users.
nishanth
parents:
21
diff
changeset
|
152 |
task.save() |
55
ca2486e29178
added a utility called getTask in task events and made changes in task views accordingly
nishanth
parents:
54
diff
changeset
|
153 |
|
63
1fc027bf99ee
added events in task.py for adding subtask and dependencies
nishanth
parents:
55
diff
changeset
|
154 |
|
1fc027bf99ee
added events in task.py for adding subtask and dependencies
nishanth
parents:
55
diff
changeset
|
155 |
def updateTask(task, title=None, desc=None, credits=None, tags_field=None): |
1fc027bf99ee
added events in task.py for adding subtask and dependencies
nishanth
parents:
55
diff
changeset
|
156 |
""" update the property accordingly. |
1fc027bf99ee
added events in task.py for adding subtask and dependencies
nishanth
parents:
55
diff
changeset
|
157 |
while updating title, check for uniqueness of title. |
1fc027bf99ee
added events in task.py for adding subtask and dependencies
nishanth
parents:
55
diff
changeset
|
158 |
return None if any error. |
1fc027bf99ee
added events in task.py for adding subtask and dependencies
nishanth
parents:
55
diff
changeset
|
159 |
""" |
1fc027bf99ee
added events in task.py for adding subtask and dependencies
nishanth
parents:
55
diff
changeset
|
160 |
|
1fc027bf99ee
added events in task.py for adding subtask and dependencies
nishanth
parents:
55
diff
changeset
|
161 |
if title: |
1fc027bf99ee
added events in task.py for adding subtask and dependencies
nishanth
parents:
55
diff
changeset
|
162 |
try: |
1fc027bf99ee
added events in task.py for adding subtask and dependencies
nishanth
parents:
55
diff
changeset
|
163 |
task.title = title |
1fc027bf99ee
added events in task.py for adding subtask and dependencies
nishanth
parents:
55
diff
changeset
|
164 |
task.save() |
74 | 165 |
except Task.IntegrityError: |
63
1fc027bf99ee
added events in task.py for adding subtask and dependencies
nishanth
parents:
55
diff
changeset
|
166 |
return None |
1fc027bf99ee
added events in task.py for adding subtask and dependencies
nishanth
parents:
55
diff
changeset
|
167 |
if desc:task.desc = desc |
1fc027bf99ee
added events in task.py for adding subtask and dependencies
nishanth
parents:
55
diff
changeset
|
168 |
if credits:task.credits = credits |
1fc027bf99ee
added events in task.py for adding subtask and dependencies
nishanth
parents:
55
diff
changeset
|
169 |
if tags_field:task.tags_field = tags_field |
1fc027bf99ee
added events in task.py for adding subtask and dependencies
nishanth
parents:
55
diff
changeset
|
170 |
task.save() |
1fc027bf99ee
added events in task.py for adding subtask and dependencies
nishanth
parents:
55
diff
changeset
|
171 |
return task |
92
c99f09bebe56
added the capability to remove subtasks/dependencies .
nishanth
parents:
90
diff
changeset
|
172 |
|
c99f09bebe56
added the capability to remove subtasks/dependencies .
nishanth
parents:
90
diff
changeset
|
173 |
def removeTask(main_task, sub_task): |
c99f09bebe56
added the capability to remove subtasks/dependencies .
nishanth
parents:
90
diff
changeset
|
174 |
""" get the corresponding map object and remove the sub_task. |
c99f09bebe56
added the capability to remove subtasks/dependencies .
nishanth
parents:
90
diff
changeset
|
175 |
""" |
c99f09bebe56
added the capability to remove subtasks/dependencies .
nishanth
parents:
90
diff
changeset
|
176 |
|
c99f09bebe56
added the capability to remove subtasks/dependencies .
nishanth
parents:
90
diff
changeset
|
177 |
mapobj = Map.objects.get(main=main_task) |
c99f09bebe56
added the capability to remove subtasks/dependencies .
nishanth
parents:
90
diff
changeset
|
178 |
mapobj.subs.remove(sub_task) |
c99f09bebe56
added the capability to remove subtasks/dependencies .
nishanth
parents:
90
diff
changeset
|
179 |
mapobj.save() |
94 | 180 |
|
181 |
def removeUser(main_task, rem_user): |
|
182 |
""" right now, just remove the user from the list of assigned_users. |
|
183 |
""" |
|
184 |
||
185 |
main_task.assigned_users.remove(rem_user) |
|
186 |
main_task.save() |
|
95 | 187 |
|
188 |
def completeTask(main_task): |
|
189 |
""" set the status of task to CP. |
|
190 |
""" |
|
191 |
||
192 |
main_task.status = "CP" |
|
193 |
main_task.save() |
|
96
2881ed1c52b0
added events addCredits and assignCredits and modified assign_credits view accordingly.
nishanth
parents:
95
diff
changeset
|
194 |
|
2881ed1c52b0
added events addCredits and assignCredits and modified assign_credits view accordingly.
nishanth
parents:
95
diff
changeset
|
195 |
def assignCredits(task, given_by, given_to, points): |
2881ed1c52b0
added events addCredits and assignCredits and modified assign_credits view accordingly.
nishanth
parents:
95
diff
changeset
|
196 |
""" make a proper request object. |
2881ed1c52b0
added events addCredits and assignCredits and modified assign_credits view accordingly.
nishanth
parents:
95
diff
changeset
|
197 |
""" |
2881ed1c52b0
added events addCredits and assignCredits and modified assign_credits view accordingly.
nishanth
parents:
95
diff
changeset
|
198 |
|
99
64c34c1f441f
assign_credits event now creates a proper request object .
nishanth
parents:
96
diff
changeset
|
199 |
create_request(sent_by=given_by, role="PY", task=task, receiving_user=given_to, pynts=points ) |
96
2881ed1c52b0
added events addCredits and assignCredits and modified assign_credits view accordingly.
nishanth
parents:
95
diff
changeset
|
200 |
|
2881ed1c52b0
added events addCredits and assignCredits and modified assign_credits view accordingly.
nishanth
parents:
95
diff
changeset
|
201 |
def addCredits(task, given_by, given_to, points): |
2881ed1c52b0
added events addCredits and assignCredits and modified assign_credits view accordingly.
nishanth
parents:
95
diff
changeset
|
202 |
""" add credit to the credits model. |
2881ed1c52b0
added events addCredits and assignCredits and modified assign_credits view accordingly.
nishanth
parents:
95
diff
changeset
|
203 |
""" |
2881ed1c52b0
added events addCredits and assignCredits and modified assign_credits view accordingly.
nishanth
parents:
95
diff
changeset
|
204 |
|
2881ed1c52b0
added events addCredits and assignCredits and modified assign_credits view accordingly.
nishanth
parents:
95
diff
changeset
|
205 |
creditobj = Credit() |
2881ed1c52b0
added events addCredits and assignCredits and modified assign_credits view accordingly.
nishanth
parents:
95
diff
changeset
|
206 |
creditobj.task = task |
2881ed1c52b0
added events addCredits and assignCredits and modified assign_credits view accordingly.
nishanth
parents:
95
diff
changeset
|
207 |
creditobj.given_by = given_by |
2881ed1c52b0
added events addCredits and assignCredits and modified assign_credits view accordingly.
nishanth
parents:
95
diff
changeset
|
208 |
creditobj.given_to = given_to |
2881ed1c52b0
added events addCredits and assignCredits and modified assign_credits view accordingly.
nishanth
parents:
95
diff
changeset
|
209 |
creditobj.points = points |
2881ed1c52b0
added events addCredits and assignCredits and modified assign_credits view accordingly.
nishanth
parents:
95
diff
changeset
|
210 |
creditobj.given_time = datetime.now() |
2881ed1c52b0
added events addCredits and assignCredits and modified assign_credits view accordingly.
nishanth
parents:
95
diff
changeset
|
211 |
creditobj.save() |
114 | 212 |
|
213 |
def completeTask(task, marked_by): |
|
214 |
""" set the status of task as completed. |
|
215 |
We dont have to inform parent tasks. |
|
216 |
That part is taken care by getTask method. |
|
217 |
""" |
|
218 |
||
219 |
task.status = "CM" |
|
220 |
task.save() |
|
221 |
||
117
58fa1d626d37
now if a task is closed/completed all its pending requests will be made invalid.
nishanth
parents:
114
diff
changeset
|
222 |
task.request_task.filter(is_replied=False).update(is_valid=False) |
58fa1d626d37
now if a task is closed/completed all its pending requests will be made invalid.
nishanth
parents:
114
diff
changeset
|
223 |
|
114 | 224 |
## generate notification appropriately using marked_by |
225 |
## we also have to mark unread requests as invalid |
|
226 |
||
227 |