Shelfs of diffrent users can have the same name now
Removing ratings by giving a rating of zero is now possible (like in calibre)
This commit is contained in:
parent
00ffc87a2b
commit
490f8ef5f2
|
@ -37,7 +37,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="rating">{{_('Rating')}}</label>
|
<label for="rating">{{_('Rating')}}</label>
|
||||||
<input type="number" min="1" max="5" step="1" class="form-control" name="rating" id="rating" value="{% if book.ratings %}{{book.ratings[0].rating / 2}}{% endif %}">
|
<input type="number" min="0" max="5" step="1" class="form-control" name="rating" id="rating" value="{% if book.ratings %}{{book.ratings[0].rating / 2}}{% endif %}">
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="cover_url">{{_('Cover URL (jpg)')}}</label>
|
<label for="cover_url">{{_('Cover URL (jpg)')}}</label>
|
||||||
|
|
|
@ -1267,7 +1267,8 @@ def create_shelf():
|
||||||
shelf.is_public = 1
|
shelf.is_public = 1
|
||||||
shelf.name = to_save["title"]
|
shelf.name = to_save["title"]
|
||||||
shelf.user_id = int(current_user.id)
|
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:
|
if existing_shelf:
|
||||||
flash(_(u"A shelf with the name '%(title)s' already exists.", title=to_save["title"]), category="error")
|
flash(_(u"A shelf with the name '%(title)s' already exists.", title=to_save["title"]), category="error")
|
||||||
else:
|
else:
|
||||||
|
@ -1287,8 +1288,9 @@ def edit_shelf(shelf_id):
|
||||||
shelf = ub.session.query(ub.Shelf).filter(ub.Shelf.id == shelf_id).first()
|
shelf = ub.session.query(ub.Shelf).filter(ub.Shelf.id == shelf_id).first()
|
||||||
if request.method == "POST":
|
if request.method == "POST":
|
||||||
to_save = request.form.to_dict()
|
to_save = request.form.to_dict()
|
||||||
existing_shelf = ub.session.query(ub.Shelf).filter(ub.Shelf.name == to_save["title"]).first()
|
existing_shelf = ub.session.query(ub.Shelf).filter(or_((ub.Shelf.name == to_save["title"])&( ub.Shelf.is_public == 1),
|
||||||
if existing_shelf and existing_shelf.id != shelf_id:
|
(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")
|
flash(_(u"A shelf with the name '%(title)s' already exists.",title=to_save["title"]), category="error")
|
||||||
else:
|
else:
|
||||||
shelf.name = to_save["title"]
|
shelf.name = to_save["title"]
|
||||||
|
|
Loading…
Reference in New Issue
Block a user