Exemple #1
0
def answer_edit(question_id, answer_id):
    if request.method == 'GET':
        answer = data_handler.get_answer_by_id(answer_id)
        return render_template("answer_edit.html", answer=answer)

    message = request.form['message']
    data_handler.update_answer(answer_id, message)
    return redirect(url_for('question_details', question_id=question_id))
Exemple #2
0
def update_answer(id):
    if request.method == "POST":
        message = request.form.get('message')
        image = request.form.get('image')
        question_id = request.form.get('question_id')
        data_handler.update_answer(id, message, image)
        return redirect(url_for('display_question', id=question_id))

    answer = data_handler.get_all_answer_by_id(id)
    # for line in answer_container:
    #     if line["id"]==int(id):
    #         answer=line
    return render_template('update.html', id=id, answer=answer)
Exemple #3
0
def edit_answer(answer_id):
    answer = data_handler.get_selected_answer(answer_id)

    if request.method == 'POST':
        edited_answer = {
            'id': answer_id,
            'submission_time': util.get_current_time(),
            'message': request.form['edit_answer'],
            'image': None
        }
        data_handler.update_answer(edited_answer)
        return redirect(url_for('question', question_id=answer['question_id']))

    return render_template('answer.html', answer=answer)
def edit_answer(answer_id):
    answer = data_handler.get_answer_by_id(answer_id)
    if request.method == 'POST':
        edited_answer = {}
        datas_from_answer = ['id', 'submission_time', 'vote_number', 'question_id', 'image']
        for data in datas_from_answer:
            edited_answer[data] = answer[data]
        datas_from_edit = ['message']
        for data in datas_from_edit:
            edited_answer[data] = request.form[data]

        data_handler.update_answer(edited_answer)
        return redirect(url_for('route_question', question_id=edited_answer['question_id']))

    return render_template('edit_answer.html', answer=answer)
Exemple #5
0
def edit_answer(answer_id):
    answer_data = data_handler.get_single_answer(answer_id)
    question_id = answer_data['question_id']
    question_data = data_handler.get_single_question(question_id)

    if request.method == 'POST':
        message = request.form['answer']
        data_handler.update_answer(answer_id, message)
        return redirect(f'/question/{question_id}')
    return render_template('new-answer.html',
                           answer_data=answer_data,
                           question_data=question_data,
                           question_id=question_id,
                           todo='Edit',
                           action_text=f'/answer/{answer_id}/edit')