Add generic relations for Prefix

This commit is contained in:
Jeremy Stretch 2024-10-09 14:17:50 -04:00
parent fad3457d36
commit b241428c00

View File

@ -28,6 +28,12 @@ class Region(ContactsMixin, NestedGroupModel):
states, and/or cities. Regions are recursively nested into a hierarchy: all sites belonging to a child region are states, and/or cities. Regions are recursively nested into a hierarchy: all sites belonging to a child region are
also considered to be members of its parent and ancestor region(s). also considered to be members of its parent and ancestor region(s).
""" """
prefixes = GenericRelation(
to='ipam.Prefix',
content_type_field='scope_type',
object_id_field='scope_id',
related_query_name='region'
)
vlan_groups = GenericRelation( vlan_groups = GenericRelation(
to='ipam.VLANGroup', to='ipam.VLANGroup',
content_type_field='scope_type', content_type_field='scope_type',
@ -78,6 +84,12 @@ class SiteGroup(ContactsMixin, NestedGroupModel):
within corporate sites you might distinguish between offices and data centers. Like regions, site groups can be within corporate sites you might distinguish between offices and data centers. Like regions, site groups can be
nested recursively to form a hierarchy. nested recursively to form a hierarchy.
""" """
prefixes = GenericRelation(
to='ipam.Prefix',
content_type_field='scope_type',
object_id_field='scope_id',
related_query_name='site_group'
)
vlan_groups = GenericRelation( vlan_groups = GenericRelation(
to='ipam.VLANGroup', to='ipam.VLANGroup',
content_type_field='scope_type', content_type_field='scope_type',
@ -214,6 +226,12 @@ class Site(ContactsMixin, ImageAttachmentsMixin, PrimaryModel):
) )
# Generic relations # Generic relations
prefixes = GenericRelation(
to='ipam.Prefix',
content_type_field='scope_type',
object_id_field='scope_id',
related_query_name='site'
)
vlan_groups = GenericRelation( vlan_groups = GenericRelation(
to='ipam.VLANGroup', to='ipam.VLANGroup',
content_type_field='scope_type', content_type_field='scope_type',
@ -273,6 +291,12 @@ class Location(ContactsMixin, ImageAttachmentsMixin, NestedGroupModel):
) )
# Generic relations # Generic relations
prefixes = GenericRelation(
to='ipam.Prefix',
content_type_field='scope_type',
object_id_field='scope_id',
related_query_name='location'
)
vlan_groups = GenericRelation( vlan_groups = GenericRelation(
to='ipam.VLANGroup', to='ipam.VLANGroup',
content_type_field='scope_type', content_type_field='scope_type',