def delete(topic_id): """删除话题""" topic = Topic.query.get_or_404(topic_id) permission = TopicAdminPermission(topic_id) if not permission.check(): return permission.deny() db.session.delete(topic) db.session.commit() return redirect(url_for('.topics'))
def edit(topic_id): """编辑话题""" topic = Topic.query.get_or_404(topic_id) permission = TopicAdminPermission(topic_id) if not permission.check(): return permission.deny() form = TopicForm(obj=topic) if form.validate_on_submit(): form.populate_obj(topic) db.session.add(topic) db.session.commit() return redirect(url_for('.view', topic_id=topic_id)) return render_template('topic/edit/edit.html', topic=topic, form=form)