Merge pull request #451 from eReuse/bugfix/4381

Bugfix/4381
This commit is contained in:
cayop 2023-05-30 13:10:32 +02:00 committed by GitHub
commit e4017cf5cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 9 deletions

View File

@ -563,6 +563,27 @@ class EraseDataWipe(EraseBasic):
def get_public_name(self): def get_public_name(self):
return "EraseDataWipe" 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): class Step(db.Model):
erasure_id = Column( erasure_id = Column(

View File

@ -429,11 +429,14 @@ class DeviceRow(BaseDeviceRow):
self['{} {} Size (MB)'.format(ctype, i)] = none2str(component.size) 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 = [ erasures = [
a a
for a in component_actions 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 erasure = erasures[-1] if erasures else None
if not erasure: if not erasure:
@ -441,7 +444,7 @@ class DeviceRow(BaseDeviceRow):
serial_number = none2str(component.serial_number) serial_number = none2str(component.serial_number)
self['Erasure {} {} Serial Number'.format(ctype, i)] = serial_number self['Erasure {} {} Serial Number'.format(ctype, i)] = serial_number
self['Erasure {} {} Size (MB)'.format(ctype, i)] = none2str(component.size) 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) self['Erasure {} {}'.format(ctype, i)] = none2str(component.chid)
serial_number = none2str(component.serial_number) serial_number = none2str(component.serial_number)
self['Erasure {} {} Serial Number'.format(ctype, i)] = serial_number self['Erasure {} {} Serial Number'.format(ctype, i)] = serial_number

View File

@ -348,7 +348,7 @@
<div class="container mb-5 page-break"> <div class="container mb-5 page-break">
{% if loop.index == 1 %} {% if loop.index == 1 %}
<div class="col-12" style="margin-bottom: 20px;"> <div class="col-12" style="margin-bottom: 20px;">
<h3>Tenchnical Details</h3> <h3>Technical Details</h3>
</div> </div>
{% endif %} {% endif %}
<h4>{{ (erasure.device.serial_number or '').upper() }}</h4> <h4>{{ (erasure.device.serial_number or '').upper() }}</h4>
@ -378,11 +378,6 @@
</ol> </ol>
</dd> </dd>
{% endif %} {% endif %}
{% if erasure.type == 'EraseDataWipe' %}
<br />
<dt>Software:</dt>
<dd>{{ erasure.document and erasure.document.software or ''}}</dd>
{% endif %}
{% if erasure.device.proofs %} {% if erasure.device.proofs %}
<dt>DLT Proofs:</dt> <dt>DLT Proofs:</dt>
<dd> <dd>