change certificate pdf
This commit is contained in:
parent
5eea698695
commit
631bfa2774
|
@ -1074,6 +1074,8 @@ class DataWipeForm(ActionFormMixin):
|
|||
Model = db.Model._decl_class_registry.data[self.type.data]()
|
||||
self.instance = Model()
|
||||
devices = self.devices.data
|
||||
if not self.document.success.data:
|
||||
self.severity.data = Severity.Error.name
|
||||
severity = self.severity.data
|
||||
self.devices.data = self._devices
|
||||
self.severity.data = Severity[self.severity.data]
|
||||
|
|
|
@ -1192,11 +1192,12 @@ class ExportsView(View):
|
|||
if device.placeholder and device.placeholder.binding:
|
||||
device = device.placeholder.binding
|
||||
if isinstance(device, Computer):
|
||||
for privacy in device.privacy:
|
||||
erasures.append(privacy)
|
||||
for ac in device.last_erase_action:
|
||||
erasures.append(ac)
|
||||
elif isinstance(device, DataStorage):
|
||||
if device.privacy:
|
||||
erasures.append(device.privacy)
|
||||
ac = device.last_erase_action
|
||||
if ac:
|
||||
erasures.append(ac)
|
||||
return erasures
|
||||
|
||||
def get_costum_details(self, erasures):
|
||||
|
@ -1264,9 +1265,14 @@ class ExportsView(View):
|
|||
erasures_host, erasures_on_server = a, b
|
||||
erasures_host = set(erasures_host)
|
||||
|
||||
result = 'Success'
|
||||
if "Failed" in [e.severity.get_public_name() for e in erasures]:
|
||||
result = 'Failed'
|
||||
result_success = 0
|
||||
result_failed = 0
|
||||
for e in erasures:
|
||||
result = e.severity.get_public_name()
|
||||
if "Failed" == result:
|
||||
result_failed += 1
|
||||
if "Success" == result:
|
||||
result_success += 1
|
||||
|
||||
erasures = sorted(erasures, key=lambda x: x.end_time)
|
||||
erasures_on_server = sorted(erasures_on_server, key=lambda x: x.end_time)
|
||||
|
@ -1283,7 +1289,8 @@ class ExportsView(View):
|
|||
'software': software,
|
||||
'my_data': my_data,
|
||||
'n_computers': n_computers,
|
||||
'result': result,
|
||||
'result_success': result_success,
|
||||
'result_failed': result_failed,
|
||||
'customer_details': customer_details,
|
||||
'erasure_hosts': erasures_host,
|
||||
'erasures_normal': erasures_normal,
|
||||
|
|
|
@ -246,6 +246,11 @@ class DataWipeDef(ActionDef):
|
|||
SCHEMA = schemas.DataWipe
|
||||
|
||||
|
||||
class EraseDataWipe(ActionDef):
|
||||
VIEW = None
|
||||
SCHEMA = schemas.EraseDataWipe
|
||||
|
||||
|
||||
class AllocateDef(ActionDef):
|
||||
VIEW = AllocateView
|
||||
SCHEMA = schemas.Allocate
|
||||
|
|
|
@ -483,6 +483,8 @@ class EraseBasic(JoinedWithOneDeviceMixin, ActionWithOneDevice):
|
|||
"""
|
||||
if self.snapshot:
|
||||
return self.snapshot.device.phid()
|
||||
if self.parent:
|
||||
return self.parent.phid()
|
||||
return ''
|
||||
|
||||
def get_public_name(self):
|
||||
|
|
|
@ -45,8 +45,8 @@ from ereuse_devicehub.resources.tradedocument import schemas as s_document
|
|||
from ereuse_devicehub.resources.tradedocument.models import TradeDocument
|
||||
from ereuse_devicehub.resources.user import schemas as s_user
|
||||
from ereuse_devicehub.resources.user.models import User
|
||||
from ereuse_devicehub.teal.enums import Country, Currency, Subdivision
|
||||
from ereuse_devicehub.teal.marshmallow import IP, URL, EnumField, SanitizedStr, Version
|
||||
from ereuse_devicehub.teal.enums import Currency
|
||||
from ereuse_devicehub.teal.marshmallow import URL, EnumField, SanitizedStr, Version
|
||||
from ereuse_devicehub.teal.resource import Schema
|
||||
|
||||
|
||||
|
@ -588,6 +588,11 @@ class DataWipe(ActionWithMultipleDevicesCheckingOwner):
|
|||
document = NestedOn(s_generic_document.DataWipeDocument, only_query='id')
|
||||
|
||||
|
||||
class EraseDataWipe(ActionWithMultipleDevicesCheckingOwner):
|
||||
__doc__ = m.DataWipe.__doc__
|
||||
document = NestedOn(s_generic_document.DataWipeDocument, only_query='id')
|
||||
|
||||
|
||||
class Live(ActionWithOneDevice):
|
||||
__doc__ = m.Live.__doc__
|
||||
"""
|
||||
|
@ -808,12 +813,12 @@ class Trade(ActionWithMultipleDevices):
|
|||
|
||||
@pre_load
|
||||
def adding_devices(self, data: dict):
|
||||
if not 'devices' in data.keys():
|
||||
if 'devices' not in data.keys():
|
||||
data['devices'] = []
|
||||
|
||||
@validates_schema
|
||||
def validate_lot(self, data: dict):
|
||||
if not g.user.email in [data['user_from_email'], data['user_to_email']]:
|
||||
if g.user.email not in [data['user_from_email'], data['user_to_email']]:
|
||||
txt = "you need to be one of the users of involved in the Trade"
|
||||
raise ValidationError(txt)
|
||||
|
||||
|
@ -879,7 +884,7 @@ class Trade(ActionWithMultipleDevices):
|
|||
txt = "you need one user for to do a trade"
|
||||
raise ValidationError(txt)
|
||||
|
||||
if not g.user.email in [user_from, user_to]:
|
||||
if g.user.email not in [user_from, user_to]:
|
||||
txt = "you need to be one of participate of the action"
|
||||
raise ValidationError(txt)
|
||||
|
||||
|
|
|
@ -1355,6 +1355,22 @@ class Computer(Device):
|
|||
if privacy
|
||||
)
|
||||
|
||||
@property
|
||||
def last_erase_action(self):
|
||||
components = self.components
|
||||
if self.placeholder and self.placeholder.binding:
|
||||
components = self.placeholder.binding.components
|
||||
|
||||
return set(
|
||||
ac
|
||||
for ac in (
|
||||
hdd.last_erase_action
|
||||
for hdd in components
|
||||
if isinstance(hdd, DataStorage)
|
||||
)
|
||||
if ac
|
||||
)
|
||||
|
||||
@property
|
||||
def external_document_erasure(self):
|
||||
"""Returns the external ``DataStorage`` proof of erasure."""
|
||||
|
@ -1568,12 +1584,40 @@ class DataStorage(JoinedComponentTableMixin, Component):
|
|||
ev = None
|
||||
return ev
|
||||
|
||||
@property
|
||||
def last_erase_action(self):
|
||||
erase_auto = None
|
||||
erase_manual = None
|
||||
|
||||
if self.binding:
|
||||
erase_auto = self.privacy
|
||||
erase_manual = self.binding.device.privacy
|
||||
if self.placeholder:
|
||||
erase_manual = self.privacy
|
||||
if self.placeholder.binding:
|
||||
erase_auto = self.placeholder.binding.privacy
|
||||
|
||||
if erase_auto and erase_manual:
|
||||
return (
|
||||
erase_auto
|
||||
if erase_auto.created > erase_manual.created
|
||||
else erase_manual
|
||||
)
|
||||
if erase_manual:
|
||||
return erase_manual
|
||||
if erase_auto:
|
||||
return erase_auto
|
||||
return None
|
||||
|
||||
def __format__(self, format_spec):
|
||||
v = super().__format__(format_spec)
|
||||
if 's' in format_spec:
|
||||
v += ' – {} GB'.format(self.size // 1000 if self.size else '?')
|
||||
return v
|
||||
|
||||
def get_size(self):
|
||||
return '{} GB'.format(self.size // 1000 if self.size else '?')
|
||||
|
||||
@property
|
||||
def external_document_erasure(self):
|
||||
"""Returns the external ``DataStorage`` proof of erasure."""
|
||||
|
|
|
@ -66,91 +66,108 @@
|
|||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<header class="page-header">
|
||||
<div class="col" style="background-color: #d5a6bd;">
|
||||
<p style="margin-left: 10px;">{{ date_report }}, {{ software }}</p>
|
||||
</div>
|
||||
</header>
|
||||
<div class="container">
|
||||
<header class="page-header">
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
<img class="company-logo" src="{{ customer_details and customer_details.logo.to_text() or '' }}" />
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<img class="customer-logo" src="{{ my_data and my_data.logo.to_text() }}" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="container body-content">
|
||||
<div class="row mt-3">
|
||||
<div class="col">
|
||||
<h1>Data Sanitization Certificate</h1>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mt-3">
|
||||
<div class="col-12">
|
||||
<strong>Entity Information</strong>
|
||||
<div class="col" style="background-color: #d5a6bd;">
|
||||
<p style="margin-left: 10px;">{{ date_report }}, {{ software }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div class="container body-content">
|
||||
<div class="row mt-3">
|
||||
<div class="col-12">
|
||||
<table class="body_content">
|
||||
<tbody>
|
||||
<tr style="padding-top:5px;">
|
||||
<td style="width:20%;">
|
||||
Name:
|
||||
</td>
|
||||
<tr>
|
||||
<td style="width:80%;">
|
||||
<span>{{ customer_details and customer_details.company_name or ''}}</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr style="padding-top:5px;">
|
||||
<td style="width:20%;">
|
||||
Location:
|
||||
</td>
|
||||
<td style="width:80%;">
|
||||
<span>{{ customer_details and customer_details.location or '' }}</span>
|
||||
<table class="body_content">
|
||||
<tbody>
|
||||
<tr style="padding-top:5px;">
|
||||
<td colspan="2">
|
||||
<strong>Responsible Sanitization Entity</strong>
|
||||
</td>
|
||||
</tr>
|
||||
<tr style="padding-top:5px;">
|
||||
<td style="width:20%;">
|
||||
<span>Name:</span>
|
||||
</td>
|
||||
<td style="width:80%;">
|
||||
<span>{{ my_data and my_data.company_name or '' }}</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr style="padding-top:5px;">
|
||||
<td style="width:20%;">
|
||||
<span>Responsible Person</span>
|
||||
</td>
|
||||
<td style="width:80%;">
|
||||
<span>{{ my_data and my_data.responsable_person or '' }}</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr style="padding-top:5px;">
|
||||
<td style="width:20%;">
|
||||
<span>Location:</span>
|
||||
</td>
|
||||
<td style="width:80%;">
|
||||
<span>{{ my_data and my_data.location or '' }}</span>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
<td style="width:20%;">
|
||||
<img style="width: 100%; height: auto;" src="{{ my_data and my_data.logo.to_text() }}" />
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row" style="padding-top: 20px;">
|
||||
<div class="col-12">
|
||||
<strong>Responsible Sanitization Entity</strong>
|
||||
</div>
|
||||
<div class="col-12">
|
||||
<table class="body_content">
|
||||
<tbody>
|
||||
<tr style="padding-top:5px;">
|
||||
<td style="width:20%;">
|
||||
<span>Name:</span>
|
||||
</td>
|
||||
<tr>
|
||||
<td style="width:80%;">
|
||||
<span>{{ my_data and my_data.company_name or '' }}</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr style="padding-top:5px;">
|
||||
<td style="width:20%;">
|
||||
<span>Responsible Person</span>
|
||||
</td>
|
||||
<td style="width:80%;">
|
||||
<span>{{ my_data and my_data.responsable_person or '' }}</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr style="padding-top:5px;">
|
||||
<td style="width:20%;">
|
||||
<span>Location:</span>
|
||||
</td>
|
||||
<td style="width:80%;">
|
||||
<span>{{ my_data and my_data.location or '' }}</span>
|
||||
<table class="body_content">
|
||||
<tbody>
|
||||
<tr style="padding-top:5px;">
|
||||
<td colspan="2">
|
||||
<strong>Entity Information</strong>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="width:20%;">
|
||||
<span>Name: </span>
|
||||
</td>
|
||||
<td style="width:80%;">
|
||||
<span>{{ customer_details and customer_details.company_name or ''}}</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="width:20%;">
|
||||
<span>Location: </span>
|
||||
</td>
|
||||
<td style="width:80%;">
|
||||
<span>{{ customer_details and customer_details.location or '' }}</span>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</td>
|
||||
<td style="width:20%;">
|
||||
<img style="width: 100%; height: auto;" src="{{ customer_details and customer_details.logo.to_text() or '' }}" />
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="row" style="padding-top: 20px;">
|
||||
<div class="col-12">
|
||||
<strong>Summary</strong>
|
||||
|
@ -158,6 +175,16 @@
|
|||
<div class="col-12">
|
||||
<table class="body_content">
|
||||
<tbody>
|
||||
{% if customer_details and customer_details.transfer %}
|
||||
<tr style="padding-top:5px;">
|
||||
<td style="width:20%;">
|
||||
<span>Code Transfer:</span>
|
||||
</td>
|
||||
<td style="width:80%;">
|
||||
<span>{{ customer_details.transfer.code or '' }}</span>
|
||||
</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% if erasure_hosts %}
|
||||
<tr style="padding-top:5px;">
|
||||
<td style="width:20%;">
|
||||
|
@ -166,7 +193,7 @@
|
|||
<td style="width:80%;">
|
||||
{% for e in erasure_hosts %}
|
||||
{% if e.serial_number %}
|
||||
<span>{{ e.serial_number.upper() }}</span>{% if not loop.last %},{% endif %}
|
||||
<span>{{ (e.serial_number or '').upper() }}</span>{% if not loop.last %},{% endif %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</td>
|
||||
|
@ -192,10 +219,18 @@
|
|||
</tr>
|
||||
<tr style="padding-top:5px;">
|
||||
<td style="width:20%;">
|
||||
<span>Sanitization result:</span>
|
||||
<span>N° result Success:</span>
|
||||
</td>
|
||||
<td style="width:80%;">
|
||||
<span>{{ result }}</span>
|
||||
<span>{{ result_success }}</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr style="padding-top:5px;">
|
||||
<td style="width:20%;">
|
||||
<span>N° result Failed:</span>
|
||||
</td>
|
||||
<td style="width:80%;">
|
||||
<span>{{ result_failed }}</span>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
@ -288,10 +323,10 @@
|
|||
{% for erasure in erasures %}
|
||||
<tr style="border-bottom: 1px dashed #000;">
|
||||
<td>
|
||||
{{ erasure.device.serial_number and erasure.device.serial_number.upper() or '' }}
|
||||
{{ (erasure.device.serial_number or '').upper() }}
|
||||
</td>
|
||||
<td>
|
||||
{{ erasure.parent.serial_number and erasure.parent.serial_number.upper() or '' }}
|
||||
{{ (erasure.parent.serial_number or '').upper() }}
|
||||
</td>
|
||||
<td>
|
||||
{{ erasure.get_public_name() }}
|
||||
|
@ -311,39 +346,43 @@
|
|||
</div>
|
||||
{% for erasure in erasures %}
|
||||
<div class="container mb-5 page-break">
|
||||
<h4>{{ erasure.device.serial_number.upper() }}</h4>
|
||||
<dl>
|
||||
<dt>Data storage:</dt>
|
||||
<dd>{{ erasure.device.__format__('ts') }}</dd>
|
||||
|
||||
{% if erasure.parent %}
|
||||
<dt>Computer where was erase:</dt>
|
||||
<dd>Title: {{ erasure.parent.__format__('ts') }}</dd>
|
||||
<dd>DevicehubID: {{ erasure.parent.dhid }}</dd>
|
||||
<dd>Hid: {{ erasure.parent.chid }}</dd>
|
||||
<dd>Tags: {{ erasure.parent.tags }}</dd>
|
||||
|
||||
{% if erasure.device.parent %}
|
||||
<dt>Computer where it resides:</dt>
|
||||
<dd>Title: {{ erasure.device.parent.__format__('ts') }}</dd>
|
||||
<dd>DevicehubID: {{ erasure.device.parent.dhid }}</dd>
|
||||
<dd>Hid: {{ erasure.device.parent.chid }}</dd>
|
||||
<dd>Tags: {{ erasure.device.parent.tags }}</dd>
|
||||
{% endif %}
|
||||
{% if loop.index == 1 %}
|
||||
<div class="col-12" style="margin-bottom: 20px;">
|
||||
<h3>Tenchnical Details</h3>
|
||||
</div>
|
||||
{% endif %}
|
||||
<h4>{{ (erasure.device.serial_number or '').upper() }}</h4>
|
||||
<dl>
|
||||
<dt>Storage Drive:</dt>
|
||||
<dd>Model: {{ erasure.device.model }}</dd>
|
||||
<dd>SN: {{ (erasure.device.serial_number or '').upper() }}</dd>
|
||||
<dd>Size: {{ erasure.device.get_size()}}</dd>
|
||||
{% if erasure.parent %}
|
||||
<br />
|
||||
<dt>Computer Host:</dt>
|
||||
<dd>Model: {{ erasure.parent.model }}</dd>
|
||||
<dd>SN: {{ (erasure.parent.serial_number or '').upper() }}</dd>
|
||||
<dd>DHID: {{ erasure.parent.dhid }}</dd>
|
||||
{% endif %}
|
||||
|
||||
<br />
|
||||
<dt>Erasure:</dt>
|
||||
<dd>{{ erasure.__format__('ts') }}</dd>
|
||||
{% if erasure.steps %}
|
||||
<dt>Erasure steps:</dt>
|
||||
<dd>
|
||||
<ol>
|
||||
{% for step in erasure.steps %}
|
||||
<li>{{ step.__format__('') }}</li>
|
||||
{% endfor %}
|
||||
</ol>
|
||||
</dd>
|
||||
{% endif %}
|
||||
<dd>
|
||||
<ol>
|
||||
{% for step in erasure.steps %}
|
||||
<li>{{ step.__format__('') }}</li>
|
||||
{% endfor %}
|
||||
</ol>
|
||||
</dd>
|
||||
{% endif %}
|
||||
{% if erasure.type == 'EraseDataWipe' %}
|
||||
<br />
|
||||
<dt>Software:</dt>
|
||||
<dd>{{ erasure.document and erasure.document.software or ''}}</dd>
|
||||
{% endif %}
|
||||
{% if erasure.device.proofs %}
|
||||
<dt>DLT Proofs:</dt>
|
||||
<dd>
|
||||
|
|
Reference in New Issue