13757 use self.__dict to access vars in init

This commit is contained in:
Arthur 2023-09-18 12:57:02 -07:00
parent 382a592aaa
commit ad7ba0ed3f
7 changed files with 13 additions and 25 deletions

View File

@ -98,10 +98,10 @@ class Cable(PrimaryModel):
super().__init__(*args, **kwargs)
# 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
self._orig_status = self.status
self._orig_status = self.__dict__.get('status')
self._terminations_modified = False

View File

@ -89,7 +89,7 @@ class ComponentTemplateModel(ChangeLoggedModel, TrackingModelMixin):
super().__init__(*args, **kwargs)
# 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):
objectchange = super().to_objectchange(action)

View File

@ -86,7 +86,7 @@ class ComponentModel(NetBoxModel):
super().__init__(*args, **kwargs)
# 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):
if self.label:

View File

@ -205,11 +205,11 @@ class DeviceType(ImageAttachmentsMixin, PrimaryModel, WeightMixin):
super().__init__(*args, **kwargs)
# 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
self._original_front_image = self.front_image
self._original_rear_image = self.rear_image
self._original_front_image = self.__dict__.get('front_image')
self._original_rear_image = self.__dict__.get('rear_image')
def get_absolute_url(self):
return reverse('dcim:devicetype', args=[self.pk])

View File

@ -219,7 +219,7 @@ class CustomField(CloningMixin, ExportTemplatesMixin, ChangeLoggedModel):
super().__init__(*args, **kwargs)
# 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
def search_type(self):

View File

@ -467,11 +467,7 @@ class TagBulkDeleteView(generic.BulkDeleteView):
#
class ConfigContextListView(generic.ObjectListView):
queryset = ConfigContext.objects.all().prefetch_related(
'regions', 'site_groups', 'sites', 'locations', 'device_types',
'roles', 'platforms', 'cluster_types', 'cluster_groups', 'clusters',
'tenant_groups', 'tenants', 'tags',
)
queryset = ConfigContext.objects.all()
filterset = filtersets.ConfigContextFilterSet
filterset_form = forms.ConfigContextFilterForm
table = tables.ConfigContextTable
@ -519,20 +515,12 @@ class ConfigContextView(generic.ObjectView):
@register_model_view(ConfigContext, 'edit')
class ConfigContextEditView(generic.ObjectEditView):
queryset = ConfigContext.objects.all().prefetch_related(
'regions', 'site_groups', 'sites', 'locations', 'device_types',
'roles', 'platforms', 'cluster_types', 'cluster_groups', 'clusters',
'tenant_groups', 'tenants', 'tags',
)
queryset = ConfigContext.objects.all()
form = forms.ConfigContextForm
class ConfigContextBulkEditView(generic.BulkEditView):
queryset = ConfigContext.objects.all().prefetch_related(
'regions', 'site_groups', 'sites', 'locations', 'device_types',
'roles', 'platforms', 'cluster_types', 'cluster_groups', 'clusters',
'tenant_groups', 'tenants', 'tags',
)
queryset = ConfigContext.objects.all()
filterset = filtersets.ConfigContextFilterSet
table = tables.ConfigContextTable
form = forms.ConfigContextBulkEditForm

View File

@ -290,8 +290,8 @@ class Prefix(GetAvailablePrefixesMixin, PrimaryModel):
super().__init__(*args, **kwargs)
# Cache the original prefix and VRF so we can check if they have changed on post_save
self._prefix = self.prefix
self._vrf_id = self.vrf_id
self._prefix = self.__dict__.get('prefix')
self._vrf_id = self.__dict__.get('vrf_id')
def __str__(self):
return str(self.prefix)