From 0145e9618c0c1994c5729f33b86c0fe210ee8379 Mon Sep 17 00:00:00 2001 From: SvyatoslavArtymovych Date: Wed, 26 Apr 2023 17:01:20 +0300 Subject: [PATCH] fix bug with submitting the same collection label --- app/views/book.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/views/book.py b/app/views/book.py index ec97b12..6526088 100644 --- a/app/views/book.py +++ b/app/views/book.py @@ -407,7 +407,11 @@ def collection_edit(book_id: int, collection_id: int): if form.validate_on_submit(): 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.INFO, "Collection with similar label already exists. Book: [%s], Collection: [%s], Label: [%s]",