From f2e4865adf1df01a1d1bbe9c096f25c5d8f2d712 Mon Sep 17 00:00:00 2001 From: Hugh Rundle Date: Fri, 29 Oct 2021 16:13:05 +1100 Subject: [PATCH] check isni sources when editing book authors --- bookwyrm/templates/book/edit/edit_book.html | 18 ++++++++++++++++++ bookwyrm/views/books/edit_book.py | 6 +++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/bookwyrm/templates/book/edit/edit_book.html b/bookwyrm/templates/book/edit/edit_book.html index fc11208f..0854a879 100644 --- a/bookwyrm/templates/book/edit/edit_book.html +++ b/bookwyrm/templates/book/edit/edit_book.html @@ -50,6 +50,24 @@
{% for author in author_matches %} + {% if author.isni_matches %} +
+ + {% blocktrans with name=author.name %}Is "{{ name }}" one of these?{% endblocktrans %} + + {% with forloop.counter0 as counter %} + {% for match in author.isni_matches %} + + {% endfor %} + {% endwith %} +
+ {% endif %}
{% blocktrans with name=author.name %}Is "{{ name }}" an existing author?{% endblocktrans %} diff --git a/bookwyrm/views/books/edit_book.py b/bookwyrm/views/books/edit_book.py index 1445dc01..ed704e1e 100644 --- a/bookwyrm/views/books/edit_book.py +++ b/bookwyrm/views/books/edit_book.py @@ -13,7 +13,7 @@ from django.views import View from bookwyrm import book_search, forms, models from bookwyrm.views.helpers import get_edition from .books import set_cover_from_url - +from bookwyrm.utils.isni import find_authors_by_name # pylint: disable=no-self-use @method_decorator(login_required, name="dispatch") @@ -48,6 +48,7 @@ class EditBook(View): if add_author: data["add_author"] = add_author data["author_matches"] = [] + data["isni_matches"] = [] for author in add_author.split(","): if not author: continue @@ -65,6 +66,9 @@ class EditBook(View): .filter(rank__gt=0.4) .order_by("-rank")[:5] ), + "isni_matches": find_authors_by_name( + author + ), # find matches from ISNI API } )