From a0a52d8248f38571494cc804622aece4c852c364 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Wed, 13 Apr 2022 18:31:39 +0200 Subject: [PATCH 01/29] view list for snapshot errors --- ereuse_devicehub/inventory/views.py | 20 +++++ .../templates/inventory/snapshot_list.html | 73 +++++++++++++++++++ 2 files changed, 93 insertions(+) create mode 100644 ereuse_devicehub/templates/inventory/snapshot_list.html diff --git a/ereuse_devicehub/inventory/views.py b/ereuse_devicehub/inventory/views.py index ac91ac44..5ccf6961 100644 --- a/ereuse_devicehub/inventory/views.py +++ b/ereuse_devicehub/inventory/views.py @@ -547,6 +547,25 @@ class ExportsView(View): return flask.render_template('inventory/erasure.html', **params) +class SnapshotListView(GenericMixView): + decorators = [login_required] + template_name = 'inventory/snapshot_list.html' + + def dispatch_request(self): + self.get_context() + return flask.render_template(self.template_name, **self.context) + + def get_context(self): + lots = self.get_lots() + + self.context = { + 'lots': lots, + 'version': __version__, + } + + return self.context + + devices.add_url_rule('/action/add/', view_func=NewActionView.as_view('action_add')) devices.add_url_rule('/action/trade/add/', view_func=NewTradeView.as_view('trade_add')) devices.add_url_rule( @@ -560,6 +579,7 @@ devices.add_url_rule( view_func=NewTradeDocumentView.as_view('trade_document_add'), ) devices.add_url_rule('/device/', view_func=DeviceListView.as_view('devicelist')) +devices.add_url_rule('/snapshot/', view_func=SnapshotListView.as_view('snapshotlist')) devices.add_url_rule( '/device//', view_func=DeviceDetailView.as_view('device_details') ) diff --git a/ereuse_devicehub/templates/inventory/snapshot_list.html b/ereuse_devicehub/templates/inventory/snapshot_list.html new file mode 100644 index 00000000..2eb07016 --- /dev/null +++ b/ereuse_devicehub/templates/inventory/snapshot_list.html @@ -0,0 +1,73 @@ +{% extends "ereuse_devicehub/base_site.html" %} +{% block main %} + +
+

Inventory

+ +
+ +
+
+ +
+ +
+
+ +
+
+
+ + + + + + + + + + + + {% for snap in snapshots_errors %} + + + + + + + + {% endfor %} + +
WBIDSnapshot idDeviceErrorsTime
+ {{ snap.wbid }} + + {{ snap.snapshot_uuid }} + + + {{ snap.description }} + {{ dev.created.strftime('%H:%M %d-%m-%Y') }}
+ +
+
+ +
+
+
+
+ +
+ +
+ +
+ + + +{% endblock main %} From 379a2efca217016b3c297bcd920dc6a93784a62a Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Wed, 13 Apr 2022 20:15:40 +0200 Subject: [PATCH 02/29] errors in snapshots --- ereuse_devicehub/inventory/views.py | 9 ++++++++- ereuse_devicehub/templates/inventory/snapshot_list.html | 4 ++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/ereuse_devicehub/inventory/views.py b/ereuse_devicehub/inventory/views.py index 5ccf6961..9812ffad 100644 --- a/ereuse_devicehub/inventory/views.py +++ b/ereuse_devicehub/inventory/views.py @@ -25,6 +25,7 @@ from ereuse_devicehub.inventory.forms import ( UploadSnapshotForm, ) from ereuse_devicehub.labels.forms import PrintLabelsForm +from ereuse_devicehub.parser.models import SnapshotErrors from ereuse_devicehub.resources.action.models import Trade from ereuse_devicehub.resources.device.models import Computer, DataStorage, Device from ereuse_devicehub.resources.documents.device_row import ActionRow, DeviceRow @@ -557,8 +558,12 @@ class SnapshotListView(GenericMixView): def get_context(self): lots = self.get_lots() + snapshot_errors = SnapshotErrors.query.filter( + SnapshotErrors.owner == current_user + ).order_by(SnapshotErrors.created.desc()) self.context = { + 'snapshot_errors': snapshot_errors, 'lots': lots, 'version': __version__, } @@ -579,7 +584,9 @@ devices.add_url_rule( view_func=NewTradeDocumentView.as_view('trade_document_add'), ) devices.add_url_rule('/device/', view_func=DeviceListView.as_view('devicelist')) -devices.add_url_rule('/snapshot/', view_func=SnapshotListView.as_view('snapshotlist')) +devices.add_url_rule( + '/snapshot/errors/', view_func=SnapshotListView.as_view('snapshot_errors_list') +) devices.add_url_rule( '/device//', view_func=DeviceDetailView.as_view('device_details') ) diff --git a/ereuse_devicehub/templates/inventory/snapshot_list.html b/ereuse_devicehub/templates/inventory/snapshot_list.html index 2eb07016..f34e7930 100644 --- a/ereuse_devicehub/templates/inventory/snapshot_list.html +++ b/ereuse_devicehub/templates/inventory/snapshot_list.html @@ -33,7 +33,7 @@ - {% for snap in snapshots_errors %} + {% for snap in snapshot_errors %} {{ snap.wbid }} @@ -46,7 +46,7 @@ {{ snap.description }} - {{ dev.created.strftime('%H:%M %d-%m-%Y') }} + {{ snap.created.strftime('%H:%M %d-%m-%Y') }} {% endfor %} From 5e74255145de0d9f80a0331831342b3fac81f2ab Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Wed, 11 May 2022 16:59:36 +0200 Subject: [PATCH 03/29] basic list snapshots --- ereuse_devicehub/inventory/views.py | 13 ++++ .../templates/inventory/snapshots_list.html | 63 +++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 ereuse_devicehub/templates/inventory/snapshots_list.html diff --git a/ereuse_devicehub/inventory/views.py b/ereuse_devicehub/inventory/views.py index a09f4f5b..f089dc63 100644 --- a/ereuse_devicehub/inventory/views.py +++ b/ereuse_devicehub/inventory/views.py @@ -505,6 +505,18 @@ class ExportsView(View): return flask.render_template('inventory/erasure.html', **params) +class SnapshotListView(GenericMixView): + methods = ['GET'] + decorators = [login_required] + template_name = 'inventory/snapshots_list.html' + + def dispatch_request(self, id): + self.get_context() + self.context['page_title'] = "Snapshots" + self.context['snapshots'] = [] + return flask.render_template(self.template_name, **self.context) + + devices.add_url_rule('/action/add/', view_func=NewActionView.as_view('action_add')) devices.add_url_rule('/action/trade/add/', view_func=NewTradeView.as_view('trade_add')) devices.add_url_rule( @@ -551,3 +563,4 @@ devices.add_url_rule( devices.add_url_rule( '/export//', view_func=ExportsView.as_view('export') ) +devices.add_url_rule('/snapshots/', view_func=SnapshotListView.as_view('snapshotslist')) diff --git a/ereuse_devicehub/templates/inventory/snapshots_list.html b/ereuse_devicehub/templates/inventory/snapshots_list.html new file mode 100644 index 00000000..e6004f63 --- /dev/null +++ b/ereuse_devicehub/templates/inventory/snapshots_list.html @@ -0,0 +1,63 @@ +{% extends "ereuse_devicehub/base_site.html" %} +{% block main %} + +
+

Inventory

+ +
+ +
+
+ +
+ +
+
+ + +
+ +
+ +
Snapshot
+ + + + + + + + + + + + {% for snap in snapshots %} + + + + + + + + {% endfor %} + +
SidWorkbench VersionErrorsDHIDUploaded
{{ snap.sid }}{{ snap.version }}{{ snap.status }}{{ snap.device.devicehub_id }}{{ snap.created }}
+ +
+ +
+
+ +
+
+
+ + + +{% endblock main %} From 123757793f40cb0385ba36d6aa68ca67594dabd4 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Wed, 11 May 2022 17:03:31 +0200 Subject: [PATCH 04/29] add link on sidebar and put empty data --- ereuse_devicehub/inventory/views.py | 2 +- ereuse_devicehub/templates/ereuse_devicehub/base_site.html | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/ereuse_devicehub/inventory/views.py b/ereuse_devicehub/inventory/views.py index f089dc63..2cdf5af1 100644 --- a/ereuse_devicehub/inventory/views.py +++ b/ereuse_devicehub/inventory/views.py @@ -510,7 +510,7 @@ class SnapshotListView(GenericMixView): decorators = [login_required] template_name = 'inventory/snapshots_list.html' - def dispatch_request(self, id): + def dispatch_request(self): self.get_context() self.context['page_title'] = "Snapshots" self.context['snapshots'] = [] diff --git a/ereuse_devicehub/templates/ereuse_devicehub/base_site.html b/ereuse_devicehub/templates/ereuse_devicehub/base_site.html index fe014107..95b3d3a5 100644 --- a/ereuse_devicehub/templates/ereuse_devicehub/base_site.html +++ b/ereuse_devicehub/templates/ereuse_devicehub/base_site.html @@ -101,6 +101,13 @@ + + + + + + - -