From 7638a6dab4d9e164b145293839cb76390800c09a Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Wed, 14 Jun 2023 10:17:01 +0200 Subject: [PATCH] not datawipe for placeholders computers --- ereuse_devicehub/inventory/forms.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/ereuse_devicehub/inventory/forms.py b/ereuse_devicehub/inventory/forms.py index 4cab06c5..f9b10aa2 100644 --- a/ereuse_devicehub/inventory/forms.py +++ b/ereuse_devicehub/inventory/forms.py @@ -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)