mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Cleanup for #3664
This commit is contained in:
@ -5,7 +5,6 @@ from django.db.models import Q
|
|||||||
from dcim.models import DeviceRole, Platform, Region, Site
|
from dcim.models import DeviceRole, Platform, Region, Site
|
||||||
from tenancy.models import Tenant, TenantGroup
|
from tenancy.models import Tenant, TenantGroup
|
||||||
from .choices import *
|
from .choices import *
|
||||||
from .constants import *
|
|
||||||
from .models import ConfigContext, CustomField, Graph, ExportTemplate, ObjectChange, Tag
|
from .models import ConfigContext, CustomField, Graph, ExportTemplate, ObjectChange, Tag
|
||||||
|
|
||||||
|
|
||||||
@ -180,11 +179,6 @@ class ConfigContextFilter(django_filters.FilterSet):
|
|||||||
to_field_name='slug',
|
to_field_name='slug',
|
||||||
label='Tenant (slug)',
|
label='Tenant (slug)',
|
||||||
)
|
)
|
||||||
tag_id = django_filters.ModelMultipleChoiceFilter(
|
|
||||||
field_name='tags',
|
|
||||||
queryset=Tag.objects.all(),
|
|
||||||
label='Tag',
|
|
||||||
)
|
|
||||||
tag = django_filters.ModelMultipleChoiceFilter(
|
tag = django_filters.ModelMultipleChoiceFilter(
|
||||||
field_name='tags__slug',
|
field_name='tags__slug',
|
||||||
queryset=Tag.objects.all(),
|
queryset=Tag.objects.all(),
|
||||||
|
@ -14,7 +14,6 @@ from utilities.forms import (
|
|||||||
BOOLEAN_WITH_BLANK_CHOICES,
|
BOOLEAN_WITH_BLANK_CHOICES,
|
||||||
)
|
)
|
||||||
from .choices import *
|
from .choices import *
|
||||||
from .constants import *
|
|
||||||
from .models import ConfigContext, CustomField, CustomFieldValue, ImageAttachment, ObjectChange, Tag
|
from .models import ConfigContext, CustomField, CustomFieldValue, ImageAttachment, ObjectChange, Tag
|
||||||
|
|
||||||
|
|
||||||
@ -238,6 +237,14 @@ class TagBulkEditForm(BootstrapMixin, BulkEditForm):
|
|||||||
#
|
#
|
||||||
|
|
||||||
class ConfigContextForm(BootstrapMixin, forms.ModelForm):
|
class ConfigContextForm(BootstrapMixin, forms.ModelForm):
|
||||||
|
tags = forms.ModelMultipleChoiceField(
|
||||||
|
queryset=Tag.objects.all(),
|
||||||
|
to_field_name='slug',
|
||||||
|
required=False,
|
||||||
|
widget=APISelectMultiple(
|
||||||
|
api_url="/api/extras/tags/"
|
||||||
|
)
|
||||||
|
)
|
||||||
data = JSONField(
|
data = JSONField(
|
||||||
label=''
|
label=''
|
||||||
)
|
)
|
||||||
@ -267,9 +274,6 @@ class ConfigContextForm(BootstrapMixin, forms.ModelForm):
|
|||||||
'tenants': APISelectMultiple(
|
'tenants': APISelectMultiple(
|
||||||
api_url="/api/tenancy/tenants/"
|
api_url="/api/tenancy/tenants/"
|
||||||
),
|
),
|
||||||
'tags': APISelectMultiple(
|
|
||||||
api_url="/api/extras/tags/"
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -39,8 +39,6 @@ class ConfigContextQuerySet(QuerySet):
|
|||||||
else:
|
else:
|
||||||
regions = []
|
regions = []
|
||||||
|
|
||||||
tags = obj.tags.slugs()
|
|
||||||
|
|
||||||
return self.filter(
|
return self.filter(
|
||||||
Q(regions__in=regions) | Q(regions=None),
|
Q(regions__in=regions) | Q(regions=None),
|
||||||
Q(sites=obj.site) | Q(sites=None),
|
Q(sites=obj.site) | Q(sites=None),
|
||||||
@ -48,6 +46,6 @@ class ConfigContextQuerySet(QuerySet):
|
|||||||
Q(platforms=obj.platform) | Q(platforms=None),
|
Q(platforms=obj.platform) | Q(platforms=None),
|
||||||
Q(tenant_groups=tenant_group) | Q(tenant_groups=None),
|
Q(tenant_groups=tenant_group) | Q(tenant_groups=None),
|
||||||
Q(tenants=obj.tenant) | Q(tenants=None),
|
Q(tenants=obj.tenant) | Q(tenants=None),
|
||||||
Q(tags__name__in=tags) | Q(tags=None),
|
Q(tags__slug__in=obj.tags.slugs()) | Q(tags=None),
|
||||||
is_active=True,
|
is_active=True,
|
||||||
).order_by('weight', 'name')
|
).order_by('weight', 'name')
|
||||||
|
Reference in New Issue
Block a user