Ejemplo n.º 1
0
def create_question(request, story):
    f = QuestionCreateForm(request.POST)
    if f.is_valid():
        o = f.save(commit=False)
        o.story = story
        o.user = request.user
        o.save()
        return JSONResponse({'result': render_to_string('lqa/_question.html', {'question': o})})
    else:
        return JSONResponse({'form': as_crispy_form(f)})
Ejemplo n.º 2
0
def edit_question(request, story, question_id):
    q = Question.objects.get(id=question_id)
    f = QuestionCreateForm(request.POST, instance=q)
    if f.is_valid():
        o = f.save(commit=False)
        o.story = story
        o.user = request.user
        o.save()
        return JSONResponse({'result': render_to_string('lqa/_question.html', {'question': o})})
    else:
        return JSONResponse({'form': as_crispy_form(f)})
Ejemplo n.º 3
0
def create_question(request, story):
    f = QuestionCreateForm(request.POST)
    if f.is_valid():
        o = f.save(commit=False)
        o.story = story
        o.user = request.user
        o.save()
        return JSONResponse({
            'result':
            render_to_string('lqa/_question.html', {'question': o})
        })
    else:
        return JSONResponse({'form': as_crispy_form(f)})
Ejemplo n.º 4
0
def edit_question(request, story, question_id):
    q = Question.objects.get(id=question_id)
    f = QuestionCreateForm(request.POST, instance=q)
    if f.is_valid():
        o = f.save(commit=False)
        o.story = story
        o.user = request.user
        o.save()
        return JSONResponse({
            'result':
            render_to_string('lqa/_question.html', {'question': o})
        })
    else:
        return JSONResponse({'form': as_crispy_form(f)})