def create_answer(answer_id): form = CommentForm() answer = Answer.query.get_or_404(answer_id) if request.method == 'POST' and form.validate_on_submit(): comment = Comment(user=g.user, content=form.content.data, create_date=datetime.now(), answer=answer) db.session.add(comment) db.session.commit() return redirect('{}#comment_{}'.format(url_for('question.detail', question_id=answer.question.id), comment.id)) return render_template('comment/comment_form.html', form=form)
def create_question(question_id): form = CommentForm() question = Question.query.get_or_404(question_id) if request.method == 'POST' and form.validate_on_submit(): comment = Comment(user=g.user, content=form.content.data, create_date=datetime.now(), question=question) db.session.add(comment) db.session.commit() return redirect(url_for('question.detail', question_id=question_id)) return render_template('comment/comment_form.html', form=form)
def create_answer(answer_id): form = CommentForm() answer = Answer.query.get_or_404(answer_id) if request.method == 'POST' and form.validate_on_submit(): comment = Comment(user=g.user, content=form.content.data, create_date=datetime.now(), answer=answer) db.session.add(comment) db.session.commit() return redirect(url_for('question.detail', question_id=answer.question.id)) # 메뉴 리스트 menu_list = Menu.query.order_by(Menu.sort_no.asc()) # 메뉴(선택) menu = Menu.query.get_or_404(answer.question.menu_id) return render_template('comment/comment_form.html', form=form, menu_list=menu_list, menu=menu)
def create_question(question_id): form = CommentForm() question = Question.query.get_or_404(question_id) if request.method == "POST" and form.validate_on_submit(): comment = Comment( user=g.user, content=form.content.data, create_date=datetime.now(), question=question, ) db.session.add(comment) db.session.commit() return redirect("{}#comment_{}".format( url_for("question.detail", question_id=question_id), comment.id)) return render_template("comment/comment_form.html", form=form)