author | anoop |
Mon, 01 Feb 2010 14:14:04 +0530 | |
changeset 17 | 9ca9f98af0eb |
parent 14 | f2623fb8041a |
child 18 | 293692eb8f06 |
permissions | -rw-r--r-- |
12 | 1 |
from datetime import datetime |
2 |
from pytask.taskapp.models import Profile, Task, Comment, Credit |
|
3 |
||
4 |
def publishTask(task): |
|
5 |
""" set the task status to open """ |
|
6 |
||
7 |
task.status = "OP" |
|
8 |
task.save() |
|
9 |
return task |
|
10 |
||
11 |
def addMentor(task,mentor): |
|
12 |
""" add the mentor to mentors list of the task """ |
|
13 |
||
14 |
task.mentors.add(mentor) |
|
15 |
task.save() |
|
16 |
return task |
|
17 |
||
18 |
def createTask(title,desc,created_by,credits): |
|
19 |
""" creates a bare minimum task with title, description and credits. |
|
20 |
the creator of the task will be assigned as a mentor for the task. |
|
21 |
""" |
|
22 |
||
23 |
try: |
|
14
f2623fb8041a
implemented add another mentor functionality to a task.
nishanth
parents:
12
diff
changeset
|
24 |
task = Task.objects.get(title__iexact=title) |
12 | 25 |
return None |
26 |
except Task.DoesNotExist: |
|
27 |
task = Task(title=title) |
|
28 |
task.desc = desc |
|
29 |
task.created_by = created_by |
|
30 |
task.credits = credits |
|
31 |
task.creation_datetime = datetime.now() |
|
32 |
task.save() |
|
33 |
return task |
|
34 |
||
14
f2623fb8041a
implemented add another mentor functionality to a task.
nishanth
parents:
12
diff
changeset
|
35 |
def addSubTask(main_task, sub_task): |
f2623fb8041a
implemented add another mentor functionality to a task.
nishanth
parents:
12
diff
changeset
|
36 |
""" add sub_task to subs list of main_task """ |
f2623fb8041a
implemented add another mentor functionality to a task.
nishanth
parents:
12
diff
changeset
|
37 |
|
f2623fb8041a
implemented add another mentor functionality to a task.
nishanth
parents:
12
diff
changeset
|
38 |
main_task.subs.add(sub_task) |
f2623fb8041a
implemented add another mentor functionality to a task.
nishanth
parents:
12
diff
changeset
|
39 |
main_task.status = "LO" |
f2623fb8041a
implemented add another mentor functionality to a task.
nishanth
parents:
12
diff
changeset
|
40 |
main_task.save() |
f2623fb8041a
implemented add another mentor functionality to a task.
nishanth
parents:
12
diff
changeset
|
41 |
return main_task |