diff options
author | nishanth | 2010-03-02 16:55:33 +0530 |
---|---|---|
committer | nishanth | 2010-03-02 16:55:33 +0530 |
commit | 986b3a639e6849e19203cb24b7495033d4bb35ca (patch) | |
tree | 48da0616e287e44b7c677fb3ae0d858e7471a51d /taskapp/views/task.py | |
parent | 3a43223126b7c9665522c314d526579da5dcaee2 (diff) | |
download | pytask-986b3a639e6849e19203cb24b7495033d4bb35ca.tar.gz pytask-986b3a639e6849e19203cb24b7495033d4bb35ca.tar.bz2 pytask-986b3a639e6849e19203cb24b7495033d4bb35ca.zip |
now editing of tasks is done in elegant way.
Diffstat (limited to 'taskapp/views/task.py')
-rw-r--r-- | taskapp/views/task.py | 20 |
1 files changed, 3 insertions, 17 deletions
diff --git a/taskapp/views/task.py b/taskapp/views/task.py index aadaa4b..195d98e 100644 --- a/taskapp/views/task.py +++ b/taskapp/views/task.py @@ -530,25 +530,12 @@ def edit_task(request, tid): can_edit = True if is_mentor and task.status == "UP" else False if can_edit: - form = EditTaskForm(task) + form = EditTaskForm(instance=task) if request.method=="POST": data = request.POST - form = EditTaskForm(task, data) + form = EditTaskForm(data, instance=task) if form.is_valid(): - data = form.cleaned_data - title = data['title'] - try: - prev_task = Task.objects.exclude(status="DL").get(title__iexact=title) - if prev_task != task: - error_msg = "Another task exists with the same title" - return render_to_response('task/edittask.html',{'user':user, 'form':form, 'error_msg':error_msg}) - except Task.DoesNotExist: - pass - task.title = title - task.desc = data['desc'] - task.tags_field = data['tags_field'] - task.credits = data['credits'] - task.save() + form.save() return redirect(task_url) else: return render_to_response('task/edittask.html',{'user':user, 'form':form}) @@ -634,7 +621,6 @@ def close_task(request, tid): else: return show_msg(user, "You are not authorised to do this", task_url, "view the task") - def delete_task(request, tid): """ mark the task status as DL. take a reason from the user and pass on to all the other mentors. |