mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-26 17:26:10 -06:00
#12255 fix init
This commit is contained in:
parent
700ee1237f
commit
268f894c20
@ -82,6 +82,12 @@ class ComponentTemplateModel(WebhooksMixin, ChangeLoggedModel):
|
|||||||
"""
|
"""
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
super().__init__(*args, **kwargs)
|
||||||
|
|
||||||
|
# Cache the original DeviceType ID for reference under clean()
|
||||||
|
self._original_device_type = self.device_type_id
|
||||||
|
|
||||||
def to_objectchange(self, action):
|
def to_objectchange(self, action):
|
||||||
objectchange = super().to_objectchange(action)
|
objectchange = super().to_objectchange(action)
|
||||||
objectchange.related_object = self.device_type
|
objectchange.related_object = self.device_type
|
||||||
@ -90,7 +96,7 @@ class ComponentTemplateModel(WebhooksMixin, ChangeLoggedModel):
|
|||||||
def clean(self):
|
def clean(self):
|
||||||
super().clean()
|
super().clean()
|
||||||
|
|
||||||
if (not self._can_switch_device) and (self.pk is not None) and (self._original_device != self.device_id):
|
if (not self._can_switch_device) and (self.pk is not None) and (self._original_device_type != self.device_type_id):
|
||||||
raise ValidationError({
|
raise ValidationError({
|
||||||
"device_type": "Component templates cannot be moved to a different device type."
|
"device_type": "Component templates cannot be moved to a different device type."
|
||||||
})
|
})
|
||||||
@ -129,12 +135,6 @@ class ModularComponentTemplateModel(ComponentTemplateModel):
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
|
||||||
super().__init__(*args, **kwargs)
|
|
||||||
|
|
||||||
# Cache the original DeviceType ID for reference under clean()
|
|
||||||
self._original_device_type = self.device_type_id
|
|
||||||
|
|
||||||
def to_objectchange(self, action):
|
def to_objectchange(self, action):
|
||||||
objectchange = super().to_objectchange(action)
|
objectchange = super().to_objectchange(action)
|
||||||
if self.device_type is not None:
|
if self.device_type is not None:
|
||||||
|
Loading…
Reference in New Issue
Block a user