예제 #1
0
 def questions_index_post():
     form = QuestionForm(request.form, csrf_enabled=False)
     form.category.choices = [(str(c.id), c.name) for c in cdw.categories.all()]
     if form.validate():
         return jsonify(cdw.questions.save(form.to_question()))
     else:
         return jsonify({"errors":form.errors}, 400)
예제 #2
0
 def questions_index_post():
     form = QuestionForm(request.form, csrf_enabled=False)
     form.category.choices = [(str(c.id), c.name)
                              for c in cdw.categories.all()]
     if form.validate():
         return jsonify(cdw.questions.save(form.to_question()))
     else:
         return jsonify({"errors": form.errors}, 400)
예제 #3
0
def question_create():
    form = QuestionForm(csrf_enabled=False)
    form.category.choices = [(str(c.id), c.name) for c in cdw.categories.all()]

    if form.validate():
        flash("Question created successfully", "info")
        cdw.questions.save(form.to_question())

    return redirect('/admin/debates/questions')
예제 #4
0
def question_create():
    form = QuestionForm(csrf_enabled=False)
    form.category.choices = [(str(c.id), c.name) for c in cdw.categories.all()]
    
    if form.validate():
        flash("Question created successfully", "info")
        cdw.questions.save(form.to_question())
    
    return redirect('/admin/debates/questions')
예제 #5
0
def question_update(question_id):
    question = cdw.questions.with_id(question_id)
    form = QuestionForm(csrf_enabled=False)

    if form.validate():
        question.category = cdw.categories.with_id(form.category.data)
        question.text = form.text.data
        question.save()
        flash('Question updated', 'info')

    return redirect('/admin/debates/questions/%s' % str(question.id))
예제 #6
0
def question_update(question_id):
    question = cdw.questions.with_id(question_id)
    form = QuestionForm(csrf_enabled=False)
    
    if form.validate():
        question.category = cdw.categories.with_id(form.category.data)
        question.text = form.text.data
        question.save()
        flash('Question updated', 'info')
    
    return redirect('/admin/debates/questions/%s' % str(question.id))