From 02313f40b8700a7a3c121f94bbdc0d301db16c60 Mon Sep 17 00:00:00 2001
From: Mouse Reeve
Date: Sun, 5 Dec 2021 13:46:13 -0800
Subject: [PATCH] Adds update from inventaire link for books
---
bookwyrm/connectors/inventaire.py | 2 +-
bookwyrm/templates/book/book.html | 10 +++++++++-
bookwyrm/urls.py | 4 ++--
3 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/bookwyrm/connectors/inventaire.py b/bookwyrm/connectors/inventaire.py
index 45d0546f..a9aeb94f 100644
--- a/bookwyrm/connectors/inventaire.py
+++ b/bookwyrm/connectors/inventaire.py
@@ -214,7 +214,7 @@ class Connector(AbstractConnector):
def get_remote_id_from_model(self, obj):
"""use get_remote_id to figure out the link from a model obj"""
- remote_id_value = getattr(obj, self.inventaire_id)
+ remote_id_value = obj.inventaire_id
return self.get_remote_id(remote_id_value)
diff --git a/bookwyrm/templates/book/book.html b/bookwyrm/templates/book/book.html
index cdfbdf98..6d8ce72b 100644
--- a/bookwyrm/templates/book/book.html
+++ b/bookwyrm/templates/book/book.html
@@ -102,7 +102,15 @@
{% endif %}
{% if book.inventaire_id %}
- {% trans "View on Inventaire" %}
+
+ {% trans "View on Inventaire" %}
+ {% if request.user.is_authenticated and perms.bookwyrm.edit_book %}
+
+ {% endif %}
+
{% endif %}
diff --git a/bookwyrm/urls.py b/bookwyrm/urls.py
index 6e53ef2a..012a9116 100644
--- a/bookwyrm/urls.py
+++ b/bookwyrm/urls.py
@@ -425,12 +425,12 @@ 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[\w\.]+)?$",
+ rf"{BOOK_PATH}/update/(?P[\w\.]+)/?$",
views.update_book_from_remote,
name="book-update-remote",
),
re_path(
- r"^author/(?P\d+)/update/(?P[\w\.]+)?$",
+ r"^author/(?P\d+)/update/(?P[\w\.]+)/?$",
views.update_author_from_remote,
name="author-update-remote",
),