summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornishanth2010-02-26 22:45:19 +0530
committernishanth2010-02-26 22:45:19 +0530
commit6590772d0aef7a21e0ab87b4232631f2c142e5a9 (patch)
tree82726ae90470bc4e0bd98f0f86e3855a796f28e8
parentd784c93b2fc7332d0e54e5a8039e0692f78d7a35 (diff)
downloadpytask-6590772d0aef7a21e0ab87b4232631f2c142e5a9.tar.gz
pytask-6590772d0aef7a21e0ab87b4232631f2c142e5a9.tar.bz2
pytask-6590772d0aef7a21e0ab87b4232631f2c142e5a9.zip
taking care if publish task post request is made again. added published_date field to task.
-rw-r--r--taskapp/events/task.py3
-rw-r--r--taskapp/models.py1
-rw-r--r--taskapp/views/task.py19
3 files changed, 13 insertions, 10 deletions
diff --git a/taskapp/events/task.py b/taskapp/events/task.py
index 417d94d..93bd78d 100644
--- a/taskapp/events/task.py
+++ b/taskapp/events/task.py
@@ -25,6 +25,8 @@ def publishTask(task, rem_mentors=True, rem_comments=True):
task.comment_set.update(is_deleted=True)
task.comment_set.update(deleted_by=task.created_by)
+ task.published_datetime = datetime.datetime.now()
+
task.save()
return task
@@ -125,6 +127,7 @@ def createTask(title,desc,created_by,credits):
task.created_by = created_by
task.credits = credits
task.creation_datetime = datetime.now()
+ task.published_datetime = datetime.now()
task.save()
return task
diff --git a/taskapp/models.py b/taskapp/models.py
index aa75bc8..386b10e 100644
--- a/taskapp/models.py
+++ b/taskapp/models.py
@@ -87,6 +87,7 @@ class Task(models.Model):
assigned_users = models.ManyToManyField(User, blank = True, related_name = "%(class)s_assigned_users")
creation_datetime = models.DateTimeField()
+ published_datetime = models.DateTimeField()
sub_type = models.CharField(max_length=1, choices = (('D','Dependency'),('S','Subtask')), default = 'D')
def __unicode__(self):
diff --git a/taskapp/views/task.py b/taskapp/views/task.py
index c85d809..fe7349c 100644
--- a/taskapp/views/task.py
+++ b/taskapp/views/task.py
@@ -16,7 +16,7 @@ def browse_tasks(request):
""" display all the tasks """
user = request.user
- task_list = Task.objects.exclude(status="UP").exclude(status="DL").order_by('creation_datetime').reverse()
+ task_list = Task.objects.exclude(status="UP").exclude(status="DL").order_by('published_datetime').reverse()
context = {'user':user,
'task_list':task_list,
@@ -35,21 +35,21 @@ def publish_task(request, tid):
is_guest = True if not user.is_authenticated() else False
is_mentor = True if user in task.mentors.all() else False
- if user==task.created_by:
+ if user == task.created_by:
context = {
'user':user,
}
-
- if request.method == "POST":
- publishTask(task)
- return show_msg(user, "The task has been published", task_url, "view the task")
+ if task.status == "UP":
+ if request.method == "POST":
+ publishTask(task)
+ return show_msg(user, "The task has been published", task_url, "view the task")
+ else:
+ return render_to_response('task/publish.html', context)
else:
- return render_to_response('task/publish.html', context)
+ return show_msg(user, "The task is already published", task_url, "view the task")
else:
return show_msg(user, "You are not authorised to do this", '/task/browse/', "browse tasks")
-
-
def view_task(request, tid):
""" get the task depending on its tid and display accordingly if it is a get.
check for authentication and add a comment if it is a post request.
@@ -283,7 +283,6 @@ def remove_task(request, tid):
else:
return show_msg(user, "You are not authorised to do this", task_url, "view the task")
-
def claim_task(request, tid):
""" display a list of claims for get and display submit only if claimable """