def index(): if request.method == 'POST': data_manager.create_comment(request.form.get('name'), request.form.get('text')) comments = data_manager.get_comments() return render_template('index.html', comments=comments)
def show_question(question_id, is_new_answer=False, is_new_comment=False, answer_to_edit=False, answer_to_comment=False, show_modal=False, comment_to_edit=None): question = data_manager.get_question_by_id(question_id) answers_for_question = data_manager.get_answers_for_question(question_id) comments_for_question = data_manager.get_comments(question_id) comments_for_answers = data_manager.get_comments_for_answers(question_id) tags_for_question = data_manager.get_tags_for_question(question_id) tags_wo_question = data_manager.get_tags_wo_question(question_id) return render_template('maintain-question.html', question=question, answers_for_question=answers_for_question, is_new_answer=is_new_answer, comments_for_question=comments_for_question, comments_for_answers=comments_for_answers, is_new_comment=is_new_comment, answer_to_edit=answer_to_edit, answer_to_comment=answer_to_comment, comment_to_edit=comment_to_edit, tags_for_question=tags_for_question, tags_wo_question=tags_wo_question, show_modal=show_modal)
def delete_comment(comment_id): comments = data_manager.get_comments() if data_manager.validation(comments, comment_id): if request.method == "POST": data_manager.delete_comments(comment_id) return redirect(url_for('route_main')) return redirect(url_for('route_main'))
def answer_page(question_id, answer_id): answers = data_manager.get_answer_by_id(question_id) all_comment = data_manager.get_comments(answer_id) comments = [] for comment in all_comment: if comment['answer_id'] == answer_id: comments.append(comment) return render_template("answer.html", question_id=question_id, answer_id=answer_id, answers=answers, comments=comments)
def route_question(question_id): data_manager.update_question_view_number(question_id) question = data_manager.get_question_by_id(question_id) answers = data_manager.get_answers_by_question_id(question_id) comments = data_manager.get_comments() return render_template('question.html', question=question, answers=answers, comments=comments)
def display_question(question_id): questions = data_manager.get_question_by_id(question_id) answers = data_manager.get_answer_by_id(question_id) comments = data_manager.get_comments(question_id) tag = data_manager.get_tagz(question_id) user_id = session.get('id', None) question_user_id = [question['user_id'] for question in questions] return render_template("display_question.html", questions=questions, answers=answers, question_id=question_id, comments=comments, tag=tag, user_id=user_id, question_user_id=question_user_id)
def show_question_details(question_id): question = data_manager.get_question_details(question_id) comments = data_manager.get_comments() answers = data_manager.get_answers_for_question(question_id) data_manager.update_view_number(question_id) return render_template('question.html', question=question, comments=comments, answers=answers)
def route_question_id(question_id): stored_questions = data_manager.get_questions() stored_answers = data_manager.get_answers() stored_comments = data_manager.get_comments() return render_template('questiondetails.html', questions=stored_questions, answers=stored_answers, id=question_id, comments=stored_comments)
def route_question(id): if request.method == "GET": questions = data_manager.get_question_details(id) answers = data_manager.get_answer_details(id) comments = data_manager.get_comments(id) # tags = data_manager.get_question_tags(id) # all_tags = data_manager.get_all_tags() return render_template("question.html", question=questions, answers=answers, comments=comments)
def question_page(question_id): question_details = data_manager.get_display_question(question_id) answers = data_manager.get_display_answers('question_id', question_id) comments = data_manager.get_comments(question_id) tags = data_manager.get_tags_of_question() user_of_question = data_manager.get_user_name_by_question_id( question_id)['user_name'] return render_template("question.html", question_id=question_id, question=question_details, answers=answers, comments=comments, user_of_question=user_of_question, tags=tags)
def display_question(question_id): if request.method == 'GET': data_manager.view_up_answer(question_id) question_comments = data_manager.get_question_comment(question_id) questions = data_manager.find_question(question_id) answers = data_manager.find_question_answer(question_id) comments = data_manager.get_comments() question_tags = data_manager.get_question_tags(question_id) return render_template('question.html', questions=questions, answers=answers, question_comments=question_comments, comments=comments, question_id=question_id, question_tags=question_tags)
def edit_comment(comment_id): comments = data_manager.get_comments() question_id = data_manager.get_question_id_for_comment(comment_id) if request.method == "POST": edit_counter = '' for comment in comments: if comment['id'] == comment_id: edit_counter = comment['edited_count'] if edit_counter is None: new_message = request.form['comment'] data_manager.get_update_for_comment(comment_id, new_message) return redirect('/') elif edit_counter is not None: new_message = request.form['comment'] data_manager.get_new_update_for_comment(comment_id, new_message) return redirect('/') return render_template('edit_comment.html', comment_id=comment_id, comments=comments)
def display_question(question_id): question = questions_data.get_question(question_id) answers = answers_data.get_answers(question_id) comments = data_manager.get_comments(question_id) tags_name = [] tags = data_manager.get_tags(question_id) for tag in tags: tags_name.append(data_manager.get_tags_name(tag["tag_id"])) image_names = os.listdir(app.config['UPLOAD_FOLDER']) question_image_name = data_manager.return_question_image_name( image_names, question_id) return render_template("display_question.html", headers=QUESTIONS_HEADERS, question=question, answers_headers=ANSWERS_HEADERS, answers=answers, headers_print=HEADERS_PRINT, comments=comments, tags_name=tags_name, question_image_name=question_image_name)
def route_question(question_id): if 'username' in session: logedin = True else: logedin = False question_id = int(question_id) question = data_manager.read_a_question(int(question_id)) answers_list = data_manager.answer_by_question_id(int(question_id)) comments = data_manager.get_comments() tags = data_manager.get_tags_for_question(question_id) try: accepted_answer_id = data_manager.acceptance_check(question_id) except TypeError: accepted_answer_id = -1 return render_template("question.html", logedin=logedin, comments=comments, question=question, question_id=question_id, answers_list=answers_list, tags=tags, accepted_answer_id=accepted_answer_id)