diff --git a/ereuse_devicehub/resources/action/models.py b/ereuse_devicehub/resources/action/models.py index 20128497..30be54c8 100644 --- a/ereuse_devicehub/resources/action/models.py +++ b/ereuse_devicehub/resources/action/models.py @@ -563,6 +563,27 @@ class EraseDataWipe(EraseBasic): def get_public_name(self): return "EraseDataWipe" + def __format__(self, format_spec: str) -> str: + v = '' + if 't' in format_spec: + v += '{} {}.'.format(self.type, self.severity) + if 's' in format_spec: + if not self.document: + v += 'On {}'.format(self.date_str) + return v + software = self.document.software or '' + url = self.document.url or '' + v += 'Software: {}, {}. '.format(software, url) + v += 'On {}'.format(self.date_str) + return v + + @property + def date_str(self): + day = self.created + if self.document: + day = self.document.date or self.end_time or self.created + return '{:%c}'.format(day) + class Step(db.Model): erasure_id = Column( diff --git a/ereuse_devicehub/resources/documents/device_row.py b/ereuse_devicehub/resources/documents/device_row.py index ba165e0b..aac1f56a 100644 --- a/ereuse_devicehub/resources/documents/device_row.py +++ b/ereuse_devicehub/resources/documents/device_row.py @@ -429,11 +429,14 @@ class DeviceRow(BaseDeviceRow): self['{} {} Size (MB)'.format(ctype, i)] = none2str(component.size) - component_actions = sorted(component.actions, key=lambda x: x.created) + component_actions = [ac for ac in component.actions] + if component.binding: + component_actions.extend(component.binding.device.actions) + component_actions = sorted(component_actions, key=lambda x: x.created) erasures = [ a for a in component_actions - if a.type in ['EraseBasic', 'EraseSectors', 'DataWipe'] + if a.type in ['EraseBasic', 'EraseSectors', 'DataWipe', 'EraseDataWipe'] ] erasure = erasures[-1] if erasures else None if not erasure: @@ -441,7 +444,7 @@ class DeviceRow(BaseDeviceRow): serial_number = none2str(component.serial_number) self['Erasure {} {} Serial Number'.format(ctype, i)] = serial_number self['Erasure {} {} Size (MB)'.format(ctype, i)] = none2str(component.size) - elif hasattr(erasure, 'type') and erasure.type == 'DataWipe': + elif hasattr(erasure, 'type') and erasure.type in ['DataWipe', 'EraseDataWipe']: self['Erasure {} {}'.format(ctype, i)] = none2str(component.chid) serial_number = none2str(component.serial_number) self['Erasure {} {} Serial Number'.format(ctype, i)] = serial_number diff --git a/ereuse_devicehub/templates/inventory/erasure.html b/ereuse_devicehub/templates/inventory/erasure.html index 854d9a19..5674ae9c 100644 --- a/ereuse_devicehub/templates/inventory/erasure.html +++ b/ereuse_devicehub/templates/inventory/erasure.html @@ -348,7 +348,7 @@
{% if loop.index == 1 %}
-

Tenchnical Details

+

Technical Details

{% endif %}

{{ (erasure.device.serial_number or '').upper() }}

@@ -378,11 +378,6 @@ {% endif %} - {% if erasure.type == 'EraseDataWipe' %} -
-
Software:
-
{{ erasure.document and erasure.document.software or ''}}
- {% endif %} {% if erasure.device.proofs %}
DLT Proofs: