mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Refactor tenancy forms
This commit is contained in:
36
netbox/tenancy/forms/bulk_import.py
Normal file
36
netbox/tenancy/forms/bulk_import.py
Normal file
@@ -0,0 +1,36 @@
|
||||
from extras.forms import CustomFieldModelCSVForm
|
||||
from tenancy.models import Tenant, TenantGroup
|
||||
from utilities.forms import CSVModelChoiceField, SlugField
|
||||
|
||||
__all__ = (
|
||||
'TenantCSVForm',
|
||||
'TenantGroupCSVForm',
|
||||
)
|
||||
|
||||
|
||||
class TenantGroupCSVForm(CustomFieldModelCSVForm):
|
||||
parent = CSVModelChoiceField(
|
||||
queryset=TenantGroup.objects.all(),
|
||||
required=False,
|
||||
to_field_name='name',
|
||||
help_text='Parent group'
|
||||
)
|
||||
slug = SlugField()
|
||||
|
||||
class Meta:
|
||||
model = TenantGroup
|
||||
fields = ('name', 'slug', 'parent', 'description')
|
||||
|
||||
|
||||
class TenantCSVForm(CustomFieldModelCSVForm):
|
||||
slug = SlugField()
|
||||
group = CSVModelChoiceField(
|
||||
queryset=TenantGroup.objects.all(),
|
||||
required=False,
|
||||
to_field_name='name',
|
||||
help_text='Assigned group'
|
||||
)
|
||||
|
||||
class Meta:
|
||||
model = Tenant
|
||||
fields = ('name', 'slug', 'group', 'description', 'comments')
|
Reference in New Issue
Block a user