author | nishanth |
Thu, 25 Feb 2010 17:00:18 +0530 | |
changeset 96 | 2881ed1c52b0 |
parent 95 | e4034904f82e |
child 99 | 64c34c1f441f |
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 |
19 | 3 |
|
4 |
def publishTask(task): |
|
5 |
""" 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
|
6 |
|
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
|
7 |
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
|
8 |
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
|
9 |
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
|
10 |
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
|
11 |
|
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 |
if subs or any(map(lambda t:t.status!="CM",deps)): |
53 | 13 |
task.status = "LO" |
14 |
else: |
|
15 |
task.status = "OP" |
|
19 | 16 |
task.save() |
17 |
return task |
|
18 |
||
54 | 19 |
def addSubTask(main_task, sub_task): |
20 |
""" 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
|
21 |
sub task can be added only if a task is in UP/OP/LO state. |
54 | 22 |
""" |
23 |
||
24 |
## Shall modify after talking to pr about subtasks |
|
25 |
## 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
|
26 |
|
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
|
27 |
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
|
28 |
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
|
29 |
|
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
|
30 |
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
|
31 |
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
|
32 |
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
|
33 |
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
|
34 |
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
|
35 |
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
|
36 |
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
|
37 |
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
|
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 |
sub_tasks = getTask(main_task.id).subs |
54 | 40 |
if main_task.status == "OP": |
41 |
if any(map(lambda t:t.status!="CM",sub_tasks)): |
|
42 |
main_task.status = "LO" |
|
43 |
else: |
|
44 |
"CM" |
|
45 |
main_task.save() |
|
46 |
||
47 |
def addDep(main_task, dependency): |
|
48 |
""" add the dependency task to deps attribute of the task. |
|
49 |
update the status of main_task accordingly. |
|
89
1cc03941ed5d
added the capability of adding subtasks/dependencies .
nishanth
parents:
74
diff
changeset
|
50 |
note that deps can be added only if task is in UP/OP/LO state. |
54 | 51 |
And also if the task doesn't have any subs. |
52 |
""" |
|
53 |
||
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
|
54 |
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
|
55 |
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
|
56 |
|
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
|
57 |
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
|
58 |
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
|
59 |
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
|
60 |
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
|
61 |
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
|
62 |
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
|
63 |
|
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
|
64 |
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
|
65 |
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
|
66 |
|
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 |
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
|
68 |
|
54 | 69 |
if main_task.status in ["OP", "LO"]: |
70 |
if all(map(lambda t:t.status=="CM",deps)): |
|
71 |
main_task.status = "OP" |
|
72 |
else: |
|
73 |
main_task.status = "LO" |
|
74 |
||
75 |
main_task.save() |
|
76 |
||
19 | 77 |
def addMentor(task,mentor): |
78 |
""" add the mentor to mentors list of the task """ |
|
79 |
||
80 |
task.mentors.add(mentor) |
|
81 |
task.save() |
|
82 |
return task |
|
83 |
||
84 |
def createTask(title,desc,created_by,credits): |
|
85 |
""" creates a bare minimum task with title, description and credits. |
|
86 |
the creator of the task will be assigned as a mentor for the task. |
|
87 |
""" |
|
88 |
||
89 |
try: |
|
21
c28774fe7ffd
implemented "add another mentor" functionality to a task.
nishanth
parents:
19
diff
changeset
|
90 |
task = Task.objects.get(title__iexact=title) |
19 | 91 |
return None |
92 |
except Task.DoesNotExist: |
|
93 |
task = Task(title=title) |
|
94 |
task.desc = desc |
|
95 |
task.created_by = created_by |
|
96 |
task.credits = credits |
|
97 |
task.creation_datetime = datetime.now() |
|
98 |
task.save() |
|
99 |
return task |
|
100 |
||
25
c0e4fc8b8b5b
added the functionality to assign a task to one of the claimed users.
nishanth
parents:
21
diff
changeset
|
101 |
def addClaim(task, message, user): |
c0e4fc8b8b5b
added the functionality to assign a task to one of the claimed users.
nishanth
parents:
21
diff
changeset
|
102 |
""" 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
|
103 |
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
|
104 |
""" |
c0e4fc8b8b5b
added the functionality to assign a task to one of the claimed users.
nishanth
parents:
21
diff
changeset
|
105 |
|
c0e4fc8b8b5b
added the functionality to assign a task to one of the claimed users.
nishanth
parents:
21
diff
changeset
|
106 |
task.claimed_users.add(user) |
c0e4fc8b8b5b
added the functionality to assign a task to one of the claimed users.
nishanth
parents:
21
diff
changeset
|
107 |
task.save() |
c0e4fc8b8b5b
added the functionality to assign a task to one of the claimed users.
nishanth
parents:
21
diff
changeset
|
108 |
claim = Claim() |
c0e4fc8b8b5b
added the functionality to assign a task to one of the claimed users.
nishanth
parents:
21
diff
changeset
|
109 |
claim.message = message |
c0e4fc8b8b5b
added the functionality to assign a task to one of the claimed users.
nishanth
parents:
21
diff
changeset
|
110 |
claim.task = task |
c0e4fc8b8b5b
added the functionality to assign a task to one of the claimed users.
nishanth
parents:
21
diff
changeset
|
111 |
claim.user = user |
c0e4fc8b8b5b
added the functionality to assign a task to one of the claimed users.
nishanth
parents:
21
diff
changeset
|
112 |
claim.creation_datetime = datetime.now() |
c0e4fc8b8b5b
added the functionality to assign a task to one of the claimed users.
nishanth
parents:
21
diff
changeset
|
113 |
claim.save() |
c0e4fc8b8b5b
added the functionality to assign a task to one of the claimed users.
nishanth
parents:
21
diff
changeset
|
114 |
|
c0e4fc8b8b5b
added the functionality to assign a task to one of the claimed users.
nishanth
parents:
21
diff
changeset
|
115 |
def assignTask(task, user): |
c0e4fc8b8b5b
added the functionality to assign a task to one of the claimed users.
nishanth
parents:
21
diff
changeset
|
116 |
""" 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
|
117 |
|
63
1fc027bf99ee
added events in task.py for adding subtask and dependencies
nishanth
parents:
55
diff
changeset
|
118 |
if task.status in ['OP', 'WR']: |
1fc027bf99ee
added events in task.py for adding subtask and dependencies
nishanth
parents:
55
diff
changeset
|
119 |
task.assigned_users.add(user) |
1fc027bf99ee
added events in task.py for adding subtask and dependencies
nishanth
parents:
55
diff
changeset
|
120 |
task.claimed_users.remove(user) |
1fc027bf99ee
added events in task.py for adding subtask and dependencies
nishanth
parents:
55
diff
changeset
|
121 |
task.status = "WR" |
25
c0e4fc8b8b5b
added the functionality to assign a task to one of the claimed users.
nishanth
parents:
21
diff
changeset
|
122 |
task.save() |
55
ca2486e29178
added a utility called getTask in task events and made changes in task views accordingly
nishanth
parents:
54
diff
changeset
|
123 |
|
ca2486e29178
added a utility called getTask in task events and made changes in task views accordingly
nishanth
parents:
54
diff
changeset
|
124 |
def getTask(tid): |
ca2486e29178
added a utility called getTask in task events and made changes in task views accordingly
nishanth
parents:
54
diff
changeset
|
125 |
""" retreive the task from database. |
ca2486e29178
added a utility called getTask in task events and made changes in task views accordingly
nishanth
parents:
54
diff
changeset
|
126 |
if the task has deps or subs, update its status correspondingly. |
ca2486e29178
added a utility called getTask in task events and made changes in task views accordingly
nishanth
parents:
54
diff
changeset
|
127 |
""" |
ca2486e29178
added a utility called getTask in task events and made changes in task views accordingly
nishanth
parents:
54
diff
changeset
|
128 |
|
ca2486e29178
added a utility called getTask in task events and made changes in task views accordingly
nishanth
parents:
54
diff
changeset
|
129 |
task = Task.objects.get(id=tid) |
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
|
130 |
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
|
131 |
mapobj = Map.objects.get(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
|
132 |
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
|
133 |
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
|
134 |
mapobj.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
|
135 |
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
|
136 |
|
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
|
137 |
task_subs = mapobj.subs.all() |
55
ca2486e29178
added a utility called getTask in task events and made changes in task views accordingly
nishanth
parents:
54
diff
changeset
|
138 |
|
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
|
139 |
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
|
140 |
task.deps, task.subs = task_subs, [] |
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
|
141 |
elif 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
|
142 |
task.subs, task.deps = task_subs, [] |
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
|
143 |
|
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
|
144 |
deps, subs = task.deps, task.subs |
55
ca2486e29178
added a utility called getTask in task events and made changes in task views accordingly
nishanth
parents:
54
diff
changeset
|
145 |
if deps and task.status in ["OP", "LO"]: |
ca2486e29178
added a utility called getTask in task events and made changes in task views accordingly
nishanth
parents:
54
diff
changeset
|
146 |
task.status = "OP" if all(map(lambda t:t.status=="CM",deps)) else "LO" |
ca2486e29178
added a utility called getTask in task events and made changes in task views accordingly
nishanth
parents:
54
diff
changeset
|
147 |
if subs and task.status in ["OP", "LO", "CM"]: |
ca2486e29178
added a utility called getTask in task events and made changes in task views accordingly
nishanth
parents:
54
diff
changeset
|
148 |
task.status = "CM" if all(map(lambda t:t.status=="CM",subs)) else "LO" |
ca2486e29178
added a utility called getTask in task events and made changes in task views accordingly
nishanth
parents:
54
diff
changeset
|
149 |
|
ca2486e29178
added a utility called getTask in task events and made changes in task views accordingly
nishanth
parents:
54
diff
changeset
|
150 |
task.save() |
ca2486e29178
added a utility called getTask in task events and made changes in task views accordingly
nishanth
parents:
54
diff
changeset
|
151 |
return task |
63
1fc027bf99ee
added events in task.py for adding subtask and dependencies
nishanth
parents:
55
diff
changeset
|
152 |
|
1fc027bf99ee
added events in task.py for adding subtask and dependencies
nishanth
parents:
55
diff
changeset
|
153 |
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
|
154 |
""" update the property accordingly. |
1fc027bf99ee
added events in task.py for adding subtask and dependencies
nishanth
parents:
55
diff
changeset
|
155 |
while updating title, check for uniqueness of title. |
1fc027bf99ee
added events in task.py for adding subtask and dependencies
nishanth
parents:
55
diff
changeset
|
156 |
return None if any error. |
1fc027bf99ee
added events in task.py for adding subtask and dependencies
nishanth
parents:
55
diff
changeset
|
157 |
""" |
1fc027bf99ee
added events in task.py for adding subtask and dependencies
nishanth
parents:
55
diff
changeset
|
158 |
|
1fc027bf99ee
added events in task.py for adding subtask and dependencies
nishanth
parents:
55
diff
changeset
|
159 |
if title: |
1fc027bf99ee
added events in task.py for adding subtask and dependencies
nishanth
parents:
55
diff
changeset
|
160 |
try: |
1fc027bf99ee
added events in task.py for adding subtask and dependencies
nishanth
parents:
55
diff
changeset
|
161 |
task.title = title |
1fc027bf99ee
added events in task.py for adding subtask and dependencies
nishanth
parents:
55
diff
changeset
|
162 |
task.save() |
74 | 163 |
except Task.IntegrityError: |
63
1fc027bf99ee
added events in task.py for adding subtask and dependencies
nishanth
parents:
55
diff
changeset
|
164 |
return None |
1fc027bf99ee
added events in task.py for adding subtask and dependencies
nishanth
parents:
55
diff
changeset
|
165 |
if desc:task.desc = desc |
1fc027bf99ee
added events in task.py for adding subtask and dependencies
nishanth
parents:
55
diff
changeset
|
166 |
if credits:task.credits = credits |
1fc027bf99ee
added events in task.py for adding subtask and dependencies
nishanth
parents:
55
diff
changeset
|
167 |
if tags_field:task.tags_field = tags_field |
1fc027bf99ee
added events in task.py for adding subtask and dependencies
nishanth
parents:
55
diff
changeset
|
168 |
task.save() |
1fc027bf99ee
added events in task.py for adding subtask and dependencies
nishanth
parents:
55
diff
changeset
|
169 |
return task |
92
c99f09bebe56
added the capability to remove subtasks/dependencies .
nishanth
parents:
90
diff
changeset
|
170 |
|
c99f09bebe56
added the capability to remove subtasks/dependencies .
nishanth
parents:
90
diff
changeset
|
171 |
def removeTask(main_task, sub_task): |
c99f09bebe56
added the capability to remove subtasks/dependencies .
nishanth
parents:
90
diff
changeset
|
172 |
""" get the corresponding map object and remove the sub_task. |
c99f09bebe56
added the capability to remove subtasks/dependencies .
nishanth
parents:
90
diff
changeset
|
173 |
""" |
c99f09bebe56
added the capability to remove subtasks/dependencies .
nishanth
parents:
90
diff
changeset
|
174 |
|
c99f09bebe56
added the capability to remove subtasks/dependencies .
nishanth
parents:
90
diff
changeset
|
175 |
mapobj = Map.objects.get(main=main_task) |
c99f09bebe56
added the capability to remove subtasks/dependencies .
nishanth
parents:
90
diff
changeset
|
176 |
mapobj.subs.remove(sub_task) |
c99f09bebe56
added the capability to remove subtasks/dependencies .
nishanth
parents:
90
diff
changeset
|
177 |
mapobj.save() |
94 | 178 |
|
179 |
def removeUser(main_task, rem_user): |
|
180 |
""" right now, just remove the user from the list of assigned_users. |
|
181 |
""" |
|
182 |
||
183 |
main_task.assigned_users.remove(rem_user) |
|
184 |
main_task.save() |
|
95 | 185 |
|
186 |
def completeTask(main_task): |
|
187 |
""" set the status of task to CP. |
|
188 |
""" |
|
189 |
||
190 |
main_task.status = "CP" |
|
191 |
main_task.save() |
|
96
2881ed1c52b0
added events addCredits and assignCredits and modified assign_credits view accordingly.
nishanth
parents:
95
diff
changeset
|
192 |
|
2881ed1c52b0
added events addCredits and assignCredits and modified assign_credits view accordingly.
nishanth
parents:
95
diff
changeset
|
193 |
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
|
194 |
""" make a proper request object. |
2881ed1c52b0
added events addCredits and assignCredits and modified assign_credits view accordingly.
nishanth
parents:
95
diff
changeset
|
195 |
""" |
2881ed1c52b0
added events addCredits and assignCredits and modified assign_credits view accordingly.
nishanth
parents:
95
diff
changeset
|
196 |
|
2881ed1c52b0
added events addCredits and assignCredits and modified assign_credits view accordingly.
nishanth
parents:
95
diff
changeset
|
197 |
addCredits(task, given_by, given_to, points) |
2881ed1c52b0
added events addCredits and assignCredits and modified assign_credits view accordingly.
nishanth
parents:
95
diff
changeset
|
198 |
|
2881ed1c52b0
added events addCredits and assignCredits and modified assign_credits view accordingly.
nishanth
parents:
95
diff
changeset
|
199 |
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
|
200 |
""" add credit to the credits model. |
2881ed1c52b0
added events addCredits and assignCredits and modified assign_credits view accordingly.
nishanth
parents:
95
diff
changeset
|
201 |
""" |
2881ed1c52b0
added events addCredits and assignCredits and modified assign_credits view accordingly.
nishanth
parents:
95
diff
changeset
|
202 |
|
2881ed1c52b0
added events addCredits and assignCredits and modified assign_credits view accordingly.
nishanth
parents:
95
diff
changeset
|
203 |
creditobj = Credit() |
2881ed1c52b0
added events addCredits and assignCredits and modified assign_credits view accordingly.
nishanth
parents:
95
diff
changeset
|
204 |
creditobj.task = task |
2881ed1c52b0
added events addCredits and assignCredits and modified assign_credits view accordingly.
nishanth
parents:
95
diff
changeset
|
205 |
creditobj.given_by = given_by |
2881ed1c52b0
added events addCredits and assignCredits and modified assign_credits view accordingly.
nishanth
parents:
95
diff
changeset
|
206 |
creditobj.given_to = given_to |
2881ed1c52b0
added events addCredits and assignCredits and modified assign_credits view accordingly.
nishanth
parents:
95
diff
changeset
|
207 |
creditobj.points = points |
2881ed1c52b0
added events addCredits and assignCredits and modified assign_credits view accordingly.
nishanth
parents:
95
diff
changeset
|
208 |
creditobj.given_time = datetime.now() |
2881ed1c52b0
added events addCredits and assignCredits and modified assign_credits view accordingly.
nishanth
parents:
95
diff
changeset
|
209 |
creditobj.save() |