def delete_only_comment(question_id, comment_id, answer_id): if request.path == f'/question/{question_id}/delete_this/{comment_id}/{answer_id}': user = session['username'] data_handler.delete_comment(comment_id, user) return redirect( url_for('show_answer_comments', question_id=question_id, answer_id=answer_id)) if request.path == f'/question/{question_id}/edit_this/{comment_id}/{answer_id}': if request.method == 'POST': user = session['username'] new_comment = request.form['message'] new_sub_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S') data_handler.update_comment(new_comment, new_sub_time, comment_id, user) return redirect( url_for('show_answer_comments', question_id=question_id, answer_id=answer_id)) question = data_handler.get_question_SQL(question_id) answer = data_handler.get_answer_for_question_SQL_with_ans_id(answer_id) comment = data_handler.get_comment_for_edit(comment_id) return render_template('edit-comment.html', comment=comment, question=question, answer=answer)
def show_answer_comments(question_id=None, answer_id=None): question = data_handler.get_question_SQL(question_id) answer = data_handler.get_answer_for_question_SQL_with_ans_id(answer_id) comment = data_handler.get_comment_for_A(answer_id) return render_template('quest_ans_comment.html', question=question, answer=answer, comments=comment)
def ques_downvote(id=None): data_handler.downvote_questions_SQL(id) question_row = data_handler.get_question_SQL(id) data = [] for i in question_row: data.append(i) username = data[0]['owner'] data_handler.question_downvote_reputation(username) return redirect(url_for('route_list'))
def add_comment_to_answer(question_id=None, answer_id=None): question = data_handler.get_question_SQL(question_id) answer = data_handler.get_answer_for_question_SQL_with_ans_id(answer_id) if request.method == 'POST': user = session['username'] comment = request.form['message'] time = datetime.now().strftime('%Y-%m-%d %H:%M:%S') data_handler.add_comment_to_A(answer_id, comment, time, user) return redirect(url_for('questions_site', id=question_id)) return render_template('new-comment-for-answer.html', quest=question_id, ans_id=answer_id)
def accept_answer(id=None): user = session['username'] question = data_handler.get_question_by_answer_mark_edition(id) owner = [] user_infos = [] for i in question: user_infos.append(i) the_whole_question = data_handler.get_question_SQL( user_infos[0]['question_id']) for i in the_whole_question: owner.append(i) if user == owner[0]['owner']: question_id = int(user_infos[0]['question_id']) answer_row = data_handler.get_answer_by_answer_id(id) print(answer_row) row = [] for i in answer_row: row.append(i) answer_owner = row[0]['owner'] data_handler.answer_accept_reputation(answer_owner) data_handler.accepted_answer(id, question_id) question = data_handler.get_question_SQL(question_id) answer = data_handler.get_answer_for_question_SQL(question_id) comment_for_Q = data_handler.get_comment_for_Q(question_id) tag = data_handler.question_tag() choose_the_one = data_handler.get_all_tag() comment_for_A = data_handler.get_comment_for_A(question_id) return render_template('/questions.html', question=question, id=question_id, tag=tag, match=choose_the_one, answer=answer, comment_Q=comment_for_Q, comment_A=comment_for_A) return redirect('/')
def questions_site(id=None): question = data_handler.get_question_SQL(id) answer = data_handler.get_answer_for_question_SQL(id) comment_for_Q = data_handler.get_comment_for_Q(id) tag = data_handler.question_tag() choose_the_one = data_handler.get_all_tag() comment_for_A = data_handler.get_comment_for_A(id) #SZAR return render_template('/questions.html', question=question, id=id, tag=tag, match=choose_the_one, answer=answer, comment_Q=comment_for_Q, comment_A=comment_for_A)