def delete_comment_answer(cmnt_id):

    answ_id = request.form['answer_id']
    answer = logic.get_answer(answ_id)
    qstn_id = answer['question_id']
    logic.delete_comment(cmnt_id)

    return redirect(url_for('show_question', qstn_id=qstn_id))
def vote_answer(answ_id):

    vote = request.form['vote']
    answer = logic.get_answer(answ_id)
    qstn_id = answer['question_id']
    logic.vote_answer(answ_id, vote)
    logic.change_rep_answ(answ_id, vote)

    return redirect(url_for('show_question', qstn_id=qstn_id))
def modify_comment_to_answer(cmnt_id=None):

    comment = request.form
    answ_id = comment['answer_id']
    answer = logic.get_answer(answ_id)
    qstn_id = answer['question_id']
    if cmnt_id is None:
        logic.add_new_comment(comment)
    else:
        logic.modify_comment(cmnt_id, comment)

    return redirect(url_for('show_question', qstn_id=qstn_id))
def edit_answer_comment(answ_id):

    cmnt_id = request.form['id']
    answer = logic.get_answer(answ_id)
    comment = logic.get_comment(cmnt_id)
    if answer is None or comment is None:
        abort(404)
    mates = logic.get_users_ids()

    return render_template('cmnt_a_form.html',
                           form_type='edit',
                           comment=comment,
                           answer=answer,
                           mates=mates)
def post_comment_to_answer(answ_id):

    # Displays a page with a question and form to be filled with
    # the new comment

    answer = logic.get_answer(answ_id)
    if answer is None:
        abort(404)
    comment = logic.CMNT_DEFAULTS
    mates = logic.get_users_ids()

    return render_template('cmnt_a_form.html',
                           form_type='new',
                           comment=comment,
                           answer=answer,
                           mates=mates)
def edit_answer():

    # Receive form request with the answer id and send request to logic
    # to retrive answer data.
    # Display a page with the form filled with the answer existing data

    answ_id = int(request.form['id'])
    qstn_id = int(request.form['question_id'])
    answer = logic.get_answer(answ_id)
    question = logic.get_question(qstn_id)
    mates = logic.get_users_ids()

    return render_template('ans_form.html',
                           form_type="edit",
                           answer=answer,
                           question=question,
                           mates=mates)
Ejemplo n.º 7
0
def function_name(message):
    answer=logic.get_answer(message.text)
    bot.reply_to(message, answer)
Ejemplo n.º 8
0
def function_name(message):
    answer = logic.get_answer(message.text)
    bot.reply_to(message, answer)