+ # Make sure there isn't already a Collection with this title
+ existing_collection = request.db.Collection.find_one({
+ 'creator': request.user.id,
+ 'title':form.title.data})
+
+ if existing_collection and existing_collection.id != collection.id:
+ messages.add_message(
+ request, messages.ERROR,
+ _('You already have a collection called "%s"!') % \
+ form.title.data)
+ elif slug_used:
+ form.slug.errors.append(
+ _(u'A collection with that slug already exists for this user.'))
+ else:
+ collection.title = unicode(form.title.data)
+ collection.description = unicode(form.description.data)
+ collection.slug = unicode(form.slug.data)
+
+ collection.save()
+
+ return redirect_obj(request, collection)
+
+ if request.user.is_admin \
+ and collection.creator != request.user.id \
+ and request.method != 'POST':
+ messages.add_message(
+ request, messages.WARNING,
+ _("You are editing another user's collection. Proceed with caution."))
+
+ return render_to_response(
+ request,
+ 'mediagoblin/edit/edit_collection.html',
+ {'collection': collection,
+ 'form': form})
+
+
+@require_active_login
+def change_pass(request):
+ form = forms.ChangePassForm(request.form)
+ user = request.user
+
+ if request.method == 'POST' and form.validate():
+
+ if not auth_lib.bcrypt_check_password(
+ form.old_password.data, user.pw_hash):
+ form.old_password.errors.append(
+ _('Wrong password'))