Merge pull request #458 from eReuse/bugfix/erasure-placeholders

not datawipe for placeholders computers
This commit is contained in:
cayop 2023-06-14 10:43:18 +02:00 committed by GitHub
commit e0f986f4fe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -29,6 +29,7 @@ from wtforms import (
) )
from wtforms.fields import FormField from wtforms.fields import FormField
from ereuse_devicehub import messages
from ereuse_devicehub.db import db from ereuse_devicehub.db import db
from ereuse_devicehub.inventory.models import ( from ereuse_devicehub.inventory.models import (
DeliveryNote, DeliveryNote,
@ -1092,6 +1093,21 @@ class DataWipeDocumentForm(Form):
class DataWipeForm(ActionFormMixin): class DataWipeForm(ActionFormMixin):
document = FormField(DataWipeDocumentForm) document = FormField(DataWipeDocumentForm)
def validate(self, extra_validators=None):
is_valid = super().validate(extra_validators)
if not is_valid:
return False
txt = "Error: Only Data Sanitization actions are "
txt += "allowed on Placeholders that are of the Data Storage type."
for dev in self._devices:
if dev.is_abstract() == 'Placeholder':
if not (isinstance(dev, DataStorage) or isinstance(dev, Mobile)):
messages.error(txt)
return False
return is_valid
def save(self): def save(self):
self.document.form.save(commit=False) self.document.form.save(commit=False)