# HG changeset patch # User nishanth # Date 1267204519 -19800 # Node ID 6d92b7cd2a3724f5a3249cc22f195a2ee4928e1a # Parent a6b4234388c8f4b93f8b5036e1e9e3c58665e63d taking care if publish task post request is made again. added published_date field to task. diff -r a6b4234388c8 -r 6d92b7cd2a37 taskapp/events/task.py --- a/taskapp/events/task.py Fri Feb 26 18:34:30 2010 +0530 +++ b/taskapp/events/task.py Fri Feb 26 22:45:19 2010 +0530 @@ -25,6 +25,8 @@ 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 @@ task.created_by = created_by task.credits = credits task.creation_datetime = datetime.now() + task.published_datetime = datetime.now() task.save() return task diff -r a6b4234388c8 -r 6d92b7cd2a37 taskapp/models.py --- a/taskapp/models.py Fri Feb 26 18:34:30 2010 +0530 +++ b/taskapp/models.py Fri Feb 26 22:45:19 2010 +0530 @@ -87,6 +87,7 @@ 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 -r a6b4234388c8 -r 6d92b7cd2a37 taskapp/views/task.py --- a/taskapp/views/task.py Fri Feb 26 18:34:30 2010 +0530 +++ b/taskapp/views/task.py Fri Feb 26 22:45:19 2010 +0530 @@ -16,7 +16,7 @@ """ 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 @@ 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 @@ 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 """