mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-19 05:21:55 -06:00
Use TreeNode choice fields for region assignment
This commit is contained in:
parent
da68968d75
commit
221805a63e
@ -182,18 +182,18 @@ class MACAddressField(forms.Field):
|
||||
#
|
||||
|
||||
class RegionForm(BootstrapMixin, forms.ModelForm):
|
||||
parent = TreeNodeChoiceField(
|
||||
queryset=Region.objects.all(),
|
||||
required=False,
|
||||
widget=StaticSelect2()
|
||||
)
|
||||
slug = SlugField()
|
||||
|
||||
class Meta:
|
||||
model = Region
|
||||
fields = [
|
||||
fields = (
|
||||
'parent', 'name', 'slug',
|
||||
]
|
||||
widgets = {
|
||||
'parent': APISelect(
|
||||
api_url="/api/dcim/regions/"
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
class RegionCSVForm(forms.ModelForm):
|
||||
@ -232,9 +232,7 @@ class SiteForm(BootstrapMixin, TenancyForm, CustomFieldModelForm):
|
||||
region = TreeNodeChoiceField(
|
||||
queryset=Region.objects.all(),
|
||||
required=False,
|
||||
widget=APISelect(
|
||||
api_url="/api/dcim/regions/"
|
||||
)
|
||||
widget=StaticSelect2()
|
||||
)
|
||||
slug = SlugField()
|
||||
comments = CommentField()
|
||||
@ -325,9 +323,7 @@ class SiteBulkEditForm(BootstrapMixin, AddRemoveTagsForm, CustomFieldBulkEditFor
|
||||
region = TreeNodeChoiceField(
|
||||
queryset=Region.objects.all(),
|
||||
required=False,
|
||||
widget=APISelect(
|
||||
api_url="/api/dcim/regions/"
|
||||
)
|
||||
widget=StaticSelect2()
|
||||
)
|
||||
tenant = forms.ModelChoiceField(
|
||||
queryset=Tenant.objects.all(),
|
||||
|
@ -1,6 +1,7 @@
|
||||
from django import forms
|
||||
from django.contrib.auth.models import User
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from mptt.forms import TreeNodeMultipleChoiceField
|
||||
from taggit.forms import TagField
|
||||
|
||||
from dcim.models import DeviceRole, Platform, Region, Site
|
||||
@ -8,7 +9,7 @@ from tenancy.models import Tenant, TenantGroup
|
||||
from utilities.forms import (
|
||||
add_blank_choice, APISelectMultiple, BootstrapMixin, BulkEditForm, BulkEditNullBooleanSelect, ColorSelect,
|
||||
CommentField, ContentTypeSelect, DateTimePicker, DynamicModelMultipleChoiceField, JSONField, SlugField,
|
||||
StaticSelect2, BOOLEAN_WITH_BLANK_CHOICES,
|
||||
StaticSelect2, StaticSelect2Multiple, BOOLEAN_WITH_BLANK_CHOICES,
|
||||
)
|
||||
from virtualization.models import Cluster, ClusterGroup
|
||||
from .choices import *
|
||||
@ -190,6 +191,11 @@ class TagBulkEditForm(BootstrapMixin, BulkEditForm):
|
||||
#
|
||||
|
||||
class ConfigContextForm(BootstrapMixin, forms.ModelForm):
|
||||
regions = TreeNodeMultipleChoiceField(
|
||||
queryset=Region.objects.all(),
|
||||
required=False,
|
||||
widget=StaticSelect2Multiple()
|
||||
)
|
||||
tags = forms.ModelMultipleChoiceField(
|
||||
queryset=Tag.objects.all(),
|
||||
to_field_name='slug',
|
||||
|
Loading…
Reference in New Issue
Block a user