From 40e9428b492cf7004784f37a17aa6835558ccee9 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Thu, 3 Nov 2022 11:30:43 -0700 Subject: [PATCH] Adds more fields to import admin table and ticks version --- bookwyrm/models/import_job.py | 10 ++++++++++ bookwyrm/settings.py | 2 +- bookwyrm/templates/settings/imports/imports.html | 13 +++++++++++-- bookwyrm/views/admin/imports.py | 4 +++- 4 files changed, 25 insertions(+), 4 deletions(-) diff --git a/bookwyrm/models/import_job.py b/bookwyrm/models/import_job.py index 18aad6d88..060f11ede 100644 --- a/bookwyrm/models/import_job.py +++ b/bookwyrm/models/import_job.py @@ -58,6 +58,16 @@ class ImportJob(models.Model): """And how many pending items??""" return self.pending_items.count() + @property + def successful_item_count(self): + """How many found a book?""" + return self.items.filter(book__isnull=False).count() + + @property + def failed_item_count(self): + """How many found a book?""" + return self.items.filter(fail_reason__isnull=False).count() + class ImportItem(models.Model): """a single line of a csv being imported""" diff --git a/bookwyrm/settings.py b/bookwyrm/settings.py index 7e6afbc6b..893669694 100644 --- a/bookwyrm/settings.py +++ b/bookwyrm/settings.py @@ -11,7 +11,7 @@ from django.utils.translation import gettext_lazy as _ env = Env() env.read_env() DOMAIN = env("DOMAIN") -VERSION = "0.4.5" +VERSION = "0.4.6" RELEASE_API = env( "RELEASE_API", diff --git a/bookwyrm/templates/settings/imports/imports.html b/bookwyrm/templates/settings/imports/imports.html index 57c0c73f3..b027e6a4d 100644 --- a/bookwyrm/templates/settings/imports/imports.html +++ b/bookwyrm/templates/settings/imports/imports.html @@ -1,6 +1,7 @@ {% extends 'settings/layout.html' %} {% load i18n %} {% load utilities %} +{% load humanize %} {% block title %}{% trans "Imports" %}{% endblock %} @@ -54,6 +55,12 @@ {% trans "Pending items" %} + + {% trans "Successful items" %} + + + {% trans "Failed items" %} + {% if status == "active" %} {% trans "Actions" %} {% endif %} @@ -68,8 +75,10 @@ {% if status != "active" %} {{ import.updated_date }} {% endif %} - {{ import.item_count }} - {{ import.pending_item_count }} + {{ import.item_count|intcomma }} + {{ import.pending_item_count|intcomma }} + {{ import.successful_item_count|intcomma }} + {{ import.failed_item_count|intcomma }} {% if status == "active" %} {% join "complete" import.id as modal_id %} diff --git a/bookwyrm/views/admin/imports.py b/bookwyrm/views/admin/imports.py index 9ebfce41f..ccba4f976 100644 --- a/bookwyrm/views/admin/imports.py +++ b/bookwyrm/views/admin/imports.py @@ -22,7 +22,9 @@ class ImportList(View): def get(self, request, status="active"): """list of imports""" complete = status == "complete" - imports = models.ImportJob.objects.filter(complete=complete) + imports = models.ImportJob.objects.filter(complete=complete).order_by( + "created_date" + ) paginated = Paginator(imports, PAGE_LENGTH) page = paginated.get_page(request.GET.get("page")) data = {