Base views should take keyword arguments and should use them for URLs.
--- 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" <nishanth@fossee.in>',
'"Madhusudan.C.S" <madhusudancs@fossee.in>',
@@ -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
--- 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)