1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Rename ContactAssignment.content_type to object_type

This commit is contained in:
Jeremy Stretch
2024-03-01 16:54:01 -05:00
parent e0165539b3
commit 5f43eabab1
12 changed files with 74 additions and 32 deletions

View File

@@ -111,13 +111,13 @@ class Contact(PrimaryModel):
class ContactAssignment(CustomFieldsMixin, ExportTemplatesMixin, TagsMixin, ChangeLoggedModel):
content_type = models.ForeignKey(
object_type = models.ForeignKey(
to='contenttypes.ContentType',
on_delete=models.CASCADE
)
object_id = models.PositiveBigIntegerField()
object = GenericForeignKey(
ct_field='content_type',
ct_field='object_type',
fk_field='object_id'
)
contact = models.ForeignKey(
@@ -137,16 +137,16 @@ class ContactAssignment(CustomFieldsMixin, ExportTemplatesMixin, TagsMixin, Chan
blank=True
)
clone_fields = ('content_type', 'object_id', 'role', 'priority')
clone_fields = ('object_type', 'object_id', 'role', 'priority')
class Meta:
ordering = ('contact', 'priority', 'role', 'pk')
indexes = (
models.Index(fields=('content_type', 'object_id')),
models.Index(fields=('object_type', 'object_id')),
)
constraints = (
models.UniqueConstraint(
fields=('content_type', 'object_id', 'contact', 'role'),
fields=('object_type', 'object_id', 'contact', 'role'),
name='%(app_label)s_%(class)s_unique_object_contact_role'
),
)
@@ -165,9 +165,9 @@ class ContactAssignment(CustomFieldsMixin, ExportTemplatesMixin, TagsMixin, Chan
super().clean()
# Validate the assigned object type
if self.content_type not in ObjectType.objects.with_feature('contacts'):
if self.object_type not in ObjectType.objects.with_feature('contacts'):
raise ValidationError(
_("Contacts cannot be assigned to this object type ({type}).").format(type=self.content_type)
_("Contacts cannot be assigned to this object type ({type}).").format(type=self.object_type)
)
def to_objectchange(self, action):