def category_edit(workspace, category): form = CategoryForm(obj=category) if form.validate_on_submit(): form.populate_obj(category) category.make_name() db.session.commit() flash("Edited item '%s'" % category.name, "success") return render_redirect(url_for('category_list', workspace=workspace.name), code=303) return render_form(form=form, title=u"Edit Category", formid='category_edit', submit=u"Save", cancel_url=url_for('category_list', workspace=workspace.name), ajax=True)
def category_new(workspace): form = CategoryForm() if form.validate_on_submit(): category = Category(workspace=workspace) form.populate_obj(category) category.make_name() db.session.add(category) db.session.commit() flash("Created new category in workspace '%s'." % workspace.name, "success") return render_redirect(url_for('category_list', workspace=workspace.name), code=303) return render_form(form=form, title=u"Create new category", formid="category_new", submit=u"Create", cancel_url=url_for('category_list', workspace=workspace.name), ajax=False)