def add_comment_to_answer(question_id, answer_id): if request.method == "POST": message = request.form["message"] user_id = session['id'] data_manager.add_comment_to_answer(message, question_id, answer_id, user_id) return redirect("/list/question/" + question_id) return render_template("add_comment_to_answer.html", question_id=question_id, answer_id=answer_id)
def add_comment_to_answer(answer_id): if request.method == 'POST': submission_time = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") message = request.form['message'] data_manager.add_comment_to_answer(submission_time, answer_id, message) question_id = data_manager.get_question_by_answer(answer_id) return redirect('/question/' + question_id) return render_template('comment_answer.html', answer_id=answer_id)
def add_comment_to_answer(answer_id): if request.method == 'GET': return render_template('add-comment-answer.html', answer_id=answer_id) data_manager.add_comment_to_answer(request.form, answer_id) question_id = data_manager.get_question_id_from_answer(answer_id) return redirect(f'/question/{question_id}')
def route_answer_comment(answer_id): if 'id' not in session: return redirect(url_for('route_main')) if request.method == "POST": answer = data_manager.get_row_from_table('answer', int(answer_id)) file = request.form['message'] data_manager.add_comment_to_answer(file, int(answer_id), session['id']) return redirect(f"/question/{answer[0]['question_id']}/question") answer = data_manager.get_row_from_table('answer', int(answer_id)) return render_template("answer_comment.html", answer=answer, answer_id=answer_id)
def add_comment_to_answer(answer_id): answer_headers = ['message', 'submission_time', 'vote_number', 'image'] answer = data_manager.get_table_by_id(answer_id, "answer") if request.method == 'POST': new_comment = request.form.to_dict() data_manager.add_comment_to_answer(new_comment) return redirect('/question/' + str(request.form.get('question_id'))) return render_template('post_comment_to_answer.html', answer=answer, answer_headers=answer_headers)
def comment_answer(answer_id): columns = ['id', 'question_id'] question = data_manager.get_data_by_id(columns, 'answer', answer_id, 'id') if request.method == 'GET': return render_template("answer_comment.html", answer_id=answer_id) if request.method == 'POST': comment = request.form.get('comment_answer') user_id = session['user_id'] data_manager.add_comment_to_answer(comment, answer_id, 'comment', user_id) return redirect('/question/' + str(question[0]['question_id']))
def add_comment_to_answer(answer_id): if request.method == 'POST': user_id = data_manager.get_user_id_by_username(session['username']) comment_message = request.form['message'] data_manager.add_comment_to_answer(answer_id, comment_message, user_id) question_id = data_manager.get_question_id_by_answer_id(answer_id) return redirect(url_for('route_question', question_id=question_id)) question = data_manager.get_question_by_answer_id(answer_id) answer = data_manager.get_answer_by_answer_id(answer_id) return render_template('add-comment-to-answer.html', question=question, answer=answer)
def add_answer_comment(answer_id: int, question_id: int): if request.method == 'POST': user_comment = request.form.get('comment') now_time = datetime.now() try: user_id = data_manager.get_user_id(session['username']) except: user_id = '' data_manager.add_comment_to_answer(answer_id, user_comment, now_time, user_id) return redirect(f'/question/{question_id}') return render_template('add_comment_answer.html', answer_id=answer_id, question_id=question_id)
def add_a_comment_to_answer(answer_id): question_id = request.args.get('question_id') if request.method == 'POST': message_data = request.form.to_dict() message = message_data['message'] answer_id = request.form.get('answer_id') user_name = session['username'] user_id = data_manager.get_user_id(user_name) data_manager.add_comment_to_answer(answer_id, message, user_id['user_id']) return redirect(url_for('display_question', question_id=question_id)) return render_template('add_a_comment_to_answer.html', answer_id=answer_id, question_id=question_id)
def add_comment(question_id, answer_id): question_id = int(question_id) answer_id = int(answer_id) if request.method == 'POST': if answer_id == -1: edited_count = 0 message = request.form['comment'] data_manager.add_comment_to_qustion(message=message, question_id=question_id, edited_count=edited_count) return redirect(url_for('route_question', question_id=question_id)) else: edited_count = 0 message = request.form['comment'] data_manager.add_comment_to_answer(message=message, answer_id=answer_id, edited_count=edited_count) return redirect(url_for('route_question', question_id=question_id)) return render_template('add_comment.html', question_id=question_id, answer_id=answer_id)