From a9504b0b717511de27727e89418475be07474ac6 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Wed, 23 Nov 2022 13:36:34 +0100 Subject: [PATCH] first step for pagination --- ereuse_devicehub/inventory/views.py | 7 + .../templates/inventory/erasure_list.html | 175 +++++++----------- 2 files changed, 79 insertions(+), 103 deletions(-) diff --git a/ereuse_devicehub/inventory/views.py b/ereuse_devicehub/inventory/views.py index 1d34a7b3..56eaab1d 100644 --- a/ereuse_devicehub/inventory/views.py +++ b/ereuse_devicehub/inventory/views.py @@ -128,6 +128,13 @@ class ErasureListView(DeviceListMixin): ) if orphans: erasure = [e for e in erasure if e.device.orphan] + + page = int(request.args.get('page', 1)) + per_page = int(request.args.get('per_page', 5)) + + erasure = erasure.paginate(page=page, per_page=per_page) + erasure.first = per_page * erasure.page - per_page + 1 + erasure.last = len(erasure.items) + erasure.first - 1 self.context['erasure'] = erasure diff --git a/ereuse_devicehub/templates/inventory/erasure_list.html b/ereuse_devicehub/templates/inventory/erasure_list.html index adaec94f..57f660b8 100644 --- a/ereuse_devicehub/templates/inventory/erasure_list.html +++ b/ereuse_devicehub/templates/inventory/erasure_list.html @@ -110,6 +110,37 @@ {% endif %}
+
+
+ +
+ +
@@ -125,7 +156,7 @@ - {% for ac in erasure %} + {% for ac in erasure.items %}
- {{ ac.snapshot.uuid }} + {{ ac.snapshot.uuid }} @@ -196,6 +227,38 @@
+
+
+ Showing {{ erasure.first }} to {{ erasure.last }} of {{ erasure.total }} entries +
+ +
{% if lot and not lot.is_temporary %}
@@ -225,103 +288,6 @@
-
-
Transfer
-
- {{ form_transfer.csrf_token }} - - {% for field in form_transfer %} - {% if field != form_transfer.csrf_token %} -
- {% if field != form_transfer.type %} - {{ field.label(class_="form-label") }} - {% if field == form_transfer.code %} - * - {% endif %} - {{ field }} - {{ field.description }} - {% if field.errors %} -

- {% for error in field.errors %} - {{ error }}
- {% endfor %} -

- {% endif %} - {% endif %} -
- {% endif %} - {% endfor %} - -
- Cancel - -
-
-
-
-
Delivery Note
-
- {{ form_delivery.csrf_token }} - - {% for field in form_delivery %} - {% if field != form_delivery.csrf_token %} -
- {% if field != form_delivery.type %} - {{ field.label(class_="form-label") }} - {{ field }} - {{ field.description }} - {% if field.errors %} -

- {% for error in field.errors %} - {{ error }}
- {% endfor %} -

- {% endif %} - {% endif %} -
- {% endif %} - {% endfor %} - - {% if lot.transfer and form_receiver.is_editable() %} -
- Cancel - -
- {% endif %} -
-
-
-
Receiver Note
-
- {{ form_receiver.csrf_token }} - - {% for field in form_receiver %} - {% if field != form_receiver.csrf_token %} -
- {% if field != form_receiver.type %} - {{ field.label(class_="form-label") }} - {{ field }} - {{ field.description }} - {% if field.errors %} -

- {% for error in field.errors %} - {{ error }}
- {% endfor %} -

- {% endif %} - {% endif %} -
- {% endif %} - {% endfor %} - - {% if lot.transfer and form_receiver.is_editable() %} -
- Cancel - -
- {% endif %} -
-
{% endif %} @@ -344,11 +310,14 @@ + {% if config['DEBUG'] %} {% else %}