From 44985d07a1f0ba6634744b406224b03f8fb2c8dd Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Wed, 26 Oct 2022 11:26:09 +0200 Subject: [PATCH] add dhid as column in erasure section --- ereuse_devicehub/inventory/views.py | 2 ++ ereuse_devicehub/resources/lot/views.py | 9 ++++++++- ereuse_devicehub/templates/inventory/erasure_list.html | 10 ++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/ereuse_devicehub/inventory/views.py b/ereuse_devicehub/inventory/views.py index 567196eb..7d1bbc86 100644 --- a/ereuse_devicehub/inventory/views.py +++ b/ereuse_devicehub/inventory/views.py @@ -939,6 +939,7 @@ class ExportsView(View): cw.writerow( [ 'Data Storage Serial', + 'DHID', 'Snapshot ID', 'Type of Erasure', 'PHID Erasure Host', @@ -958,6 +959,7 @@ class ExportsView(View): for ac in query: row = [ ac.device.serial_number.upper(), + ac.device.dhid, ac.snapshot.uuid, ac.type, ac.get_phid(), diff --git a/ereuse_devicehub/resources/lot/views.py b/ereuse_devicehub/resources/lot/views.py index 0f0752ab..c3416db2 100644 --- a/ereuse_devicehub/resources/lot/views.py +++ b/ereuse_devicehub/resources/lot/views.py @@ -16,7 +16,7 @@ from ereuse_devicehub.db import db from ereuse_devicehub.inventory.models import Transfer from ereuse_devicehub.query import things_response from ereuse_devicehub.resources.action.models import Confirm, Revoke, Trade -from ereuse_devicehub.resources.device.models import Computer, Device +from ereuse_devicehub.resources.device.models import Computer, DataStorage, Device from ereuse_devicehub.resources.lot.models import Lot, Path @@ -302,6 +302,13 @@ class LotDeviceView(LotBaseChildrenView): devices = set( Device.query.filter(Device.id.in_(ids)).filter(Device.owner == g.user) ) + devices = set() + dev_qry = Device.query.filter(Device.id.in_(ids)).filter(Device.owner == g.user) + + for dev in dev_qry: + if isinstance(dev, DataStorage) and dev.parent: + continue + devices.add(dev) lot.devices.update(devices) diff --git a/ereuse_devicehub/templates/inventory/erasure_list.html b/ereuse_devicehub/templates/inventory/erasure_list.html index 57f91b75..e33bed45 100644 --- a/ereuse_devicehub/templates/inventory/erasure_list.html +++ b/ereuse_devicehub/templates/inventory/erasure_list.html @@ -49,6 +49,7 @@ Select Data Storage Serial + DHID Snapshot ID Type of Erasure PHID Erasure Host @@ -78,6 +79,15 @@ {% else %} {{ ac.device.serial_number.upper() }} {% endif %} + + + {% if ac.device.phid() %} + + {{ ac.device.dhid }} + + {% else %} + {{ ac.device.dhid }} + {% endif %}