]> git.openstreetmap.org Git - osqa.git/commitdiff
redirect to the question page if accept request has been made from a non-AJAX context...
authorjordan <jordan@0cfe37f9-358a-4d5e-be75-b63607b5c754>
Mon, 10 Oct 2011 22:01:13 +0000 (22:01 +0000)
committerjordan <jordan@0cfe37f9-358a-4d5e-be75-b63607b5c754>
Mon, 10 Oct 2011 22:01:13 +0000 (22:01 +0000)
git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@1186 0cfe37f9-358a-4d5e-be75-b63607b5c754

forum/views/commands.py

index 7abdbef7f5633521fda8b50ed60bc9580c92e856..4bfcf6be71df90f8b00e4f82395b569cf50f7772 100644 (file)
@@ -8,7 +8,7 @@ from django.core.urlresolvers import reverse
 from django.utils import simplejson
 from django.utils.encoding import smart_unicode
 from django.utils.translation import ungettext, ugettext as _
-from django.http import HttpResponse, Http404
+from django.http import HttpResponse, HttpResponseRedirect, Http404
 from django.shortcuts import get_object_or_404, render_to_response
 
 from forum.models import *
@@ -338,6 +338,11 @@ def accept_answer(request, id):
 
 
         AcceptAnswerAction(node=answer, user=user, ip=request.META['REMOTE_ADDR']).save()
+
+        # If the request is not an AJAX redirect to the answer URL rather than to the home page
+        if not request.is_ajax():
+            return HttpResponseRedirect(answer.get_absolute_url())
+
         commands['mark_accepted'] = [answer.id]
 
     return {'commands': commands}