mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-29 20:06:25 -06:00
Add generic relations for group assignments
This commit is contained in:
parent
ac68339e4f
commit
8b81522164
@ -1,8 +1,7 @@
|
|||||||
from django.apps import apps
|
from django.apps import apps
|
||||||
from django.contrib.contenttypes.fields import GenericForeignKey
|
from django.contrib.contenttypes.fields import GenericForeignKey, GenericRelation
|
||||||
from django.core.exceptions import ValidationError
|
from django.core.exceptions import ValidationError
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.db.models import Q
|
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
@ -117,6 +116,13 @@ class Circuit(ContactsMixin, ImageAttachmentsMixin, DistanceMixin, PrimaryModel)
|
|||||||
null=True
|
null=True
|
||||||
)
|
)
|
||||||
|
|
||||||
|
group_assignments = GenericRelation(
|
||||||
|
to='circuits.CircuitGroupAssignment',
|
||||||
|
content_type_field='member_type',
|
||||||
|
object_id_field='member_id',
|
||||||
|
related_query_name='circuit'
|
||||||
|
)
|
||||||
|
|
||||||
clone_fields = (
|
clone_fields = (
|
||||||
'provider', 'provider_account', 'type', 'status', 'tenant', 'install_date', 'termination_date', 'commit_rate',
|
'provider', 'provider_account', 'type', 'status', 'tenant', 'install_date', 'termination_date', 'commit_rate',
|
||||||
'description',
|
'description',
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
from functools import cached_property
|
from functools import cached_property
|
||||||
|
|
||||||
|
from django.contrib.contenttypes.fields import GenericRelation
|
||||||
from django.core.exceptions import ValidationError
|
from django.core.exceptions import ValidationError
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
@ -50,6 +51,13 @@ class VirtualCircuit(PrimaryModel):
|
|||||||
null=True
|
null=True
|
||||||
)
|
)
|
||||||
|
|
||||||
|
group_assignments = GenericRelation(
|
||||||
|
to='circuits.CircuitGroupAssignment',
|
||||||
|
content_type_field='member_type',
|
||||||
|
object_id_field='member_id',
|
||||||
|
related_query_name='virtual_circuit'
|
||||||
|
)
|
||||||
|
|
||||||
clone_fields = (
|
clone_fields = (
|
||||||
'provider_network', 'provider_account', 'status', 'tenant', 'description',
|
'provider_network', 'provider_account', 'status', 'tenant', 'description',
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user