Ejemplo n.º 1
0
def question_new(request):
    params = _common_params(request)
    initial = _common_initial(request)
    params['next_url'] = initial['next_url']

    if request.method == 'POST':
        form = PostQuestionForm(request.user, request.POST)
        if request.user.is_authenticated():
            if form.is_valid():
                form.save()
                return redirect(form.cleaned_data.get('next_url'))
            else:
                params['next_url'] = request.POST.get('next_url')
    else:
        form = PostQuestionForm(request.user, initial=initial)

    params['form'] = form

    return render_to_response('main/pages/question_edit.html', params, context_instance=RequestContext(request))
Ejemplo n.º 2
0
def question_new(request):
    params = _common_params(request)
    params["cancel_url"] = reverse(question_list)

    if request.method == "POST":
        form = PostQuestionForm(request.user, request.POST)
        if request.user.is_authenticated():
            if form.is_valid():
                new_question = form.save()
                if new_question.is_published:
                    return redirect(question_list)
                else:
                    return redirect(new_question)
    else:
        form = PostQuestionForm(request.user)

    params["form"] = form

    return render_to_response("oneliners/pages/question_edit.html", params, context_instance=RequestContext(request))
Ejemplo n.º 3
0
def question_new(request):
    params = _common_params(request)
    params['cancel_url'] = reverse(question_list)

    if request.method == 'POST':
        form = PostQuestionForm(request.user, request.POST)
        if request.user.is_authenticated():
            if form.is_valid():
                new_question = form.save()
                if new_question.is_published:
                    return redirect(question_list)
                else:
                    return redirect(new_question)
    else:
        form = PostQuestionForm(request.user)

    params['form'] = form

    return render_to_response('oneliners/pages/question_edit.html', params, context_instance=RequestContext(request))