diff --git a/cps/templates/edit_book.html b/cps/templates/edit_book.html
index 85e8de1a..e4bc7e0b 100644
--- a/cps/templates/edit_book.html
+++ b/cps/templates/edit_book.html
@@ -37,7 +37,7 @@
-
+
diff --git a/cps/web.py b/cps/web.py
index 07136f5f..fff84f37 100755
--- a/cps/web.py
+++ b/cps/web.py
@@ -1267,7 +1267,8 @@ def create_shelf():
shelf.is_public = 1
shelf.name = to_save["title"]
shelf.user_id = int(current_user.id)
- existing_shelf = ub.session.query(ub.Shelf).filter(ub.Shelf.name == shelf.name).first()
+ existing_shelf = ub.session.query(ub.Shelf).filter(or_((ub.Shelf.name == to_save["title"])&( ub.Shelf.is_public == 1),
+ (ub.Shelf.name == to_save["title"])& (ub.Shelf.user_id == int(current_user.id)))).first()
if existing_shelf:
flash(_(u"A shelf with the name '%(title)s' already exists.", title=to_save["title"]), category="error")
else:
@@ -1287,8 +1288,9 @@ def edit_shelf(shelf_id):
shelf = ub.session.query(ub.Shelf).filter(ub.Shelf.id == shelf_id).first()
if request.method == "POST":
to_save = request.form.to_dict()
- existing_shelf = ub.session.query(ub.Shelf).filter(ub.Shelf.name == to_save["title"]).first()
- if existing_shelf and existing_shelf.id != shelf_id:
+ existing_shelf = ub.session.query(ub.Shelf).filter(or_((ub.Shelf.name == to_save["title"])&( ub.Shelf.is_public == 1),
+ (ub.Shelf.name == to_save["title"])& (ub.Shelf.user_id == int(current_user.id)))).filter(ub.Shelf.id!=shelf_id).first()
+ if existing_shelf:
flash(_(u"A shelf with the name '%(title)s' already exists.",title=to_save["title"]), category="error")
else:
shelf.name = to_save["title"]