diff --git a/ereuse_devicehub/inventory/views.py b/ereuse_devicehub/inventory/views.py index 4e480537..73e3badc 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,21 @@ 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).order_by( + EraseBasic.created.desc() + ) + self.context['erasure'] = erasure + + class DeviceListView(DeviceListMixin): def dispatch_request(self, lot_id=None): self.get_context(lot_id) @@ -1324,3 +1339,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 @@ + + + +