From 8eed5a6d3da1221e41b05c423c15fdc227c283ae Mon Sep 17 00:00:00 2001 From: hernani Date: Fri, 7 May 2010 13:27:37 +0000 Subject: [PATCH] Fixed in http://jira.osqa.net/browse/OSQA-159 git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@161 0cfe37f9-358a-4d5e-be75-b63607b5c754 --- forum/views/auth.py | 11 +++++++++++ forum/views/writers.py | 9 +++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/forum/views/auth.py b/forum/views/auth.py index 0d4e2f3..3d8403f 100644 --- a/forum/views/auth.py +++ b/forum/views/auth.py @@ -339,6 +339,17 @@ def login_and_forward(request, user, forward=None, message=None): login(request, user) #user_logged_in.send(user=user,old_session=old_session,sender=None) + temp_data = request.session.pop('temp_node_data', None) + if temp_data: + request.POST = temp_data + node_type = request.session.pop('temp_node_type') + + if node_type == "question": + from forum.views.writers import ask + return ask(request) + elif node_type == "answer": + from forum.views.writers import answer + return answer(request, request.session.pop('temp_question_id')) if not forward: signin_action = request.session.get('on_signin_action', None) diff --git a/forum/views/writers.py b/forum/views/writers.py index 1d7214f..98b523e 100644 --- a/forum/views/writers.py +++ b/forum/views/writers.py @@ -68,7 +68,7 @@ def upload(request):#ajax upload file to a question or answer def ask(request): - if request.method == "POST" and "text" in request.POST: + if request.POST and "text" in request.POST: form = AskForm(request.POST) if form.is_valid(): if request.user.is_authenticated(): @@ -86,6 +86,8 @@ def ask(request): question = AskAction(user=request.user).save(data=form.cleaned_data).node return HttpResponseRedirect(question.get_absolute_url()) else: + request.session['temp_node_data'] = request.POST + request.session['temp_node_type'] = 'question' return HttpResponseRedirect(reverse('auth_action_signin', kwargs={'action': 'newquestion'})) elif request.method == "POST" and "go" in request.POST: form = AskForm({'title': request.POST['q']}) @@ -195,7 +197,7 @@ def edit_answer(request, id): def answer(request, id): question = get_object_or_404(Question, id=id) - if request.method == "POST": + if request.POST: form = AnswerForm(question, request.POST) if form.is_valid(): if request.user.is_authenticated(): @@ -213,6 +215,9 @@ def answer(request, id): answer = AnswerAction(user=request.user).save(dict(question=question, **form.cleaned_data)).node return HttpResponseRedirect(answer.get_absolute_url()) else: + request.session['temp_node_data'] = request.POST + request.session['temp_node_type'] = 'answer' + request.session['temp_question_id'] = id return HttpResponseRedirect(reverse('auth_action_signin', kwargs={'action': 'newquestion'})) return HttpResponseRedirect(question.get_absolute_url()) -- 2.39.5