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)
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():
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']})
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():
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())