]> git.openstreetmap.org Git - osqa.git/blobdiff - forum/views/commands.py
redirect to the question page if accept request has been made from a non-AJAX context...
[osqa.git] / 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}