def answer_comment(answer_id): if request.method == 'GET': comments = data_handler.get_all_comments_answer(answer_id) question_id = data_handler.get_question_id_by_answer_id(answer_id) return render_template("comment_answer.html", answer_id=answer_id, comments=comments, question_id=question_id) else: comment_answer = request.form["comment"] username = session['username'] data_handler.add_new_comment_answer(comment_answer, answer_id, username) comments = data_handler.get_all_comments_answer(answer_id) question_id = data_handler.get_question_id_by_answer_id(answer_id) return render_template("comment_answer.html", answer_id=answer_id, comments=comments, question_id=question_id)
def delete_answer_comment(comment_id): username = session['username'] answer_id = data_handler.get_answer_id_by_comment_id(comment_id) question_id = data_handler.get_question_id_by_answer_id(answer_id) check_for_validation = data_handler.check_user_id_authentication_for_comment(username, comment_id) if check_for_validation: data_handler.delete_comment_by_comment_id(comment_id) return redirect(url_for('list_answers', id=question_id))
def answer_downvote(id=None): data_handler.downvote_answers_SQL(id) realdictrow = data_handler.get_question_id_by_answer_id(id) list_for_realdictrow = [] for i in realdictrow: list_for_realdictrow.append(i) question_id = list_for_realdictrow[0]['question_id'] username = list_for_realdictrow[0]['owner'] data_handler.answer_downvote_reputation(username) return redirect(url_for('questions_site', id=question_id))
def edit_answer_comment(comment_id): username = session['username'] answer_id = data_handler.get_answer_id_by_comment_id(comment_id) question_id = data_handler.get_question_id_by_answer_id(answer_id) check_for_validation = data_handler.check_user_id_authentication_for_comment(username, comment_id) if check_for_validation: if request.method == 'POST': comment = {'id': comment_id, 'submission_time': request.form.get('submission_time'), 'question_id': request.form.get('question_id'), 'answer_id': request.form.get('answer_id'), 'message': request.form.get('message'), 'edited_count': request.form.get('edited_count'), } data_handler.update_comment(comment) time = data_handler.date_time() return redirect(url_for('list_answers', id=question_id, time=time, username=username)) comment = data_handler.get_answer_comment_by_comment_id(comment_id) return render_template('add-answer-comment.html', edit_comment=comment, comment=None, button_title="Edit Comment", username=username) else: return redirect(url_for('list_answers', id=question_id))
def delete_answer_comment(answer_id, comment_id): data_handler.delete_line(comment_id) comments = data_handler.get_all_comments_answer(answer_id) question_id = data_handler.get_question_id_by_answer_id(answer_id) return render_template('comment_answer.html', answer_id=answer_id, question_id=question_id, comments=comments)
def deny_answer(answer_id): username = session['username'] question_id = data_handler.get_question_id_by_answer_id(answer_id) user = data_handler.get_user_id_by_username(username) data_handler.deny_answer(answer_id) return redirect(url_for('list_answers', id=question_id, user=user, username=username))