allow edit only phid on abstrac devices
This commit is contained in:
parent
5d81db5b8c
commit
ded8a23075
|
@ -414,6 +414,34 @@ class NewDeviceForm(FlaskForm):
|
|||
self.resolution.data = self._obj.resolution_width
|
||||
self.screen.data = self._obj.size
|
||||
|
||||
if self._obj.placeholder.is_abstract:
|
||||
self.type.render_kw = disabled
|
||||
self.amount.render_kw = disabled
|
||||
self.id_device_supplier.render_kw = disabled
|
||||
self.pallet.render_kw = disabled
|
||||
self.info.render_kw = disabled
|
||||
self.serial_number.render_kw = disabled
|
||||
self.model.render_kw = disabled
|
||||
self.manufacturer.render_kw = disabled
|
||||
self.appearance.render_kw = disabled
|
||||
self.functionality.render_kw = disabled
|
||||
self.brand.render_kw = disabled
|
||||
self.generation.render_kw = disabled
|
||||
self.version.render_kw = disabled
|
||||
self.weight.render_kw = disabled
|
||||
self.width.render_kw = disabled
|
||||
self.height.render_kw = disabled
|
||||
self.depth.render_kw = disabled
|
||||
self.variant.render_kw = disabled
|
||||
self.sku.render_kw = disabled
|
||||
self.image.render_kw = disabled
|
||||
if self._obj.type in ['Smartphone', 'Tablet', 'Cellphone']:
|
||||
self.imei.render_kw = disabled
|
||||
self.meid.render_kw = disabled
|
||||
if self._obj.type == 'ComputerMonitor':
|
||||
self.resolution.render_kw = disabled
|
||||
self.screen.render_kw = disabled
|
||||
|
||||
def validate(self, extra_validators=None): # noqa: C901
|
||||
error = ["Not a correct value"]
|
||||
is_valid = super().validate(extra_validators)
|
||||
|
@ -575,10 +603,12 @@ class NewDeviceForm(FlaskForm):
|
|||
|
||||
def edit_device(self):
|
||||
self._obj.placeholder.phid = self.phid.data or self._obj.placeholder.phid
|
||||
self._obj.placeholder.id_device_supplier = self.id_device_supplier.data or None
|
||||
if not self._obj.placeholder.is_abstract:
|
||||
self._obj.placeholder.id_device_supplier = (
|
||||
self.id_device_supplier.data or None
|
||||
)
|
||||
self._obj.placeholder.info = self.info.data or None
|
||||
self._obj.placeholder.pallet = self.pallet.data or None
|
||||
self._obj.placeholder.is_abstract = False
|
||||
self._obj.model = self.model.data
|
||||
self._obj.manufacturer = self.manufacturer.data
|
||||
self._obj.serial_number = self.serial_number.data
|
||||
|
@ -601,7 +631,10 @@ class NewDeviceForm(FlaskForm):
|
|||
self._obj.imei = self.imei.data
|
||||
self._obj.meid = self.meid.data
|
||||
|
||||
if self.appearance.data and self.appearance.data != self._obj.appearance().name:
|
||||
if (
|
||||
self.appearance.data
|
||||
and self.appearance.data != self._obj.appearance().name
|
||||
):
|
||||
self._obj.set_appearance(self.appearance.data)
|
||||
|
||||
if (
|
||||
|
@ -609,6 +642,7 @@ class NewDeviceForm(FlaskForm):
|
|||
and self.functionality.data != self._obj.functionality().name
|
||||
):
|
||||
self._obj.set_functionality(self.functionality.data)
|
||||
|
||||
placeholder_log = PlaceholdersLog(
|
||||
type="Update", source='Web form', placeholder=self._obj.placeholder
|
||||
)
|
||||
|
|
Reference in New Issue