def question_comments(question_id): if data_manager.check_answer_id(question_id) is True: abort(404) comments = data_manager.get_question_comments(question_id) if request.method == "GET": try: return render_template('question-comments.html', comments=comments) except (IndexError, UndefinedError): abort(404)
def display_answers(question_id): answer_headers = data_manager.ANSWER_HEADER answer_details = data_manager.fetch_answers(question_id) question_details = data_manager.fetch_dictionary(question_id) data_manager.update_view_number(question_id) comments = data_manager.get_question_comments() return render_template('display_data/list_answers.html', answer_details=answer_details, question_details=question_details, answer_headers=answer_headers, comments=comments)
def question_page(question_id): try: question = data_manager.get_question_by_question_id(question_id) answers = data_manager.get_all_answers_by_question_id(question_id) tags = data_manager.get_tags(question_id) question_comments = data_manager.get_question_comments(question_id) data_manager.question_view_number(question_id) return render_template("question.html", question=question, answers=answers, question_comments=question_comments, tags=tags) except (IndexError, UndefinedError): abort(404)
def question_route(id): if request.method == "GET": answer_user_data=data_manager.find_username_for_answer(id) question_user_data=data_manager.find_username_by_question_id(id) quest_comm_user_data = data_manager.find_userdata_for_questions_comments(id) question = data_manager.get_question(id) answers = data_manager.get_all_answers(id) question_comments = data_manager.get_question_comments(id) return render_template("question-page.html", to_display=question,q_user_data=question_user_data, a_user_data=answer_user_data, answers_to_display=answers, question_id=id, comments=question_comments, quest_comm_user_data=quest_comm_user_data)
def display_data(): if request.args: sorting_key = request.args['sort_by'] reverse_bool = request.args['order_descending'] questions = data_manager.get_sorted_questions(sorting_key, reverse_bool) else: questions = data_manager.get_all_questions() tags = data_manager.get_question_tags() comments = data_manager.get_question_comments() question_headers = data_manager.QUESTION_HEADERS return render_template('display_data/list.html', questions=questions, question_headers=question_headers, tags=tags, comments=comments)
def route_question(question_id): if 'user_name' in session: if request.method == 'GET': question = data_manager.get_data('question', question_id) answers = data_manager.get_data('answer', question_id=question_id) question_comments = data_manager.get_question_comments(question_id) answer_comments = data_manager.get_answer_comments(question_id) return render_template("question-only.html", question_id=int(question_id), question=question, answers=answers, question_comments=question_comments, answer_comments=answer_comments) elif request.method == 'POST': data_manager.delete_question(question_id) return redirect('/list') else: return redirect('/')
def q_id(question_id): question = data_manager.get_question_by_id(question_id) if request.method == 'GET': message = question['message'] title = question['title'] question_id = question['id'] answers = data_manager.get_answer_by_question_id(question_id) if answers: answer_id = answers[0]['id'] else: answer_id = 0 print(answer_id) comments_questions = data_manager.get_question_comments(question_id) comments_answers = data_manager.get_answer_comments() print(comments_answers) return render_template("question_id.html", message=message, title=title, answers=answers, question_id=question_id, comments_questions=comments_questions, comments_answers=comments_answers, answer_id=answer_id) elif request.method == 'POST': if request.form["btn"] == "Send answer": answer = OrderedDict() answer['submission_time'] = datetime.now() answer['vote_number'] = 0 answer['question_id'] = question_id answer['message'] = request.form.get('comment') answer['image'] = None data_manager.add_answer(answer) return redirect(url_for('get_question_list')) elif request.form['btn'] == "Delete question": data_manager.delete_question(question_id) data_manager.delete_answer(question_id) return redirect(url_for('get_question_list')) elif request.form['btn'] == "Edit question": return redirect(url_for('edit', question_id=question_id))
def question_route(question_id): existing_ids = data_manager.get_question_ids() if question_id not in existing_ids: return redirect('/') post = data_manager.get_question_by_id(question_id) post_data = 0 answers_dict = data_manager.get_all_sorted_answers(question_id) id_tuple = data_manager.get_answers_ids(question_id) question_comments_dict = data_manager.get_question_comments(question_id) try: answer_comments_dict = data_manager.get_answer_coments(id_tuple) except ProgrammingError: id_tuple = (-1, ) answer_comments_dict = data_manager.get_answer_coments(id_tuple) return render_template('question_page.html', post=post[post_data], answers=answers_dict, question_id=question_id, question_comments=question_comments_dict, answer_comments=answer_comments_dict)
def get_comments(question_id): return data_manager.get_question_comments(question_id)
def show_comments_on_question(question_id): comments = dm.get_question_comments(question_id) return render_template("question_comments.html", question_id=question_id, comments=comments)