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 )
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 )
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 )