Ejemplo n.º 1
0
def delete_answer(answer_id):
    answers = data_manager.get_answers()
    if data_manager.validation(answers, answer_id):
        if request.method == "POST":
            data_manager.delete_answer(answer_id)
            return redirect(url_for('route_list'))
    return redirect(url_for('route_main'))
Ejemplo n.º 2
0
def delete_question(question_id):
    questions = data_manager.get_questions()
    if data_manager.validation(questions, question_id):
        if request.method == "POST":
            data_manager.delete_question(question_id)
            return redirect(url_for('route_list'))
    else:
        return redirect(url_for('route_main'))
Ejemplo n.º 3
0
def delete_comment(comment_id):
    comments = data_manager.get_comments()
    if data_manager.validation(comments, comment_id):
        if request.method == "POST":
            data_manager.delete_comments(comment_id)
            return redirect(url_for('route_main'))

    return redirect(url_for('route_main'))
Ejemplo n.º 4
0
def edit_answer(answer_id):
    answers = data_manager.get_answers()
    question_id = data_manager.get_question_id(answer_id)
    if data_manager.validation(answers, answer_id):
        if request.method == "POST":
            new_message = request.form['answer']
            data_manager.get_update(answer_id, new_message)
            return redirect(f'/question/{question_id}')
        return render_template('edit_answer.html',
                               answer_id=answer_id,
                               answers=answers)
    return redirect(url_for('route_main'))
Ejemplo n.º 5
0
def edit_question(question_id):
    questions = data_manager.get_questions()
    if data_manager.validation(questions, question_id):
        if request.method == "POST":
            new_message = request.form['message']
            new_title = request.form['title']
            data_manager.get_update_question(question_id, new_message,
                                             new_title)
            return redirect(f'/question/{question_id}')

        return render_template('edit_question.html',
                               questions=questions,
                               question_id=question_id)

    return redirect(url_for('route_main'))
Ejemplo n.º 6
0
def edit_comment(comment_id):
    comments = data_manager.get_comments()
    if data_manager.validation(comments, comment_id):
        if request.method == "POST":
            edit_counter = ''
            for comment in comments:
                if comment['id'] == comment_id:
                    edit_counter = comment['edited_count']
            if edit_counter is None:
                new_message = request.form['comment']
                data_manager.get_update_for_comment(comment_id, new_message)
                return redirect(url_for('route_main'))
            elif edit_counter is not None:
                new_message = request.form['comment']
                data_manager.get_new_update_for_comment(
                    comment_id, new_message)
                return redirect(url_for('route_main'))
        return render_template('edit_comment.html',
                               comment_id=comment_id,
                               comments=comments)
    return redirect(url_for('route_main'))