author | nishanth |
Tue, 23 Feb 2010 10:41:43 +0530 | |
changeset 53 | 2c5062a93734 |
parent 25 | c0e4fc8b8b5b |
child 54 | 943d682aefdd |
permissions | -rw-r--r-- |
19 | 1 |
from datetime import datetime |
25
c0e4fc8b8b5b
added the functionality to assign a task to one of the claimed users.
nishanth
parents:
21
diff
changeset
|
2 |
from pytask.taskapp.models import Profile, Task, Comment, Credit, Claim |
19 | 3 |
|
4 |
def publishTask(task): |
|
5 |
""" set the task status to open """ |
|
6 |
||
53 | 7 |
sub_tasks = task.subs.all() |
8 |
dependencies = task.deps.all() |
|
9 |
if sub_tasks or any(map(lambda t:t.status!="CM",dependencies)): |
|
10 |
task.status = "LO" |
|
11 |
else: |
|
12 |
task.status = "OP" |
|
19 | 13 |
task.save() |
14 |
return task |
|
15 |
||
16 |
def addMentor(task,mentor): |
|
17 |
""" add the mentor to mentors list of the task """ |
|
18 |
||
19 |
task.mentors.add(mentor) |
|
20 |
task.save() |
|
21 |
return task |
|
22 |
||
23 |
def createTask(title,desc,created_by,credits): |
|
24 |
""" creates a bare minimum task with title, description and credits. |
|
25 |
the creator of the task will be assigned as a mentor for the task. |
|
26 |
""" |
|
27 |
||
28 |
try: |
|
21
c28774fe7ffd
implemented "add another mentor" functionality to a task.
nishanth
parents:
19
diff
changeset
|
29 |
task = Task.objects.get(title__iexact=title) |
19 | 30 |
return None |
31 |
except Task.DoesNotExist: |
|
32 |
task = Task(title=title) |
|
33 |
task.desc = desc |
|
34 |
task.created_by = created_by |
|
35 |
task.credits = credits |
|
36 |
task.creation_datetime = datetime.now() |
|
37 |
task.save() |
|
38 |
return task |
|
39 |
||
21
c28774fe7ffd
implemented "add another mentor" functionality to a task.
nishanth
parents:
19
diff
changeset
|
40 |
def addSubTask(main_task, sub_task): |
c28774fe7ffd
implemented "add another mentor" functionality to a task.
nishanth
parents:
19
diff
changeset
|
41 |
""" add sub_task to subs list of main_task """ |
c28774fe7ffd
implemented "add another mentor" functionality to a task.
nishanth
parents:
19
diff
changeset
|
42 |
|
c28774fe7ffd
implemented "add another mentor" functionality to a task.
nishanth
parents:
19
diff
changeset
|
43 |
main_task.subs.add(sub_task) |
c28774fe7ffd
implemented "add another mentor" functionality to a task.
nishanth
parents:
19
diff
changeset
|
44 |
main_task.status = "LO" |
c28774fe7ffd
implemented "add another mentor" functionality to a task.
nishanth
parents:
19
diff
changeset
|
45 |
main_task.save() |
c28774fe7ffd
implemented "add another mentor" functionality to a task.
nishanth
parents:
19
diff
changeset
|
46 |
return main_task |
25
c0e4fc8b8b5b
added the functionality to assign a task to one of the claimed users.
nishanth
parents:
21
diff
changeset
|
47 |
|
c0e4fc8b8b5b
added the functionality to assign a task to one of the claimed users.
nishanth
parents:
21
diff
changeset
|
48 |
def addClaim(task, message, user): |
c0e4fc8b8b5b
added the functionality to assign a task to one of the claimed users.
nishanth
parents:
21
diff
changeset
|
49 |
""" 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
|
50 |
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
|
51 |
""" |
c0e4fc8b8b5b
added the functionality to assign a task to one of the claimed users.
nishanth
parents:
21
diff
changeset
|
52 |
|
c0e4fc8b8b5b
added the functionality to assign a task to one of the claimed users.
nishanth
parents:
21
diff
changeset
|
53 |
task.claimed_users.add(user) |
c0e4fc8b8b5b
added the functionality to assign a task to one of the claimed users.
nishanth
parents:
21
diff
changeset
|
54 |
task.status = "CL" |
c0e4fc8b8b5b
added the functionality to assign a task to one of the claimed users.
nishanth
parents:
21
diff
changeset
|
55 |
task.save() |
c0e4fc8b8b5b
added the functionality to assign a task to one of the claimed users.
nishanth
parents:
21
diff
changeset
|
56 |
claim = Claim() |
c0e4fc8b8b5b
added the functionality to assign a task to one of the claimed users.
nishanth
parents:
21
diff
changeset
|
57 |
claim.message = message |
c0e4fc8b8b5b
added the functionality to assign a task to one of the claimed users.
nishanth
parents:
21
diff
changeset
|
58 |
claim.task = task |
c0e4fc8b8b5b
added the functionality to assign a task to one of the claimed users.
nishanth
parents:
21
diff
changeset
|
59 |
claim.user = user |
c0e4fc8b8b5b
added the functionality to assign a task to one of the claimed users.
nishanth
parents:
21
diff
changeset
|
60 |
claim.creation_datetime = datetime.now() |
c0e4fc8b8b5b
added the functionality to assign a task to one of the claimed users.
nishanth
parents:
21
diff
changeset
|
61 |
claim.save() |
c0e4fc8b8b5b
added the functionality to assign a task to one of the claimed users.
nishanth
parents:
21
diff
changeset
|
62 |
|
c0e4fc8b8b5b
added the functionality to assign a task to one of the claimed users.
nishanth
parents:
21
diff
changeset
|
63 |
def assignTask(task, user): |
c0e4fc8b8b5b
added the functionality to assign a task to one of the claimed users.
nishanth
parents:
21
diff
changeset
|
64 |
""" 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
|
65 |
|
c0e4fc8b8b5b
added the functionality to assign a task to one of the claimed users.
nishanth
parents:
21
diff
changeset
|
66 |
task.assigned_users.add(user) |
c0e4fc8b8b5b
added the functionality to assign a task to one of the claimed users.
nishanth
parents:
21
diff
changeset
|
67 |
task.status = "AS" |
c0e4fc8b8b5b
added the functionality to assign a task to one of the claimed users.
nishanth
parents:
21
diff
changeset
|
68 |
task.save() |