def change_comment(self, request, id, action): comment = Comment.query.get(id) if action in ("hide", "restore"): message = { "hide": _(u"Do you really want to hide the comment?"), "restore": _(u"Do you really want to restore the comment?"), } if confirm_action(request, message[action], "news/edit_comment", id=id, action=action): comment.deleted = action == "hide" db.session.commit() request.flash( _(u"The comment has been hidden") if action == "hide" else _(u"The comment has been restored") ) return redirect_to(comment) return redirect_to(comment.article) # action == 'edit' form = EditCommentForm(request.form) if form.validate_on_submit(): if form.validate(): comment.text = form.text.data db.session.commit() request.flash(_(u"The comment was saved"), True) return redirect_to(comment) else: form.text.data = comment.text return {"comment": comment, "form": form}
def change_comment(self, request, id, action): comment = Comment.query.get(id) if action in ('hide', 'restore'): message = { 'hide': _(u'Do you really want to hide the comment?'), 'restore': _(u'Do you really want to restore the comment?') } if confirm_action(request, message[action], 'news/edit_comment', id=id, action=action): comment.deleted = action == 'hide' db.session.commit() request.flash(_(u'The comment has been hidden') if \ action == 'hide' else _(u'The comment has been restored')) return redirect_to(comment) return redirect_to(comment.article) # action == 'edit' form = EditCommentForm(request.form) if form.validate_on_submit(): if form.validate(): comment.text = form.text.data db.session.commit() request.flash(_(u'The comment was saved'), True) return redirect_to(comment) else: form.text.data = comment.text return { 'comment': comment, 'form': form, }
def tags_delete(self, request, slug): message = _(u'Do you really want to delete this tag?') tag = Tag.query.filter_by(slug=slug).one() if confirm_action(request, message, 'portal/tag_delete', slug=slug): db.session.delete(tag) db.session.commit() request.flash(_(u'The tag ā%sā was deleted successfully.' % tag.name)) return redirect_to('portal/tags') return redirect_to(tag)