submit_form = submit_forms.AddCollectionForm(request.form)
if request.method == 'POST' and submit_form.validate():
- collection = request.db.Collection()
-
- collection.title = unicode(submit_form.title.data)
- collection.description = unicode(submit_form.description.data)
- collection.creator = request.user.id
- collection.generate_slug()
-
- # Make sure this user isn't duplicating an existing collection
- existing_collection = request.db.Collection.find_one({
- 'creator': request.user.id,
- 'title':collection.title})
-
- if existing_collection:
- add_message(request, messages.ERROR,
- _('You already have a collection called "%s"!') \
- % collection.title)
- else:
- collection.save()
-
- add_message(request, SUCCESS,
- _('Collection "%s" added!') % collection.title)
-
- return redirect(request, "mediagoblin.user_pages.user_home",
- user=request.user.username)
+ collection = request.db.Collection()
+
+ collection.title = unicode(submit_form.title.data)
+ collection.description = unicode(submit_form.description.data)
+ collection.creator = request.user.id
+ collection.generate_slug()
+
+ # Make sure this user isn't duplicating an existing collection
+ existing_collection = request.db.Collection.find_one({
+ 'creator': request.user.id,
+ 'title':collection.title})
+
+ if existing_collection:
+ add_message(request, messages.ERROR,
+ _('You already have a collection called "%s"!') \
+ % collection.title)
+ else:
+ collection.save()
+
+ add_message(request, SUCCESS,
+ _('Collection "%s" added!') % collection.title)
+
+ return redirect(request, "mediagoblin.user_pages.user_home",
+ user=request.user.username)
return render_to_response(
request,