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
1 changed files with 16 additions and 0 deletions

View File

@ -29,6 +29,7 @@ from wtforms import (
)
from wtforms.fields import FormField
from ereuse_devicehub import messages
from ereuse_devicehub.db import db
from ereuse_devicehub.inventory.models import (
DeliveryNote,
@ -1092,6 +1093,21 @@ class DataWipeDocumentForm(Form):
class DataWipeForm(ActionFormMixin):
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):
self.document.form.save(commit=False)