예제 #1
0
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'))
예제 #2
0
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'))
예제 #3
0
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)
예제 #4
0
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)