Пример #1
0
def edit_category(category_id):
    """修改分类"""
    category = Category.query.get_or_404(category_id)
    form = CategoryForm()
    if form.validate_on_submit():
        if form.name.data == Category.query.get(1).name:
            flash(
                "You can't move the category name to the default category name.",
                'warning')
            return redirect(url_for('admin.manage_category'))
        category.name = form.name.data
        db.session.commit()
        flash('Category edited.', 'success')
        return redirect(url_for('admin.manage_category'))
    form.name.data = category.name
    return render_template('admin/edit_category.html', form=form)
Пример #2
0
def show_category():
    form = CategoryForm()
    return render_template('blog/category.html', form=form)
Пример #3
0
def edit_category(category_id):
    form = CategoryForm()
    return render_template('admin/edit_category.html', form=form)
Пример #4
0
def new_category():
    form = CategoryForm()
    return render_template('admin/new_category.html', form=form)