From ec913bbab0f8fb13449ff9d36e54da09bb4092dc Mon Sep 17 00:00:00 2001 From: jordan Date: Mon, 10 Oct 2011 22:01:13 +0000 Subject: [PATCH] redirect to the question page if accept request has been made from a non-AJAX context (it redirected to the home page before) git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@1186 0cfe37f9-358a-4d5e-be75-b63607b5c754 --- forum/views/commands.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/forum/views/commands.py b/forum/views/commands.py index 7abdbef..4bfcf6b 100644 --- a/forum/views/commands.py +++ b/forum/views/commands.py @@ -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} -- 2.45.1