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):
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',
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
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',
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