diff --git a/bookwyrm/templates/import/import_status.html b/bookwyrm/templates/import/import_status.html index 01a1fec6b..b2e21d22c 100644 --- a/bookwyrm/templates/import/import_status.html +++ b/bookwyrm/templates/import/import_status.html @@ -69,6 +69,7 @@ {% block actions %}{% endblock %} + {% block table_headers %} + {% endblock %} {% for item in items %} + {% block table_row %} + {% endblock %} {% endfor %}
{% trans "Row" %} @@ -89,7 +90,9 @@ {% trans "Status" %}
{{ item.index }} @@ -126,6 +129,7 @@ {% endif %}
diff --git a/bookwyrm/templates/import/manual_review.html b/bookwyrm/templates/import/manual_review.html new file mode 100644 index 000000000..c9c038698 --- /dev/null +++ b/bookwyrm/templates/import/manual_review.html @@ -0,0 +1,76 @@ +{% extends 'import/import_status.html' %} +{% load i18n %} +{% load utilities %} + +{% block title %}{% trans "Import Troubleshooting" %}{% endblock %} + +{% block page_title %} +{% trans "Review items" %} +{% endblock %} + +{% block actions %} +
+
+

+ {% trans "Approving a suggestion will permanently add the suggested book to your shelves and associate your reading dates, reviews, and ratings with that book." %} +

+
+
+{% endblock %} + +{% block table_headers %} + + + {% trans "Row" %} + + + {% trans "Title" %} + + + {% trans "ISBN" %} + + + {% trans "Author" %} + + + {% trans "Actions" %} + + +{% endblock %} + +{% block table_row %} + + + {{ item.index }} + + + {{ item.normalized_data.title }} + + + {{ item.isbn }} + + + {{ item.normalized_data.authors }} + + + + + + + + +
+ {% with guess=item.book_guess %} +
+ + {% include 'snippets/book_cover.html' with book=guess cover_class='is-h-s' size='small' %} + +
+
+ {% include 'snippets/book_titleby.html' with book=guess %} +
+ {% endwith %} +
+ + +{% endblock %} diff --git a/bookwyrm/urls.py b/bookwyrm/urls.py index 061163a14..1004e30bc 100644 --- a/bookwyrm/urls.py +++ b/bookwyrm/urls.py @@ -243,6 +243,11 @@ urlpatterns = [ views.ImportTroubleshoot.as_view(), name="import-troubleshoot", ), + re_path( + r"^import/(\d+)/review/?$", + views.ImportManualReview.as_view(), + name="import-review", + ), # users re_path(rf"{USER_PATH}\.json$", views.User.as_view()), re_path(rf"{USER_PATH}/?$", views.User.as_view(), name="user-feed"), diff --git a/bookwyrm/views/__init__.py b/bookwyrm/views/__init__.py index 21eeb39b2..9fe09795a 100644 --- a/bookwyrm/views/__init__.py +++ b/bookwyrm/views/__init__.py @@ -46,7 +46,8 @@ from .shelf.shelf_actions import shelve, unshelve # csv import from .imports.import_data import Import from .imports.import_status import ImportStatus -from .imports.troubelshoot import ImportTroubleshoot +from .imports.troubleshoot import ImportTroubleshoot +from .imports.manually_review import ImportManualReview # misc views from .author import Author, EditAuthor diff --git a/bookwyrm/views/imports/import_data.py b/bookwyrm/views/imports/import_data.py index 64cefc7f3..7f6a4d13f 100644 --- a/bookwyrm/views/imports/import_data.py +++ b/bookwyrm/views/imports/import_data.py @@ -10,7 +10,11 @@ from django.utils.translation import gettext_lazy as _ from django.views import View from bookwyrm import forms, models -from bookwyrm.importers import LibrarythingImporter, GoodreadsImporter, StorygraphImporter +from bookwyrm.importers import ( + LibrarythingImporter, + GoodreadsImporter, + StorygraphImporter, +) # pylint: disable= no-self-use @method_decorator(login_required, name="dispatch") diff --git a/bookwyrm/views/imports/manually_review.py b/bookwyrm/views/imports/manually_review.py new file mode 100644 index 000000000..286251d44 --- /dev/null +++ b/bookwyrm/views/imports/manually_review.py @@ -0,0 +1,39 @@ +""" verify books we're unsure about """ +from django.contrib.auth.decorators import login_required +from django.core.exceptions import PermissionDenied +from django.core.paginator import Paginator +from django.shortcuts import get_object_or_404 +from django.template.response import TemplateResponse +from django.utils.decorators import method_decorator +from django.views import View + +from bookwyrm import models +from bookwyrm.settings import PAGE_LENGTH + +# pylint: disable= no-self-use +@method_decorator(login_required, name="dispatch") +class ImportManualReview(View): + """problems items in an existing import""" + + def get(self, request, job_id): + """status of an import job""" + job = get_object_or_404(models.ImportJob, id=job_id) + if job.user != request.user: + raise PermissionDenied() + + items = job.items.order_by("index").filter( + book__isnull=True, book_guess__isnull=False + ) + + paginated = Paginator(items, PAGE_LENGTH) + page = paginated.get_page(request.GET.get("page")) + data = { + "job": job, + "items": page, + "page_range": paginated.get_elided_page_range( + page.number, on_each_side=2, on_ends=1 + ), + "complete": True, + } + + return TemplateResponse(request, "import/manual_review.html", data) diff --git a/bookwyrm/views/imports/troubleshoot.py b/bookwyrm/views/imports/troubleshoot.py index 48f2b9986..f637b966b 100644 --- a/bookwyrm/views/imports/troubleshoot.py +++ b/bookwyrm/views/imports/troubleshoot.py @@ -23,7 +23,7 @@ class ImportTroubleshoot(View): raise PermissionDenied() items = job.items.order_by("index").filter( - fail_reason__isnull=False, book_guess__isnull=False + fail_reason__isnull=False, book_guess__isnull=True ) paginated = Paginator(items, PAGE_LENGTH)