Adds more fields to import admin table and ticks version

This commit is contained in:
Mouse Reeve 2022-11-03 11:30:43 -07:00
parent 3f2f718878
commit 40e9428b49
4 changed files with 25 additions and 4 deletions

View file

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

View file

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

View file

@ -1,6 +1,7 @@
{% extends 'settings/layout.html' %}
{% load i18n %}
{% load utilities %}
{% load humanize %}
{% block title %}{% trans "Imports" %}{% endblock %}
@ -54,6 +55,12 @@
<th>
{% trans "Pending items" %}
</th>
<th>
{% trans "Successful items" %}
</th>
<th>
{% trans "Failed items" %}
</th>
{% if status == "active" %}
<th>{% trans "Actions" %}</th>
{% endif %}
@ -68,8 +75,10 @@
{% if status != "active" %}
<td>{{ import.updated_date }}</td>
{% endif %}
<td>{{ import.item_count }}</td>
<td>{{ import.pending_item_count }}</td>
<td>{{ import.item_count|intcomma }}</td>
<td>{{ import.pending_item_count|intcomma }}</td>
<td>{{ import.successful_item_count|intcomma }}</td>
<td>{{ import.failed_item_count|intcomma }}</td>
{% if status == "active" %}
<td>
{% join "complete" import.id as modal_id %}

View file

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