mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-24 00:15:17 -06:00
13757 use self.__dict to access vars in init
This commit is contained in:
parent
382a592aaa
commit
ad7ba0ed3f
@ -98,10 +98,10 @@ class Cable(PrimaryModel):
|
|||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
|
|
||||||
# A copy of the PK to be used by __str__ in case the object is deleted
|
# A copy of the PK to be used by __str__ in case the object is deleted
|
||||||
self._pk = self.pk
|
self._pk = self.__dict__.get('id')
|
||||||
|
|
||||||
# Cache the original status so we can check later if it's been changed
|
# Cache the original status so we can check later if it's been changed
|
||||||
self._orig_status = self.status
|
self._orig_status = self.__dict__.get('status')
|
||||||
|
|
||||||
self._terminations_modified = False
|
self._terminations_modified = False
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ class ComponentTemplateModel(ChangeLoggedModel, TrackingModelMixin):
|
|||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
|
|
||||||
# Cache the original DeviceType ID for reference under clean()
|
# Cache the original DeviceType ID for reference under clean()
|
||||||
self._original_device_type = self.device_type_id
|
self._original_device_type = self.__dict__.get('device_type_id')
|
||||||
|
|
||||||
def to_objectchange(self, action):
|
def to_objectchange(self, action):
|
||||||
objectchange = super().to_objectchange(action)
|
objectchange = super().to_objectchange(action)
|
||||||
|
@ -86,7 +86,7 @@ class ComponentModel(NetBoxModel):
|
|||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
|
|
||||||
# Cache the original Device ID for reference under clean()
|
# Cache the original Device ID for reference under clean()
|
||||||
self._original_device = self.device_id
|
self._original_device = self.__dict__.get('device_id')
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
if self.label:
|
if self.label:
|
||||||
|
@ -205,11 +205,11 @@ class DeviceType(ImageAttachmentsMixin, PrimaryModel, WeightMixin):
|
|||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
|
|
||||||
# Save a copy of u_height for validation in clean()
|
# Save a copy of u_height for validation in clean()
|
||||||
self._original_u_height = self.u_height
|
self._original_u_height = self.__dict__.get('u_height')
|
||||||
|
|
||||||
# Save references to the original front/rear images
|
# Save references to the original front/rear images
|
||||||
self._original_front_image = self.front_image
|
self._original_front_image = self.__dict__.get('front_image')
|
||||||
self._original_rear_image = self.rear_image
|
self._original_rear_image = self.__dict__.get('rear_image')
|
||||||
|
|
||||||
def get_absolute_url(self):
|
def get_absolute_url(self):
|
||||||
return reverse('dcim:devicetype', args=[self.pk])
|
return reverse('dcim:devicetype', args=[self.pk])
|
||||||
|
@ -219,7 +219,7 @@ class CustomField(CloningMixin, ExportTemplatesMixin, ChangeLoggedModel):
|
|||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
|
|
||||||
# Cache instance's original name so we can check later whether it has changed
|
# Cache instance's original name so we can check later whether it has changed
|
||||||
self._name = self.name
|
self._name = self.__dict__.get('name')
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def search_type(self):
|
def search_type(self):
|
||||||
|
@ -467,11 +467,7 @@ class TagBulkDeleteView(generic.BulkDeleteView):
|
|||||||
#
|
#
|
||||||
|
|
||||||
class ConfigContextListView(generic.ObjectListView):
|
class ConfigContextListView(generic.ObjectListView):
|
||||||
queryset = ConfigContext.objects.all().prefetch_related(
|
queryset = ConfigContext.objects.all()
|
||||||
'regions', 'site_groups', 'sites', 'locations', 'device_types',
|
|
||||||
'roles', 'platforms', 'cluster_types', 'cluster_groups', 'clusters',
|
|
||||||
'tenant_groups', 'tenants', 'tags',
|
|
||||||
)
|
|
||||||
filterset = filtersets.ConfigContextFilterSet
|
filterset = filtersets.ConfigContextFilterSet
|
||||||
filterset_form = forms.ConfigContextFilterForm
|
filterset_form = forms.ConfigContextFilterForm
|
||||||
table = tables.ConfigContextTable
|
table = tables.ConfigContextTable
|
||||||
@ -519,20 +515,12 @@ class ConfigContextView(generic.ObjectView):
|
|||||||
|
|
||||||
@register_model_view(ConfigContext, 'edit')
|
@register_model_view(ConfigContext, 'edit')
|
||||||
class ConfigContextEditView(generic.ObjectEditView):
|
class ConfigContextEditView(generic.ObjectEditView):
|
||||||
queryset = ConfigContext.objects.all().prefetch_related(
|
queryset = ConfigContext.objects.all()
|
||||||
'regions', 'site_groups', 'sites', 'locations', 'device_types',
|
|
||||||
'roles', 'platforms', 'cluster_types', 'cluster_groups', 'clusters',
|
|
||||||
'tenant_groups', 'tenants', 'tags',
|
|
||||||
)
|
|
||||||
form = forms.ConfigContextForm
|
form = forms.ConfigContextForm
|
||||||
|
|
||||||
|
|
||||||
class ConfigContextBulkEditView(generic.BulkEditView):
|
class ConfigContextBulkEditView(generic.BulkEditView):
|
||||||
queryset = ConfigContext.objects.all().prefetch_related(
|
queryset = ConfigContext.objects.all()
|
||||||
'regions', 'site_groups', 'sites', 'locations', 'device_types',
|
|
||||||
'roles', 'platforms', 'cluster_types', 'cluster_groups', 'clusters',
|
|
||||||
'tenant_groups', 'tenants', 'tags',
|
|
||||||
)
|
|
||||||
filterset = filtersets.ConfigContextFilterSet
|
filterset = filtersets.ConfigContextFilterSet
|
||||||
table = tables.ConfigContextTable
|
table = tables.ConfigContextTable
|
||||||
form = forms.ConfigContextBulkEditForm
|
form = forms.ConfigContextBulkEditForm
|
||||||
|
@ -290,8 +290,8 @@ class Prefix(GetAvailablePrefixesMixin, PrimaryModel):
|
|||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
|
|
||||||
# Cache the original prefix and VRF so we can check if they have changed on post_save
|
# Cache the original prefix and VRF so we can check if they have changed on post_save
|
||||||
self._prefix = self.prefix
|
self._prefix = self.__dict__.get('prefix')
|
||||||
self._vrf_id = self.vrf_id
|
self._vrf_id = self.__dict__.get('vrf_id')
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return str(self.prefix)
|
return str(self.prefix)
|
||||||
|
Loading…
Reference in New Issue
Block a user