adjust model name to IPAddressFunctionAssignments

This commit is contained in:
Jamie Murphy 2023-07-06 21:51:45 +01:00
parent 557c7d5f2e
commit 603f021465
5 changed files with 30 additions and 6 deletions

View File

@ -646,7 +646,7 @@ class Device(PrimaryModel, ConfigContextModel):
to='extras.ImageAttachment' to='extras.ImageAttachment'
) )
ipaddressfunctions = GenericRelation( ipaddressfunctions = GenericRelation(
to='ipam.IPAddressFunction' to='ipam.IPAddressFunctionAssignments'
) )
objects = ConfigContextModelQuerySet.as_manager() objects = ConfigContextModelQuerySet.as_manager()
@ -1236,7 +1236,7 @@ class VirtualDeviceContext(PrimaryModel):
# Generic relation # Generic relation
ipaddressfunctions = GenericRelation( ipaddressfunctions = GenericRelation(
to='ipam.IPAddressFunction' to='ipam.IPAddressFunctionAssignments'
) )
class Meta: class Meta:

View File

@ -0,0 +1,23 @@
# Generated by Django 4.1.9 on 2023-07-06 20:51
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('extras', '0092_delete_jobresult'),
('contenttypes', '0002_remove_content_type_name'),
('ipam', '0067_ipaddressfunction_and_more'),
]
operations = [
migrations.RenameModel(
old_name='IPAddressFunction',
new_name='IPAddressFunctionAssignments',
),
migrations.AlterModelOptions(
name='ipaddressfunctionassignments',
options={'ordering': ('function',), 'verbose_name': 'IP Address Function Assignments'},
),
]

View File

@ -12,6 +12,7 @@ __all__ = (
'ASNRange', 'ASNRange',
'Aggregate', 'Aggregate',
'IPAddress', 'IPAddress',
'IPAddressFunctionAssignments',
'IPRange', 'IPRange',
'FHRPGroup', 'FHRPGroup',
'FHRPGroupAssignment', 'FHRPGroupAssignment',

View File

@ -20,7 +20,7 @@ from netbox.models import OrganizationalModel, PrimaryModel, NetBoxModel
__all__ = ( __all__ = (
'Aggregate', 'Aggregate',
'IPAddress', 'IPAddress',
'IPAddressFunction', 'IPAddressFunctionAssignments',
'IPRange', 'IPRange',
'Prefix', 'Prefix',
'RIR', 'RIR',
@ -668,7 +668,7 @@ class IPRange(PrimaryModel):
return int(float(child_count) / self.size * 100) return int(float(child_count) / self.size * 100)
class IPAddressFunction(NetBoxModel): class IPAddressFunctionAssignments(NetBoxModel):
assigned_object_type = models.ForeignKey( assigned_object_type = models.ForeignKey(
to=ContentType, to=ContentType,
limit_choices_to=IPADDRESS_FUNCTION_ASSIGNMENT_MODELS, limit_choices_to=IPADDRESS_FUNCTION_ASSIGNMENT_MODELS,
@ -694,7 +694,7 @@ class IPAddressFunction(NetBoxModel):
class Meta: class Meta:
ordering = ('function',) ordering = ('function',)
verbose_name = 'IP Address Function' verbose_name = 'IP Address Function Assignments'
constraints = ( constraints = (
models.UniqueConstraint( models.UniqueConstraint(
fields=('assigned_object_type', 'assigned_object_id', 'function'), fields=('assigned_object_type', 'assigned_object_id', 'function'),

View File

@ -125,7 +125,7 @@ class VirtualMachine(PrimaryModel, ConfigContextModel):
to='tenancy.ContactAssignment' to='tenancy.ContactAssignment'
) )
ipaddressfunctions = GenericRelation( ipaddressfunctions = GenericRelation(
to='ipam.IPAddressFunction' to='ipam.IPAddressFunctionAssignments'
) )
objects = ConfigContextModelQuerySet.as_manager() objects = ConfigContextModelQuerySet.as_manager()