mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-14 01:41:22 -06:00
Merge pull request #19070 from netbox-community/17166-remove-limit_choices_to
Closes #17166: Remove obsolete `limit_choices_to` argument from ForeignKey & M2M fields
This commit is contained in:
commit
3902cab925
@ -39,9 +39,6 @@ class Migration(migrations.Migration):
|
||||
name='termination_type',
|
||||
field=models.ForeignKey(
|
||||
blank=True,
|
||||
limit_choices_to=models.Q(
|
||||
('model__in', ('region', 'sitegroup', 'site', 'location', 'providernetwork'))
|
||||
),
|
||||
null=True,
|
||||
on_delete=django.db.models.deletion.PROTECT,
|
||||
related_name='+',
|
||||
|
@ -51,7 +51,6 @@ class Migration(migrations.Migration):
|
||||
name='member_type',
|
||||
field=models.ForeignKey(
|
||||
on_delete=django.db.models.deletion.PROTECT,
|
||||
limit_choices_to=models.Q(('app_label', 'circuits'), ('model__in', ['circuit', 'virtualcircuit'])),
|
||||
related_name='+',
|
||||
to='contenttypes.contenttype',
|
||||
blank=True,
|
||||
@ -68,7 +67,6 @@ class Migration(migrations.Migration):
|
||||
model_name='circuitgroupassignment',
|
||||
name='member_type',
|
||||
field=models.ForeignKey(
|
||||
limit_choices_to=models.Q(('app_label', 'circuits'), ('model__in', ['circuit', 'virtualcircuit'])),
|
||||
on_delete=django.db.models.deletion.PROTECT,
|
||||
related_name='+',
|
||||
to='contenttypes.contenttype'
|
||||
|
@ -182,7 +182,6 @@ class CircuitGroupAssignment(CustomFieldsMixin, ExportTemplatesMixin, TagsMixin,
|
||||
"""
|
||||
member_type = models.ForeignKey(
|
||||
to='contenttypes.ContentType',
|
||||
limit_choices_to=CIRCUIT_GROUP_ASSIGNMENT_MEMBER_MODELS,
|
||||
on_delete=models.PROTECT,
|
||||
related_name='+'
|
||||
)
|
||||
@ -249,7 +248,6 @@ class CircuitTermination(
|
||||
termination_type = models.ForeignKey(
|
||||
to='contenttypes.ContentType',
|
||||
on_delete=models.PROTECT,
|
||||
limit_choices_to=Q(model__in=CIRCUIT_TERMINATION_TERMINATION_TYPES),
|
||||
related_name='+',
|
||||
blank=True,
|
||||
null=True
|
||||
|
@ -505,28 +505,6 @@ class Migration(migrations.Migration):
|
||||
model_name='cable',
|
||||
name='termination_a_type',
|
||||
field=models.ForeignKey(
|
||||
limit_choices_to=models.Q(
|
||||
models.Q(
|
||||
models.Q(('app_label', 'circuits'), ('model__in', ('circuittermination',))),
|
||||
models.Q(
|
||||
('app_label', 'dcim'),
|
||||
(
|
||||
'model__in',
|
||||
(
|
||||
'consoleport',
|
||||
'consoleserverport',
|
||||
'frontport',
|
||||
'interface',
|
||||
'powerfeed',
|
||||
'poweroutlet',
|
||||
'powerport',
|
||||
'rearport',
|
||||
),
|
||||
),
|
||||
),
|
||||
_connector='OR',
|
||||
)
|
||||
),
|
||||
on_delete=django.db.models.deletion.PROTECT,
|
||||
related_name='+',
|
||||
to='contenttypes.contenttype',
|
||||
@ -536,28 +514,6 @@ class Migration(migrations.Migration):
|
||||
model_name='cable',
|
||||
name='termination_b_type',
|
||||
field=models.ForeignKey(
|
||||
limit_choices_to=models.Q(
|
||||
models.Q(
|
||||
models.Q(('app_label', 'circuits'), ('model__in', ('circuittermination',))),
|
||||
models.Q(
|
||||
('app_label', 'dcim'),
|
||||
(
|
||||
'model__in',
|
||||
(
|
||||
'consoleport',
|
||||
'consoleserverport',
|
||||
'frontport',
|
||||
'interface',
|
||||
'powerfeed',
|
||||
'poweroutlet',
|
||||
'powerport',
|
||||
'rearport',
|
||||
),
|
||||
),
|
||||
),
|
||||
_connector='OR',
|
||||
)
|
||||
),
|
||||
on_delete=django.db.models.deletion.PROTECT,
|
||||
related_name='+',
|
||||
to='contenttypes.contenttype',
|
||||
|
@ -866,21 +866,6 @@ class Migration(migrations.Migration):
|
||||
name='component_type',
|
||||
field=models.ForeignKey(
|
||||
blank=True,
|
||||
limit_choices_to=models.Q(
|
||||
('app_label', 'dcim'),
|
||||
(
|
||||
'model__in',
|
||||
(
|
||||
'consoleport',
|
||||
'consoleserverport',
|
||||
'frontport',
|
||||
'interface',
|
||||
'poweroutlet',
|
||||
'powerport',
|
||||
'rearport',
|
||||
),
|
||||
),
|
||||
),
|
||||
null=True,
|
||||
on_delete=django.db.models.deletion.PROTECT,
|
||||
related_name='+',
|
||||
@ -1238,21 +1223,6 @@ class Migration(migrations.Migration):
|
||||
'component_type',
|
||||
models.ForeignKey(
|
||||
blank=True,
|
||||
limit_choices_to=models.Q(
|
||||
('app_label', 'dcim'),
|
||||
(
|
||||
'model__in',
|
||||
(
|
||||
'consoleporttemplate',
|
||||
'consoleserverporttemplate',
|
||||
'frontporttemplate',
|
||||
'interfacetemplate',
|
||||
'poweroutlettemplate',
|
||||
'powerporttemplate',
|
||||
'rearporttemplate',
|
||||
),
|
||||
),
|
||||
),
|
||||
null=True,
|
||||
on_delete=django.db.models.deletion.PROTECT,
|
||||
related_name='+',
|
||||
@ -1478,28 +1448,6 @@ class Migration(migrations.Migration):
|
||||
(
|
||||
'termination_type',
|
||||
models.ForeignKey(
|
||||
limit_choices_to=models.Q(
|
||||
models.Q(
|
||||
models.Q(('app_label', 'circuits'), ('model__in', ('circuittermination',))),
|
||||
models.Q(
|
||||
('app_label', 'dcim'),
|
||||
(
|
||||
'model__in',
|
||||
(
|
||||
'consoleport',
|
||||
'consoleserverport',
|
||||
'frontport',
|
||||
'interface',
|
||||
'powerfeed',
|
||||
'poweroutlet',
|
||||
'powerport',
|
||||
'rearport',
|
||||
),
|
||||
),
|
||||
),
|
||||
_connector='OR',
|
||||
)
|
||||
),
|
||||
on_delete=django.db.models.deletion.PROTECT,
|
||||
related_name='+',
|
||||
to='contenttypes.contenttype',
|
||||
|
@ -31,13 +31,6 @@ class Migration(migrations.Migration):
|
||||
'assigned_object_type',
|
||||
models.ForeignKey(
|
||||
blank=True,
|
||||
limit_choices_to=models.Q(
|
||||
models.Q(
|
||||
models.Q(('app_label', 'dcim'), ('model', 'interface')),
|
||||
models.Q(('app_label', 'virtualization'), ('model', 'vminterface')),
|
||||
_connector='OR',
|
||||
)
|
||||
),
|
||||
null=True,
|
||||
on_delete=django.db.models.deletion.PROTECT,
|
||||
related_name='+',
|
||||
|
@ -259,7 +259,6 @@ class CableTermination(ChangeLoggedModel):
|
||||
)
|
||||
termination_type = models.ForeignKey(
|
||||
to='contenttypes.ContentType',
|
||||
limit_choices_to=CABLE_TERMINATION_MODELS,
|
||||
on_delete=models.PROTECT,
|
||||
related_name='+'
|
||||
)
|
||||
|
@ -751,7 +751,6 @@ class InventoryItemTemplate(MPTTModel, ComponentTemplateModel):
|
||||
)
|
||||
component_type = models.ForeignKey(
|
||||
to='contenttypes.ContentType',
|
||||
limit_choices_to=MODULAR_COMPONENT_TEMPLATE_MODELS,
|
||||
on_delete=models.PROTECT,
|
||||
related_name='+',
|
||||
blank=True,
|
||||
|
@ -1274,7 +1274,6 @@ class InventoryItem(MPTTModel, ComponentModel, TrackingModelMixin):
|
||||
)
|
||||
component_type = models.ForeignKey(
|
||||
to='contenttypes.ContentType',
|
||||
limit_choices_to=MODULAR_COMPONENT_MODELS,
|
||||
on_delete=models.PROTECT,
|
||||
related_name='+',
|
||||
blank=True,
|
||||
|
@ -1225,7 +1225,6 @@ class MACAddress(PrimaryModel):
|
||||
)
|
||||
assigned_object_type = models.ForeignKey(
|
||||
to='contenttypes.ContentType',
|
||||
limit_choices_to=MACADDRESS_ASSIGNMENT_MODELS,
|
||||
on_delete=models.PROTECT,
|
||||
related_name='+',
|
||||
blank=True,
|
||||
|
@ -3,7 +3,6 @@ from django.contrib.contenttypes.fields import GenericForeignKey
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.db import models
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from dcim.constants import LOCATION_SCOPE_TYPES
|
||||
|
||||
__all__ = (
|
||||
'CachedScopeMixin',
|
||||
@ -44,7 +43,6 @@ class CachedScopeMixin(models.Model):
|
||||
scope_type = models.ForeignKey(
|
||||
to='contenttypes.ContentType',
|
||||
on_delete=models.PROTECT,
|
||||
limit_choices_to=models.Q(model__in=LOCATION_SCOPE_TYPES),
|
||||
related_name='+',
|
||||
blank=True,
|
||||
null=True
|
||||
|
@ -195,12 +195,6 @@ class Migration(migrations.Migration):
|
||||
'scope_type',
|
||||
models.ForeignKey(
|
||||
blank=True,
|
||||
limit_choices_to=models.Q(
|
||||
(
|
||||
'model__in',
|
||||
('region', 'sitegroup', 'site', 'location', 'rack', 'clustergroup', 'cluster'),
|
||||
)
|
||||
),
|
||||
null=True,
|
||||
on_delete=django.db.models.deletion.CASCADE,
|
||||
to='contenttypes.contenttype',
|
||||
|
@ -154,13 +154,6 @@ class Migration(migrations.Migration):
|
||||
name='assigned_object_type',
|
||||
field=models.ForeignKey(
|
||||
blank=True,
|
||||
limit_choices_to=models.Q(
|
||||
models.Q(
|
||||
models.Q(('app_label', 'dcim'), ('model', 'interface')),
|
||||
models.Q(('app_label', 'virtualization'), ('model', 'vminterface')),
|
||||
_connector='OR',
|
||||
)
|
||||
),
|
||||
null=True,
|
||||
on_delete=django.db.models.deletion.PROTECT,
|
||||
related_name='+',
|
||||
|
@ -136,14 +136,6 @@ class Migration(migrations.Migration):
|
||||
name='assigned_object_type',
|
||||
field=models.ForeignKey(
|
||||
blank=True,
|
||||
limit_choices_to=models.Q(
|
||||
models.Q(
|
||||
models.Q(('app_label', 'dcim'), ('model', 'interface')),
|
||||
models.Q(('app_label', 'ipam'), ('model', 'fhrpgroup')),
|
||||
models.Q(('app_label', 'virtualization'), ('model', 'vminterface')),
|
||||
_connector='OR',
|
||||
)
|
||||
),
|
||||
null=True,
|
||||
on_delete=django.db.models.deletion.PROTECT,
|
||||
related_name='+',
|
||||
|
@ -304,14 +304,6 @@ class Migration(migrations.Migration):
|
||||
(
|
||||
'assigned_object_type',
|
||||
models.ForeignKey(
|
||||
limit_choices_to=models.Q(
|
||||
models.Q(
|
||||
models.Q(('app_label', 'dcim'), ('model', 'interface')),
|
||||
models.Q(('app_label', 'ipam'), ('model', 'vlan')),
|
||||
models.Q(('app_label', 'virtualization'), ('model', 'vminterface')),
|
||||
_connector='OR',
|
||||
)
|
||||
),
|
||||
on_delete=django.db.models.deletion.PROTECT,
|
||||
related_name='+',
|
||||
to='contenttypes.contenttype',
|
||||
|
@ -33,7 +33,6 @@ class Migration(migrations.Migration):
|
||||
name='scope_type',
|
||||
field=models.ForeignKey(
|
||||
blank=True,
|
||||
limit_choices_to=models.Q(('model__in', ('region', 'sitegroup', 'site', 'location'))),
|
||||
null=True,
|
||||
on_delete=django.db.models.deletion.PROTECT,
|
||||
related_name='+',
|
||||
|
@ -742,7 +742,6 @@ class IPAddress(ContactsMixin, PrimaryModel):
|
||||
)
|
||||
assigned_object_type = models.ForeignKey(
|
||||
to='contenttypes.ContentType',
|
||||
limit_choices_to=IPADDRESS_ASSIGNMENT_MODELS,
|
||||
on_delete=models.PROTECT,
|
||||
related_name='+',
|
||||
blank=True,
|
||||
|
@ -45,7 +45,6 @@ class VLANGroup(OrganizationalModel):
|
||||
scope_type = models.ForeignKey(
|
||||
to='contenttypes.ContentType',
|
||||
on_delete=models.CASCADE,
|
||||
limit_choices_to=Q(model__in=VLANGROUP_SCOPE_TYPES),
|
||||
blank=True,
|
||||
null=True
|
||||
)
|
||||
|
@ -132,20 +132,6 @@ class Migration(migrations.Migration):
|
||||
(
|
||||
'object_types',
|
||||
models.ManyToManyField(
|
||||
limit_choices_to=models.Q(
|
||||
models.Q(
|
||||
models.Q(
|
||||
(
|
||||
'app_label__in',
|
||||
['account', 'admin', 'auth', 'contenttypes', 'sessions', 'taggit', 'users'],
|
||||
),
|
||||
_negated=True,
|
||||
),
|
||||
models.Q(('app_label', 'auth'), ('model__in', ['group', 'user'])),
|
||||
models.Q(('app_label', 'users'), ('model__in', ['objectpermission', 'token'])),
|
||||
_connector='OR',
|
||||
)
|
||||
),
|
||||
related_name='object_permissions',
|
||||
to='contenttypes.ContentType',
|
||||
),
|
||||
|
@ -13,23 +13,6 @@ class Migration(migrations.Migration):
|
||||
migrations.AlterField(
|
||||
model_name='objectpermission',
|
||||
name='object_types',
|
||||
field=models.ManyToManyField(
|
||||
limit_choices_to=models.Q(
|
||||
models.Q(
|
||||
models.Q(
|
||||
(
|
||||
'app_label__in',
|
||||
['account', 'admin', 'auth', 'contenttypes', 'sessions', 'taggit', 'users'],
|
||||
),
|
||||
_negated=True,
|
||||
),
|
||||
models.Q(('app_label', 'auth'), ('model__in', ['group', 'user'])),
|
||||
models.Q(('app_label', 'users'), ('model__in', ['objectpermission', 'token'])),
|
||||
_connector='OR',
|
||||
)
|
||||
),
|
||||
related_name='object_permissions',
|
||||
to='core.objecttype',
|
||||
),
|
||||
field=models.ManyToManyField(related_name='object_permissions', to='core.objecttype'),
|
||||
),
|
||||
]
|
||||
|
@ -28,22 +28,6 @@ class Migration(migrations.Migration):
|
||||
migrations.AlterField(
|
||||
model_name='objectpermission',
|
||||
name='object_types',
|
||||
field=models.ManyToManyField(
|
||||
limit_choices_to=models.Q(
|
||||
models.Q(
|
||||
models.Q(
|
||||
(
|
||||
'app_label__in',
|
||||
['account', 'admin', 'auth', 'contenttypes', 'sessions', 'taggit', 'users'],
|
||||
),
|
||||
_negated=True,
|
||||
),
|
||||
models.Q(('app_label', 'users'), ('model__in', ['objectpermission', 'token', 'group', 'user'])),
|
||||
_connector='OR',
|
||||
)
|
||||
),
|
||||
related_name='object_permissions',
|
||||
to='core.objecttype',
|
||||
),
|
||||
field=models.ManyToManyField(related_name='object_permissions', to='core.objecttype'),
|
||||
),
|
||||
]
|
||||
|
@ -3,7 +3,6 @@ from django.db import models
|
||||
from django.urls import reverse
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from users.constants import OBJECTPERMISSION_OBJECT_TYPES
|
||||
from utilities.querysets import RestrictedQuerySet
|
||||
|
||||
__all__ = (
|
||||
@ -31,7 +30,6 @@ class ObjectPermission(models.Model):
|
||||
)
|
||||
object_types = models.ManyToManyField(
|
||||
to='core.ObjectType',
|
||||
limit_choices_to=OBJECTPERMISSION_OBJECT_TYPES,
|
||||
related_name='object_permissions'
|
||||
)
|
||||
actions = ArrayField(
|
||||
|
@ -154,7 +154,6 @@ class Migration(migrations.Migration):
|
||||
'role',
|
||||
models.ForeignKey(
|
||||
blank=True,
|
||||
limit_choices_to={'vm_role': True},
|
||||
null=True,
|
||||
on_delete=django.db.models.deletion.PROTECT,
|
||||
related_name='virtual_machines',
|
||||
|
@ -32,7 +32,6 @@ class Migration(migrations.Migration):
|
||||
name='scope_type',
|
||||
field=models.ForeignKey(
|
||||
blank=True,
|
||||
limit_choices_to=models.Q(('model__in', ('region', 'sitegroup', 'site', 'location'))),
|
||||
null=True,
|
||||
on_delete=django.db.models.deletion.PROTECT,
|
||||
related_name='+',
|
||||
|
@ -82,7 +82,6 @@ class VirtualMachine(ContactsMixin, ImageAttachmentsMixin, RenderConfigMixin, Co
|
||||
to='dcim.DeviceRole',
|
||||
on_delete=models.PROTECT,
|
||||
related_name='virtual_machines',
|
||||
limit_choices_to={'vm_role': True},
|
||||
blank=True,
|
||||
null=True
|
||||
)
|
||||
|
@ -72,14 +72,6 @@ class Migration(migrations.Migration):
|
||||
(
|
||||
'assigned_object_type',
|
||||
models.ForeignKey(
|
||||
limit_choices_to=models.Q(
|
||||
models.Q(
|
||||
models.Q(('app_label', 'dcim'), ('model', 'interface')),
|
||||
models.Q(('app_label', 'ipam'), ('model', 'vlan')),
|
||||
models.Q(('app_label', 'virtualization'), ('model', 'vminterface')),
|
||||
_connector='OR',
|
||||
)
|
||||
),
|
||||
on_delete=django.db.models.deletion.PROTECT,
|
||||
related_name='+',
|
||||
to='contenttypes.contenttype',
|
||||
|
@ -8,7 +8,6 @@ from core.models import ObjectType
|
||||
from netbox.models import NetBoxModel, PrimaryModel
|
||||
from netbox.models.features import ContactsMixin
|
||||
from vpn.choices import L2VPNStatusChoices, L2VPNTypeChoices
|
||||
from vpn.constants import L2VPN_ASSIGNMENT_MODELS
|
||||
|
||||
__all__ = (
|
||||
'L2VPN',
|
||||
@ -93,7 +92,6 @@ class L2VPNTermination(NetBoxModel):
|
||||
)
|
||||
assigned_object_type = models.ForeignKey(
|
||||
to='contenttypes.ContentType',
|
||||
limit_choices_to=L2VPN_ASSIGNMENT_MODELS,
|
||||
on_delete=models.PROTECT,
|
||||
related_name='+'
|
||||
)
|
||||
|
@ -4,7 +4,6 @@ import taggit.managers
|
||||
from django.db import migrations, models
|
||||
|
||||
import utilities.json
|
||||
import wireless.models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
@ -149,7 +148,6 @@ class Migration(migrations.Migration):
|
||||
(
|
||||
'interface_a',
|
||||
models.ForeignKey(
|
||||
limit_choices_to=wireless.models.get_wireless_interface_types,
|
||||
on_delete=django.db.models.deletion.PROTECT,
|
||||
related_name='+',
|
||||
to='dcim.interface',
|
||||
@ -158,7 +156,6 @@ class Migration(migrations.Migration):
|
||||
(
|
||||
'interface_b',
|
||||
models.ForeignKey(
|
||||
limit_choices_to=wireless.models.get_wireless_interface_types,
|
||||
on_delete=django.db.models.deletion.PROTECT,
|
||||
related_name='+',
|
||||
to='dcim.interface',
|
||||
|
@ -66,7 +66,6 @@ class Migration(migrations.Migration):
|
||||
name='scope_type',
|
||||
field=models.ForeignKey(
|
||||
blank=True,
|
||||
limit_choices_to=models.Q(('model__in', ('region', 'sitegroup', 'site', 'location'))),
|
||||
null=True,
|
||||
on_delete=django.db.models.deletion.PROTECT,
|
||||
related_name='+',
|
||||
|
@ -123,26 +123,18 @@ class WirelessLAN(WirelessAuthenticationBase, CachedScopeMixin, PrimaryModel):
|
||||
return WirelessLANStatusChoices.colors.get(self.status)
|
||||
|
||||
|
||||
def get_wireless_interface_types():
|
||||
# Wrap choices in a callable to avoid generating dummy migrations
|
||||
# when the choices are updated.
|
||||
return {'type__in': WIRELESS_IFACE_TYPES}
|
||||
|
||||
|
||||
class WirelessLink(WirelessAuthenticationBase, DistanceMixin, PrimaryModel):
|
||||
"""
|
||||
A point-to-point connection between two wireless Interfaces.
|
||||
"""
|
||||
interface_a = models.ForeignKey(
|
||||
to='dcim.Interface',
|
||||
limit_choices_to=get_wireless_interface_types,
|
||||
on_delete=models.PROTECT,
|
||||
related_name='+',
|
||||
verbose_name=_('interface A'),
|
||||
)
|
||||
interface_b = models.ForeignKey(
|
||||
to='dcim.Interface',
|
||||
limit_choices_to=get_wireless_interface_types,
|
||||
on_delete=models.PROTECT,
|
||||
related_name='+',
|
||||
verbose_name=_('interface B'),
|
||||
|
Loading…
Reference in New Issue
Block a user