示例#1
0
def add():
    """
    Add a new collection
    """
    form = CollectionForm(exclude=['creator'])
    if form.validate_on_submit():
        model = SuperCollection()
        form.populate_obj(model)
        model.save()
        flash("Collection created")
        return redirect(url_for("collection.list"))
    return render_template('collection/edit.html',
                           title='Start a Collection',
                           form=form
                           )
示例#2
0
def add_subcollection(id):
    """
    Add a new subcollection
    """
    c = Collection.objects.get_or_404(id=id)
    form = CollectionForm(exclude=['creator'], accessibility=c.accessibility)
    if form.validate_on_submit():
        sc = SuperCollection()
        form.populate_obj(sc)
        sc.supercollection = c
        sc.save()
        c.add_subcollection(sc)
        flash("Subcollection created")
        return redirect(url_for("collection.detail", id=c.id))
    return render_template('collection/edit.html',
                           title='Start a Subcollection in %s' % c.title,
                           form=form,
                           collection=c
                           )
示例#3
0
def add():
    """
    Add a new collection
    """
    form = CollectionForm(exclude=['creator'])
    if form.validate_on_submit():
        model = SuperCollection()
        form.populate_obj(model)
        model.save()
        flash("Collection created")
        if request.is_xhr:
            return jsonify({
                'message':'Success', 
                'data':str(model.id)
                })
        return redirect(url_for("collection.list"))
    return render_template('collection/edit.html',
                           title='Start a Collection',
                           form=form
                           )