]> git.openstreetmap.org Git - osqa.git/commitdiff
Fixed in http://jira.osqa.net/browse/OSQA-159
authorhernani <hernani@0cfe37f9-358a-4d5e-be75-b63607b5c754>
Fri, 7 May 2010 13:27:37 +0000 (13:27 +0000)
committerhernani <hernani@0cfe37f9-358a-4d5e-be75-b63607b5c754>
Fri, 7 May 2010 13:27:37 +0000 (13:27 +0000)
git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@161 0cfe37f9-358a-4d5e-be75-b63607b5c754

forum/views/auth.py
forum/views/writers.py

index 0d4e2f3e6813239edc18bf23d58be8d1ac1b83b6..3d8403f947bf0005324c074eae786ed09125f84b 100644 (file)
@@ -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)
index 1d7214f45b542abea769defff0fac07a7f963213..98b523e6f0eb85ca912b06a82a1a2d2220ada89d 100644 (file)
@@ -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())