From 032ce8efbae0b4c6588f785ddec51041aaa9f9de Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Thu, 12 Nov 2020 13:52:57 -0800 Subject: [PATCH] Show failed books --- bookwyrm/templates/import_status.html | 24 +++++++++++++++++++++--- bookwyrm/views.py | 6 +++++- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/bookwyrm/templates/import_status.html b/bookwyrm/templates/import_status.html index e4eb681e1..d091e3033 100644 --- a/bookwyrm/templates/import_status.html +++ b/bookwyrm/templates/import_status.html @@ -26,7 +26,24 @@ {% endif %} +{% if failed_items %}
+

Failed to load

+ +
+{% endif %} + +
+

Successfully imported

diff --git a/bookwyrm/views.py b/bookwyrm/views.py index 771e6a85c..b40a75a75 100644 --- a/bookwyrm/views.py +++ b/bookwyrm/views.py @@ -209,10 +209,14 @@ def import_status(request, job_id): if job.user != request.user: raise PermissionDenied task = app.AsyncResult(job.task_id) + items = job.items.order_by('index').all() + failed_items = [i for i in items if i.fail_reason] + items = [i for i in items if not i.fail_reason] return TemplateResponse(request, 'import_status.html', { 'title': 'Import Status', 'job': job, - 'items': job.items.order_by('index').all(), + 'items': items, + 'failed_items': failed_items, 'task': task })
@@ -57,9 +74,10 @@ {{ item.data|dict_key:'Author' }} - {% if item.book %}✓ - {% elif item.fail_reason %} - {{ item.fail_reason }} + {% if item.book %} + + Imported + {% endif %}