not datawipe for placeholders computers

This commit is contained in:
Cayo Puigdefabregas 2023-06-14 10:17:01 +02:00
parent c27040296d
commit 7638a6dab4
1 changed files with 16 additions and 0 deletions

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)