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