From baa48bf5cdcb370b13baecce674ac2ea1278b7c7 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Thu, 22 Sep 2022 19:14:11 +0200 Subject: [PATCH 1/3] add new columns to list of snapshots --- ereuse_devicehub/inventory/views.py | 5 +++- ereuse_devicehub/parser/models.py | 30 +++++++++++++++++++ .../templates/inventory/snapshots_list.html | 12 ++++++++ 3 files changed, 46 insertions(+), 1 deletion(-) diff --git a/ereuse_devicehub/inventory/views.py b/ereuse_devicehub/inventory/views.py index 1e0896de..47681ff5 100644 --- a/ereuse_devicehub/inventory/views.py +++ b/ereuse_devicehub/inventory/views.py @@ -724,7 +724,7 @@ class NewTradeView(DeviceListMixin, NewActionView): return flask.redirect(next_url) -class NewTradeDocumentView(View): +class NewTradeDocumentView(GenericMixin): methods = ['POST', 'GET'] decorators = [login_required] template_name = 'inventory/trade_document.html' @@ -1137,6 +1137,9 @@ class SnapshotListView(GenericMixin): 'status': snap.get_status(), 'severity': snap.severity, 'created': snap.created, + 'type_device': snap.get_type_device(), + 'original_dhid': snap.get_original_dhid(), + 'new_device': snap.get_new_device(), } continue diff --git a/ereuse_devicehub/parser/models.py b/ereuse_devicehub/parser/models.py index 769e43a1..4d298af0 100644 --- a/ereuse_devicehub/parser/models.py +++ b/ereuse_devicehub/parser/models.py @@ -48,6 +48,36 @@ class SnapshotsLog(Thing): return '' + def get_original_dhid(self): + if self.snapshot: + dev = self.snapshot.device + if dev.dhid_bk: + return dev.dhid_bk + + return self.get_device() + + def get_type_device(self): + if self.snapshot: + if self.snapshot.device.binding: + return self.snapshot.device.binding.status + + return '' + + def get_new_device(self): + if not self.snapshot: + return '' + + if not self.snapshot.device: + return '' + + snapshots = [] + for s in self.snapshot.device.actions: + if s == self.snapshot: + continue + if s.type == self.snapshot.type: + snapshots.append(s) + return snapshots and 'Update' or 'New Device' + class PlaceholdersLog(Thing): """A Placeholder log.""" diff --git a/ereuse_devicehub/templates/inventory/snapshots_list.html b/ereuse_devicehub/templates/inventory/snapshots_list.html index 77e37ae5..2c6b5645 100644 --- a/ereuse_devicehub/templates/inventory/snapshots_list.html +++ b/ereuse_devicehub/templates/inventory/snapshots_list.html @@ -31,6 +31,9 @@ DHID System UUID Status + Type Upload + Type Device + Original DHID Time @@ -68,6 +71,15 @@ {{ snap.status }} + + {{ snap.new_device }} + + + {{ snap.type_device }} + + + {{ snap.original_dhid }} + {{ snap.created.strftime('%H:%M %d-%m-%Y') }} {% if snap.snapshot_uuid %} From 3b7d3966706d6020eb2cbe69d5933045b0ff5398 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Fri, 23 Sep 2022 09:58:14 +0200 Subject: [PATCH 2/3] no fix now bug 3831 --- ereuse_devicehub/inventory/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ereuse_devicehub/inventory/views.py b/ereuse_devicehub/inventory/views.py index 47681ff5..8f374a95 100644 --- a/ereuse_devicehub/inventory/views.py +++ b/ereuse_devicehub/inventory/views.py @@ -724,7 +724,7 @@ class NewTradeView(DeviceListMixin, NewActionView): return flask.redirect(next_url) -class NewTradeDocumentView(GenericMixin): +class NewTradeDocumentView(View): methods = ['POST', 'GET'] decorators = [login_required] template_name = 'inventory/trade_document.html' From 0db1d2ed0efa7b37abc95507785fcefc3bab171d Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Fri, 23 Sep 2022 10:27:29 +0200 Subject: [PATCH 3/3] fix test --- tests/test_render_2_0.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/test_render_2_0.py b/tests/test_render_2_0.py index a088df5a..0ff63885 100644 --- a/tests/test_render_2_0.py +++ b/tests/test_render_2_0.py @@ -1699,7 +1699,6 @@ def test_export_lots(user3: UserClientFlask): @pytest.mark.mvp @pytest.mark.usefixtures(conftest.app_context.__name__) def test_export_snapshot_json(user3: UserClientFlask): - file_name = 'real-eee-1001pxd.snapshot.13.json' snap = create_device(user3, file_name)