def add_category(): form = CategoryForm() if form.validate_on_submit(): form.save() flash(_("Category successfully added."), "success") return redirect(url_for("management.forums")) return render_template("management/category_form.html", form=form, title=_("Add Category"))
def edit_category(category_id): category = jnt_models.Category.query.filter_by(id=category_id).first_or_404() form = CategoryForm(obj=category) if form.validate_on_submit(): form.populate_obj(category) flash(_("Category successfully updated."), "success") category.save() return render_template("management/category_form.html", form=form, title=_("Edit Category"))