def _last_index(self, s):
        self.set_index(max(0, self._find_one_after_last_labeled_index() - 1))
def add_category():
    form = CategoryForm()

    if form.validate_on_submit():
        form.save()
        flash(_("Category added."), "success")
        return redirect(url_for("management.forums"))

    return render_template("management/category_form.html", form=form,
                           title=_("Add Category"))