summaryrefslogtreecommitdiff
path: root/taskapp/events/task.py
diff options
context:
space:
mode:
authornishanth2010-02-26 16:02:32 +0530
committernishanth2010-02-26 16:02:32 +0530
commit80f781b91da7c601746247086800147f9bb4e589 (patch)
treeb99707a63093f303c03db1aee1052974088b4f28 /taskapp/events/task.py
parent17d75d44c428de036655767bae2932075e544d19 (diff)
downloadpytask-80f781b91da7c601746247086800147f9bb4e589.tar.gz
pytask-80f781b91da7c601746247086800147f9bb4e589.tar.bz2
pytask-80f781b91da7c601746247086800147f9bb4e589.zip
did lots and now id field in task is a random key
Diffstat (limited to 'taskapp/events/task.py')
-rw-r--r--taskapp/events/task.py19
1 files changed, 16 insertions, 3 deletions
diff --git a/taskapp/events/task.py b/taskapp/events/task.py
index a8793cc..b60fb20 100644
--- a/taskapp/events/task.py
+++ b/taskapp/events/task.py
@@ -1,6 +1,7 @@
from datetime import datetime
from pytask.taskapp.models import Profile, Task, Comment, Credit, Claim, Map
from pytask.taskapp.utilities.request import create_request
+from pytask.taskapp.utilities.helper import get_key
def publishTask(task, rem_mentors=True, rem_comments=True):
""" set the task status to open """
@@ -95,18 +96,30 @@ def addMentor(task,mentor):
task.mentors.add(mentor)
task.save()
- return task
-
+ return task
+
+
+
def createTask(title,desc,created_by,credits):
""" creates a bare minimum task with title, description and credits.
the creator of the task will be assigned as a mentor for the task.
"""
+ while True:
+ id = get_key()
+ try:
+ task = Task.objects.get(id__iexact=id)
+ continue
+ except Task.DoesNotExist:
+ break
+
try:
task = Task.objects.get(title__iexact=title)
return None
- except Task.DoesNotExist:
+ except:
task = Task(title=title)
+
+ task.id = id
task.desc = desc
task.created_by = created_by
task.credits = credits