Exemplo n.º 1
0
def modify_answer(comment_id):
    comment = Comment.query.get_or_404(comment_id)
    if g.user != comment.user:
        flash('수정권한이 없습니다.')
        return redirect(url_for('question.detail', question_id=comment.answer.id))
    if request.method == 'POST':
        form = CommentForm()
        if form.validate_on_submit():
            form.populate_obj(comment)
            comment.modify_date = datetime.now()
            db.session.commit()
            return redirect('{}#comment_{}'.format(url_for('question.detail', question_id=comment.answer.question.id), comment.id))
    else:
        form = CommentForm(obj=comment)
    return render_template('comment/comment_form.html', form=form)
Exemplo n.º 2
0
def modify_question(comment_id):
    comment = Comment.query.get_or_404(comment_id)
    if g.user != comment.user:
        flash("수정 권한이 없습니다.")
        return redirect(
            url_for("question.detail", question_id=comment.question.id))
    if request.method == "POST":
        form = CommentForm()
        if form.validate_on_submit():
            form.populate_obj(comment)
            comment.modify_date = datetime.now()  # 수정일시 저장
            db.session.commit()
            return redirect(
                url_for("question.detail", question_id=comment.question.id))
    else:
        form = CommentForm(obj=comment)
    return render_template("comment/comment_form.html", form=form)
Exemplo n.º 3
0
def modify_answer(comment_id):
    comment = Comment.query.get_or_404(comment_id)
    if g.user != comment.user:
        flash('수정권한이 없습니다')
        return redirect(url_for('question.detail', question_id=comment.answer.id))
    if request.method == 'POST':
        form = CommentForm()
        if form.validate_on_submit():
            form.populate_obj(comment)
            comment.modify_date = datetime.now()  # 수정일시 저장
            db.session.commit()
            return redirect(url_for('question.detail', question_id=comment.answer.question.id))
    else:
        form = CommentForm(obj=comment)
    # 메뉴 리스트
    menu_list = Menu.query.order_by(Menu.sort_no.asc())
    # 메뉴(선택)
    menu = Menu.query.get_or_404(comment.answer.question.menu_id)
    return render_template('comment/comment_form.html', form=form, menu_list=menu_list, menu=menu)
Exemplo n.º 4
0
def modify_question(comment_id, x):
    if x == 0:
        comment_0 = Comment
        xx = 'question.detail'
    elif x == 1:
        comment_0 = Comment1
        xx = 'question.detail1'
    comment = comment_0.query.get_or_404(comment_id)
    if g.user != comment.user:
        flash('수정권한이 없습니다')
        return redirect(url_for(xx, question_id=comment.question.id))
    if request.method == 'POST':
        form = CommentForm()
        if form.validate_on_submit():
            form.populate_obj(comment)
            comment.modify_date = datetime.now()  # 수정일시 저장
            db.session.commit()
            return redirect('{}#comment_{}'.format(
                url_for(xx, question_id=comment.question.id), comment.id))
    else:
        form = CommentForm(obj=comment)
    return render_template('comment/comment_form.html', form=form)