Display error message for remote failure

This commit is contained in:
Mouse Reeve 2022-03-13 12:38:29 -07:00
parent 739b394ccc
commit c7efa23405
2 changed files with 12 additions and 2 deletions

View file

@ -12,6 +12,15 @@
{% endblock %}
{% block content %}
{% if update_error %}
<div class="notification is-danger is-light">
<span class="icon icon-x" aria-hidden="true"></span>
<span>
{% trans "Unable to connect to remote source." %}
</span>
</div>
{% endif %}
{% with user_authenticated=request.user.is_authenticated can_edit_book=perms.bookwyrm.edit_book %}
<div class="block" itemscope itemtype="https://schema.org/Book">
<div class="columns is-mobile">

View file

@ -22,7 +22,7 @@ from bookwyrm.views.helpers import is_api_request
class Book(View):
"""a book! this is the stuff"""
def get(self, request, book_id, user_statuses=False):
def get(self, request, book_id, user_statuses=False, update_error=False):
"""info about a book"""
if is_api_request(request):
book = get_object_or_404(
@ -80,6 +80,7 @@ class Book(View):
else None,
"rating": reviews.aggregate(Avg("rating"))["rating__avg"],
"lists": lists,
"update_error": update_error,
}
if request.user.is_authenticated:
@ -195,6 +196,6 @@ def update_book_from_remote(request, book_id, connector_identifier):
connector.update_book_from_remote(book)
except ConnectorException:
# the remote source isn't available or doesn't know this book
pass
return Book().get(request, book_id, update_error=True)
return redirect("book", book.id)