Adds manual review view

This commit is contained in:
Mouse Reeve 2021-11-12 16:23:56 -08:00
parent 9bff27e61f
commit 221cde9be4
7 changed files with 132 additions and 3 deletions

View file

@ -69,6 +69,7 @@
</h2>
{% block actions %}{% endblock %}
<table class="table">
{% block table_headers %}
<tr>
<th>
{% trans "Row" %}
@ -89,7 +90,9 @@
{% trans "Status" %}
</th>
</tr>
{% endblock %}
{% for item in items %}
{% block table_row %}
<tr>
<td>
{{ item.index }}
@ -126,6 +129,7 @@
{% endif %}
</td>
</tr>
{% endblock %}
{% endfor %}
</table>
</div>

View file

@ -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 %}
<div class="block">
<div class="notification content">
<p>
{% trans "Approving a suggestion will permanently add the suggested book to your shelves and associate your reading dates, reviews, and ratings with that book." %}
</p>
</div>
</div>
{% endblock %}
{% block table_headers %}
<tr>
<th>
{% trans "Row" %}
</th>
<th>
{% trans "Title" %}
</th>
<th>
{% trans "ISBN" %}
</th>
<th>
{% trans "Author" %}
</th>
<th>
{% trans "Actions" %}
</th>
</tr>
{% endblock %}
{% block table_row %}
<tr>
<td rowspan="2">
{{ item.index }}
</td>
<td>
{{ item.normalized_data.title }}
</td>
<td>
{{ item.isbn }}
</td>
<td>
{{ item.normalized_data.authors }}
</td>
<td>
<button type="submit" class="button is-success">{% trans "Approve" %}</button>
<button type="submit" class="button is-danger is-light is-outlined">{% trans "Delete" %}</button>
</td>
</tr>
<tr>
<td colspan="5">
<div class="columns is-mobile">
{% with guess=item.book_guess %}
<div class="column is-narrow">
<a href="{{ item.book.local_path }}" target="_blank">
{% include 'snippets/book_cover.html' with book=guess cover_class='is-h-s' size='small' %}
</a>
</div>
<div class="column">
{% include 'snippets/book_titleby.html' with book=guess %}
</div>
{% endwith %}
</div>
</td>
</tr>
{% endblock %}

View file

@ -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"),

View file

@ -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

View file

@ -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")

View file

@ -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)

View file

@ -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)