# HG changeset patch # User Madhusudan.C.S # Date 1296569321 -19800 # Node ID a606a40584f7b15cef199f5112971a46b53343c7 # Parent 3e8fc2ba0bdeb1329d2fe9d8356d9847e5020de2 Base views should take keyword arguments and should use them for URLs. diff -r 3e8fc2ba0bde -r a606a40584f7 pytask/taskapp/views/task.py --- a/pytask/taskapp/views/task.py Tue Feb 01 19:37:27 2011 +0530 +++ b/pytask/taskapp/views/task.py Tue Feb 01 19:38:41 2011 +0530 @@ -5,6 +5,7 @@ for everything else. """ + __authors__ = [ '"Nishanth Amuluru" ', '"Madhusudan.C.S" ', @@ -148,7 +149,9 @@ # TODO(disable): Disable once the tasks can be claimed context['uberbar_message'] = DONT_CLAIM_TASK_MSG - task_url = reverse('view_task', kwargs={'task_id': task_id}) + task_url = kwargs.get( + 'task_url', reverse('view_task', kwargs={'task_id': task_id})) + task = shortcuts.get_object_or_404(taskapp_models.Task, pk=task_id) user = request.user @@ -269,7 +272,7 @@ 'task/view.html', RequestContext(request, context)) @login_required -def edit_task(request, task_id): +def edit_task(request, task_id, **kwargs): """ only creator gets to edit the task and that too only before it gets approved. """ @@ -277,7 +280,8 @@ user = request.user profile = user.get_profile() - task_url = reverse('view_task', kwargs={'task_id': task_id}) + task_url = kwargs.get( + 'task_url', reverse('view_task', kwargs={'task_id': task_id})) task = shortcuts.get_object_or_404(taskapp_models.Task, pk=task_id) is_creator = True if user == task.created_by else False diff -r 3e8fc2ba0bde -r a606a40584f7 pytask/taskapp/views/textbook.py --- a/pytask/taskapp/views/textbook.py Tue Feb 01 19:37:27 2011 +0530 +++ b/pytask/taskapp/views/textbook.py Tue Feb 01 19:38:41 2011 +0530 @@ -308,7 +308,12 @@ if chapter.parent.id != int(book_id): raise exceptions.PyTaskException(NOT_A_PARENT_FOR_CHAPTER) - return task_view.edit_task(request, chapter_id) + kwargs = { + 'task_url': reverse( + 'view_chapter', kwargs={'book_id': book_id, 'chapter_id': chapter_id}) + } + + return task_view.edit_task(request, chapter_id, **kwargs) def view_chapter(request, book_id, chapter_id, @@ -329,7 +334,11 @@ 'edit_url': reverse('edit_chapter', kwargs={ 'book_id': book_id, 'chapter_id': chapter_id}) } - kwargs = {'context': context} + kwargs = { + 'context': context, + 'task_url': reverse( + 'view_chapter', kwargs={'book_id': book_id, 'chapter_id': chapter_id}) + } return task_view.view_task(request, chapter_id, **kwargs)