def categories_create(): form = NewCategoryForm(request.form) if not form.validate(): return render_template("categories/list.html", categories=Category.get_category_list(), form=form) category = Category(form.name.data) try: db.session.add(category) db.session.commit() except IntegrityError: db.session.rollback() return render_template("categories/list.html", categories=Category.get_category_list(), form=form, category_name_taken=True) return render_template("categories/list.html", categories=Category.get_category_list(), form=form)
def categories_index(): form = NewCategoryForm() return render_template("categories/list.html", categories=Category.get_category_list(), form=form)