From 4d3ab6a70c25ef262a803f2b29716fd14e24a5b2 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Tue, 20 Sep 2022 13:31:21 +0200 Subject: [PATCH] fix phid --- ereuse_devicehub/resources/action/models.py | 6 ++++++ ereuse_devicehub/templates/inventory/erasure_list.html | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ereuse_devicehub/resources/action/models.py b/ereuse_devicehub/resources/action/models.py index c0876598..9cf2ce54 100644 --- a/ereuse_devicehub/resources/action/models.py +++ b/ereuse_devicehub/resources/action/models.py @@ -475,6 +475,12 @@ class EraseBasic(JoinedWithOneDeviceMixin, ActionWithOneDevice): # todo will this url_for_resource work for other resources? return urlutils.URL(url_for_resource('Document', item_id=self.id)) + def get_phid(self): + if self.device and self.device.parent: + if hasattr(self.device.parent, 'phid'): + return self.device.parent.phid() + return '' + def __str__(self) -> str: return '{} on {}.'.format(self.severity, self.date_str) diff --git a/ereuse_devicehub/templates/inventory/erasure_list.html b/ereuse_devicehub/templates/inventory/erasure_list.html index 555b29e0..6495d2d6 100644 --- a/ereuse_devicehub/templates/inventory/erasure_list.html +++ b/ereuse_devicehub/templates/inventory/erasure_list.html @@ -84,7 +84,7 @@ - {{ ac.device.parent.phid() }} + {{ ac.get_phid() }}