|
|
|
@ -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"]
|
|
|
|
|