1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Implement support for nested TenantGroups

This commit is contained in:
Jeremy Stretch
2020-03-11 20:20:04 -04:00
parent a4a276083a
commit 45f6ea211d
8 changed files with 163 additions and 22 deletions

View File

@ -16,16 +16,32 @@ from .models import Tenant, TenantGroup
#
class TenantGroupForm(BootstrapMixin, forms.ModelForm):
parent = DynamicModelChoiceField(
queryset=TenantGroup.objects.all(),
required=False,
widget=APISelect(
api_url="/api/tenancy/tenant-groups/"
)
)
slug = SlugField()
class Meta:
model = TenantGroup
fields = [
'name', 'slug',
'parent', 'name', 'slug',
]
class TenantGroupCSVForm(forms.ModelForm):
parent = forms.ModelChoiceField(
queryset=TenantGroup.objects.all(),
required=False,
to_field_name='name',
help_text='Name of parent tenant group',
error_messages={
'invalid_choice': 'Tenant group not found.',
}
)
slug = SlugField()
class Meta: