From ff765f38f8617f330dacabde4768a7741221dc17 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Tue, 20 Sep 2022 10:27:02 +0200 Subject: [PATCH] add view for list of hdd eraseds --- ereuse_devicehub/inventory/views.py | 24 +- .../templates/ereuse_devicehub/base_site.html | 8 + .../templates/inventory/erasure_list.html | 265 ++++++++++++++++++ 3 files changed, 296 insertions(+), 1 deletion(-) create mode 100644 ereuse_devicehub/templates/inventory/erasure_list.html diff --git a/ereuse_devicehub/inventory/views.py b/ereuse_devicehub/inventory/views.py index 4e480537..67e1f0ee 100644 --- a/ereuse_devicehub/inventory/views.py +++ b/ereuse_devicehub/inventory/views.py @@ -36,7 +36,7 @@ from ereuse_devicehub.inventory.forms import ( ) from ereuse_devicehub.labels.forms import PrintLabelsForm from ereuse_devicehub.parser.models import PlaceholdersLog, SnapshotsLog -from ereuse_devicehub.resources.action.models import Trade +from ereuse_devicehub.resources.action.models import EraseBasic, Trade from ereuse_devicehub.resources.device.models import ( Computer, DataStorage, @@ -112,6 +112,25 @@ class DeviceListMixin(GenericMixin): return [] +class ErasureListView(DeviceListMixin): + template_name = 'inventory/erasure_list.html' + + def dispatch_request(self): + self.get_context() + self.get_devices() + return flask.render_template(self.template_name, **self.context) + + def get_devices(self): + erasure = EraseBasic.query.filter_by(author=g.user) + # ids = [ac.device.id for ac in actions] + # devices = Device.query.filter(Device.owner_id == g.user.id).filter( + # Device.id.in_(ids) + # # Device.binding == None # noqa: E711 + # ) + # self.context['devices'] = devices + self.context['erasure'] = erasure + + class DeviceListView(DeviceListMixin): def dispatch_request(self, lot_id=None): self.get_context(lot_id) @@ -1324,3 +1343,6 @@ devices.add_url_rule( '/device//binding/', view_func=BindingSearchView.as_view('binding_search'), ) +devices.add_url_rule( + '/device/erasure/', view_func=ErasureListView.as_view('device_erasure_list') +) diff --git a/ereuse_devicehub/templates/ereuse_devicehub/base_site.html b/ereuse_devicehub/templates/ereuse_devicehub/base_site.html index b52bab2a..6fdf1129 100644 --- a/ereuse_devicehub/templates/ereuse_devicehub/base_site.html +++ b/ereuse_devicehub/templates/ereuse_devicehub/base_site.html @@ -256,6 +256,14 @@ + + + +