diff --git a/bookwyrm/connectors/abstract_connector.py b/bookwyrm/connectors/abstract_connector.py index 48d2b4cb..4b1f6e58 100644 --- a/bookwyrm/connectors/abstract_connector.py +++ b/bookwyrm/connectors/abstract_connector.py @@ -177,9 +177,10 @@ class AbstractConnector(AbstractMinimalConnector): def get_or_create_author(self, remote_id, instance=None): """load that author""" - existing = models.Author.find_existing_by_remote_id(remote_id) - if existing: - return existing + if not instance: + existing = models.Author.find_existing_by_remote_id(remote_id) + if existing: + return existing data = self.get_book_data(remote_id) diff --git a/bookwyrm/connectors/openlibrary.py b/bookwyrm/connectors/openlibrary.py index 225174c8..c15277f8 100644 --- a/bookwyrm/connectors/openlibrary.py +++ b/bookwyrm/connectors/openlibrary.py @@ -68,6 +68,7 @@ class Connector(AbstractConnector): Mapping("born", remote_field="birth_date"), Mapping("died", remote_field="death_date"), Mapping("bio", formatter=get_description), + Mapping("isni", remote_field="remote_ids", formatter=get_isni), ] def get_book_data(self, remote_id): @@ -226,6 +227,13 @@ def get_languages(language_blob): return langs +def get_isni(remote_ids_blob): + """extract the isni from the remote id data for the author""" + if not remote_ids_blob or not isinstance(remote_ids_blob, dict): + return None + return remote_ids_blob.get("isni") + + def pick_default_edition(options): """favor physical copies with covers in english""" if not options: diff --git a/bookwyrm/models/author.py b/bookwyrm/models/author.py index ce0d027c..5cc11afd 100644 --- a/bookwyrm/models/author.py +++ b/bookwyrm/models/author.py @@ -38,7 +38,7 @@ class Author(BookDataModel): def isni_link(self): """generate the url from the isni id""" clean_isni = re.sub(r"\s", "", self.isni) - return f"https://insi.org/isni/{clean_isni}" + return f"https://isni.org/isni/{clean_isni}" @property def openlibrary_link(self): diff --git a/bookwyrm/templates/author/author.html b/bookwyrm/templates/author/author.html index c2355955..6e93d313 100644 --- a/bookwyrm/templates/author/author.html +++ b/bookwyrm/templates/author/author.html @@ -14,7 +14,7 @@ {% if request.user.is_authenticated and perms.bookwyrm.edit_book %}
+
{% trans "View on OpenLibrary" %} {% if request.user.is_authenticated and perms.bookwyrm.edit_book %} - +
{% endif %} {% endif %} {% if author.inventaire_id %} -+
{% trans "View on Inventaire" %} {% if request.user.is_authenticated and perms.bookwyrm.edit_book %} - +
{% endif %} {% endif %} diff --git a/bookwyrm/templates/book/book.html b/bookwyrm/templates/book/book.html index 3a7b1cbc..cdfbdf98 100644 --- a/bookwyrm/templates/book/book.html +++ b/bookwyrm/templates/book/book.html @@ -93,10 +93,12 @@ {% if book.openlibrary_key %}{% trans "View on OpenLibrary" %} + {% if request.user.is_authenticated and perms.bookwyrm.edit_book %}
+ {% endif %} {% endif %} {% if book.inventaire_id %} diff --git a/bookwyrm/urls.py b/bookwyrm/urls.py index 697028b7..6e53ef2a 100644 --- a/bookwyrm/urls.py +++ b/bookwyrm/urls.py @@ -425,15 +425,26 @@ urlpatterns = [ re_path(r"^resolve-book/?$", views.resolve_book, name="resolve-book"), re_path(r"^switch-edition/?$", views.switch_edition, name="switch-edition"), re_path( - rf"{BOOK_PATH}/update/(?P