fix bug with submitting the same collection label

This commit is contained in:
SvyatoslavArtymovych 2023-04-26 17:01:20 +03:00
parent 78b09a8274
commit 0145e9618c

View File

@ -407,7 +407,11 @@ def collection_edit(book_id: int, collection_id: int):
if form.validate_on_submit(): if form.validate_on_submit():
label = form.label.data label = form.label.data
if m.Collection.query.filter_by(label=label).first(): if (
m.Collection.query.filter_by(label=label)
.filter(m.Collection.id != collection_id)
.first()
):
log( log(
log.INFO, log.INFO,
"Collection with similar label already exists. Book: [%s], Collection: [%s], Label: [%s]", "Collection with similar label already exists. Book: [%s], Collection: [%s], Label: [%s]",