def route_delete_comment(comment_id): if request.method == 'POST': comment = data_manager.get_record_by_id('comment', comment_id) data_manager.delete_by_id('comment', comment_id) if comment['question_id'] is not None: return redirect(f"/question/{comment['question_id']}") return redirect(f"/answer/{comment['answer_id']}") return render_template('warning.html', message='Action denied')
def route_answer_delete(answer_id): if 'id' not in session: return redirect(url_for('route_main')) answer = data_manager.get_row_from_table('answer', int(answer_id)) if os.path.exists(answer[0]['image'][1:]): os.remove(answer[0]['image'][1:]) data_manager.delete_by_id('answer', 'id', int(answer_id)) return redirect(f"/question/{answer[0]['question_id']}/question")
def route_comment_delete(comment_id): if 'id' not in session: return redirect(url_for('route_main')) comment = data_manager.get_comment('id', int(comment_id)) data_manager.delete_by_id('comment', 'id', int(comment_id)) if comment[0]['question_id'] is None: answer = data_manager.get_row_from_table('answer', int(comment[0]['answer_id'])) comment = answer return redirect(f"/question/{comment[0]['question_id']}/question")
def route_question_delete(question_id): if 'id' not in session: return redirect(url_for('route_main')) answers = data_manager.get_answers_by_question_id(int(question_id)) question = data_manager.get_row_from_table('question', int(question_id)) for answer in answers: if os.path.exists(answer['image'][1:]): os.remove(answer['image'][1:]) if os.path.exists(question[0]['image'][1:]): os.remove(question[0]['image'][1:]) data_manager.delete_by_id('question', 'id', int(question_id)) data_manager.tag_delete() return redirect("/")
def route_delete_answer(answer_id): answer = data_manager.get_record_by_id('answer', answer_id) question_id = answer['question_id'] data_manager.delete_by_id('answer', answer_id) return redirect(url_for('route_question_display', question_id=question_id))
def route_delete_question(question_id): data_manager.delete_by_id('question', question_id) return redirect('/')