Merge pull request #73 from Simple2B/svyat/fix/tags

fix removing tags
This commit is contained in:
Svyatoslav Artymovych 2023-05-26 10:34:35 +03:00 committed by GitHub
commit a313a766e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 14 deletions

View File

@ -73,9 +73,8 @@ def create():
m.Collection( m.Collection(
label="Root Collection", version_id=version.id, is_root=True label="Root Collection", version_id=version.id, is_root=True
).save() ).save()
tags = form.tags.data tags = form.tags.data or ""
if tags: set_book_tags(book, tags)
set_book_tags(book, tags)
flash("Book added!", "success") flash("Book added!", "success")
return redirect(url_for("book.my_library")) return redirect(url_for("book.my_library"))
@ -97,9 +96,8 @@ def edit(book_id: int):
book: m.Book = db.session.get(m.Book, book_id) book: m.Book = db.session.get(m.Book, book_id)
label = form.label.data label = form.label.data
about = form.about.data about = form.about.data
tags = form.tags.data tags = form.tags.data or ""
if tags: set_book_tags(book, tags)
set_book_tags(book, tags)
book.label = label book.label = label
book.about = about book.about = about

View File

@ -102,8 +102,7 @@ def create_comment(
comment.save() comment.save()
tags = current_app.config["TAG_REGEX"].findall(text) tags = current_app.config["TAG_REGEX"].findall(text)
if tags: set_comment_tags(comment, tags)
set_comment_tags(comment, tags)
flash("Success!", "success") flash("Success!", "success")
return redirect(redirect_url) return redirect(redirect_url)
@ -198,8 +197,7 @@ def comment_edit(
log(log.INFO, "Edit comment [%s]", comment) log(log.INFO, "Edit comment [%s]", comment)
tags = current_app.config["TAG_REGEX"].findall(text) tags = current_app.config["TAG_REGEX"].findall(text)
if tags: set_comment_tags(comment, tags)
set_comment_tags(comment, tags)
comment.save() comment.save()

View File

@ -141,8 +141,7 @@ def interpretation_create(
interpretation.save() interpretation.save()
tags = current_app.config["TAG_REGEX"].findall(text) tags = current_app.config["TAG_REGEX"].findall(text)
if tags: set_interpretation_tags(interpretation, tags)
set_interpretation_tags(interpretation, tags)
flash("Success!", "success") flash("Success!", "success")
return redirect(redirect_url) return redirect(redirect_url)
@ -199,8 +198,7 @@ def interpretation_edit(
interpretation.plain_text = plain_text interpretation.plain_text = plain_text
interpretation.text = text interpretation.text = text
tags = current_app.config["TAG_REGEX"].findall(text) tags = current_app.config["TAG_REGEX"].findall(text)
if tags: set_interpretation_tags(interpretation, tags)
set_interpretation_tags(interpretation, tags)
log(log.INFO, "Edit interpretation [%s]", interpretation.id) log(log.INFO, "Edit interpretation [%s]", interpretation.id)
interpretation.save() interpretation.save()