Esempio n. 1
0
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 category '%s'" % category.title, "success")
        return render_redirect(url_for('category', workspace=workspace.name, category=category.name), code=303)
    return render_form(form=form, title=u"Edit category",
        formid='category_edit', submit=u"Save",
        cancel_url=url_for('category', workspace=workspace.name, category=category.name), ajax=True)
Esempio n. 2
0
def category_edit(name):
    category = Category.query.filter_by(name=name).first_or_404()
    form = CategoryForm(obj=category)
    if form.validate_on_submit():
        form.populate_obj(category)
        category.make_name()
        db.session.commit()
        flash("Edited category '%s'" % category.title, "success")
        return render_redirect(url_for('category', name=category.name), code=303)
    return render_form(form=form, title=u"Edit category",
        formid='category_edit', submit=u"Save",
        cancel_url=url_for('category', name=category.name), ajax=True)
Esempio n. 3
0
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 '%s'." % category.title, "success")
        return render_redirect(url_for('category', workspace=workspace.name, category=category.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=True)
Esempio n. 4
0
def category_edit(name):
    category = Category.query.filter_by(name=name).first_or_404()
    form = CategoryForm(obj=category)
    if form.validate_on_submit():
        form.populate_obj(category)
        category.make_name()
        db.session.commit()
        flash("Edited category '%s'" % category.title, "success")
        return render_redirect(url_for('category', name=category.name),
                               code=303)
    return render_form(form=form,
                       title=u"Edit category",
                       formid='category_edit',
                       submit=u"Save",
                       cancel_url=url_for('category', name=category.name),
                       ajax=True)
Esempio n. 5
0
def category_new():
    form = CategoryForm()
    if form.validate_on_submit():
        category = Category()
        form.populate_obj(category)
        category.make_name()
        db.session.add(category)
        db.session.commit()
        flash("Created new category '%s'." % category.title, "success")
        return render_redirect(url_for('category', name=category.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'),
                       ajax=True)
Esempio n. 6
0
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 category '%s'" % category.title, "success")
        return render_redirect(url_for('category',
                                       workspace=workspace.name,
                                       category=category.name),
                               code=303)
    return render_form(form=form,
                       title=u"Edit category",
                       formid='category_edit',
                       submit=u"Save",
                       cancel_url=url_for('category',
                                          workspace=workspace.name,
                                          category=category.name),
                       ajax=True)