예제 #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))
예제 #7
0
def debates_questions():
    active_q = cdw.questions.with_fields(active=True).first()
    questions = cdw.questions.with_fields(archived__ne=True,
                                          active__ne=True).order_by('-created')
    form = QuestionForm(csrf_enabled=False)
    
    return render_template('admin/debates/questions.html',
                           categories=cdw.categories.all(), 
                           active_question=active_q,
                           questions=questions,
                           form=form,
                           section_selector='debates', 
                           page_selector='questions')
예제 #8
0
def show_question(question_id):
    ctx = do_show_question(cdw.questions.with_id(question_id))
    question = ctx.get('question')
    form = QuestionForm(csrf_enabled=False)
    form.category.data = str(question.category.id)
    form.text.data = question.text
    
    thread_form = ThreadCrudForm(question_id,csrf_enabled=False) 
    
    return render_template("/admin/debates/show_question.html", 
                           section_selector="debates",
                           page_selector="questions-show",
                           form=form,
                           thread_form=thread_form,
                           **ctx)