]> git.openstreetmap.org Git - osqa.git/blobdiff - forum/views/writers.py
merge hernani > trunk
[osqa.git] / forum / views / writers.py
index 125318b765edee0a8c65bdbb57bb5bcc1f629dd7..a5c5d704f817f926f28d5328842ed72ad02494e9 100644 (file)
@@ -18,6 +18,7 @@ from forum.models import *
 from forum.forms import get_next_url
 from forum.utils import html
 
+from vars import PENDING_SUBMISSION_SESSION_ATTR
 
 def upload(request):#ajax upload file to a question or answer
     class FileTypeNotAllow(Exception):
@@ -84,7 +85,7 @@ def ask(request):
 
                     return HttpResponseRedirect(question.get_absolute_url())
                 else:
-                    request.session['pending_submission_data'] = {
+                    request.session[PENDING_SUBMISSION_SESSION_ATTR] = {
                         'POST': request.POST,
                         'data_name': _("question"),
                         'type': 'ask',
@@ -218,7 +219,7 @@ def answer(request, id):
     question = get_object_or_404(Question, id=id)
 
     if request.POST:
-        form = AnswerForm(question, request.POST)
+        form = AnswerForm(request.POST, request.user)
 
         if request.session.pop('reviewing_pending_data', False) or not form.is_valid():
             request.session['redirect_POST_data'] = request.POST
@@ -233,7 +234,7 @@ def answer(request, id):
 
             return HttpResponseRedirect(answer.get_absolute_url())
         else:
-            request.session['pending_submission_data'] = {
+            request.session[PENDING_SUBMISSION_SESSION_ATTR] = {
                 'POST': request.POST,
                 'data_name': _("answer"),
                 'type': 'answer',
@@ -253,7 +254,7 @@ def answer(request, id):
 
 
 def manage_pending_data(request, action, forward=None):
-    pending_data = request.session.pop('pending_submission_data', None)
+    pending_data = request.session.pop(PENDING_SUBMISSION_SESSION_ATTR, None)
 
     if not pending_data:
         raise Http404