mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-25 18:08:38 -06:00
Deprecate get_for_id() on ObjectTypeManager
This commit is contained in:
parent
944ea00a86
commit
b31f185f42
@ -40,6 +40,7 @@ class ObjectTypeManager(models.Manager):
|
||||
"""
|
||||
return self.get(app_label=app_label, model=model)
|
||||
|
||||
# TODO: Remove in NetBox v4.5
|
||||
def get_for_id(self, id):
|
||||
"""
|
||||
Retrieve an ObjectType by its primary key (numeric ID).
|
||||
|
@ -1,6 +1,7 @@
|
||||
import itertools
|
||||
|
||||
from django.contrib.contenttypes.fields import GenericForeignKey
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.db import models
|
||||
from django.dispatch import Signal
|
||||
@ -479,13 +480,13 @@ class CablePath(models.Model):
|
||||
def origin_type(self):
|
||||
if self.path:
|
||||
ct_id, _ = decompile_path_node(self.path[0][0])
|
||||
return ObjectType.objects.get_for_id(ct_id)
|
||||
return ContentType.objects.get_for_id(ct_id)
|
||||
|
||||
@property
|
||||
def destination_type(self):
|
||||
if self.is_complete:
|
||||
ct_id, _ = decompile_path_node(self.path[-1][0])
|
||||
return ObjectType.objects.get_for_id(ct_id)
|
||||
return ContentType.objects.get_for_id(ct_id)
|
||||
|
||||
@property
|
||||
def _path_decompiled(self):
|
||||
|
@ -4,6 +4,7 @@ import yaml
|
||||
from functools import cached_property
|
||||
|
||||
from django.contrib.contenttypes.fields import GenericForeignKey, GenericRelation
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.core.files.storage import default_storage
|
||||
from django.core.validators import MaxValueValidator, MinValueValidator
|
||||
@ -15,7 +16,6 @@ from django.urls import reverse
|
||||
from django.utils.safestring import mark_safe
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from core.models import ObjectType
|
||||
from dcim.choices import *
|
||||
from dcim.constants import *
|
||||
from dcim.fields import MACAddressField
|
||||
@ -1328,7 +1328,7 @@ class MACAddress(PrimaryModel):
|
||||
super().clean()
|
||||
if self._original_assigned_object_id and self._original_assigned_object_type_id:
|
||||
assigned_object = self.assigned_object
|
||||
ct = ObjectType.objects.get_for_id(self._original_assigned_object_type_id)
|
||||
ct = ContentType.objects.get_for_id(self._original_assigned_object_type_id)
|
||||
original_assigned_object = ct.get_object_for_this_type(pk=self._original_assigned_object_id)
|
||||
|
||||
if (
|
||||
|
@ -1,5 +1,6 @@
|
||||
import netaddr
|
||||
from django.contrib.contenttypes.fields import GenericForeignKey
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.db import models
|
||||
from django.db.models import F
|
||||
@ -7,7 +8,6 @@ from django.db.models.functions import Cast
|
||||
from django.utils.functional import cached_property
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from core.models import ObjectType
|
||||
from dcim.models.mixins import CachedScopeMixin
|
||||
from ipam.choices import *
|
||||
from ipam.constants import *
|
||||
@ -917,7 +917,7 @@ class IPAddress(ContactsMixin, PrimaryModel):
|
||||
|
||||
if self._original_assigned_object_id and self._original_assigned_object_type_id:
|
||||
parent = getattr(self.assigned_object, 'parent_object', None)
|
||||
ct = ObjectType.objects.get_for_id(self._original_assigned_object_type_id)
|
||||
ct = ContentType.objects.get_for_id(self._original_assigned_object_type_id)
|
||||
original_assigned_object = ct.get_object_for_this_type(pk=self._original_assigned_object_id)
|
||||
original_parent = getattr(original_assigned_object, 'parent_object', None)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user