mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
d470848b29
* Clean up base modules * Clean up forms modules * Clean up templatetags modules * Replace custom simplify_decimal filter with floatformat * Misc cleanup * Merge ReturnURLForm into ConfirmationForm * Clean up import statements for utilities.forms * Fix field class references in docs
84 lines
2.0 KiB
Python
84 lines
2.0 KiB
Python
from django.utils.translation import gettext as _
|
|
from netbox.forms import NetBoxModelImportForm
|
|
from tenancy.models import *
|
|
from utilities.forms.fields import CSVModelChoiceField, SlugField
|
|
|
|
__all__ = (
|
|
'ContactImportForm',
|
|
'ContactGroupImportForm',
|
|
'ContactRoleImportForm',
|
|
'TenantImportForm',
|
|
'TenantGroupImportForm',
|
|
)
|
|
|
|
|
|
#
|
|
# Tenants
|
|
#
|
|
|
|
class TenantGroupImportForm(NetBoxModelImportForm):
|
|
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', 'tags')
|
|
|
|
|
|
class TenantImportForm(NetBoxModelImportForm):
|
|
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', 'tags')
|
|
|
|
|
|
#
|
|
# Contacts
|
|
#
|
|
|
|
class ContactGroupImportForm(NetBoxModelImportForm):
|
|
parent = CSVModelChoiceField(
|
|
queryset=ContactGroup.objects.all(),
|
|
required=False,
|
|
to_field_name='name',
|
|
help_text=_('Parent group')
|
|
)
|
|
slug = SlugField()
|
|
|
|
class Meta:
|
|
model = ContactGroup
|
|
fields = ('name', 'slug', 'parent', 'description', 'tags')
|
|
|
|
|
|
class ContactRoleImportForm(NetBoxModelImportForm):
|
|
slug = SlugField()
|
|
|
|
class Meta:
|
|
model = ContactRole
|
|
fields = ('name', 'slug', 'description')
|
|
|
|
|
|
class ContactImportForm(NetBoxModelImportForm):
|
|
group = CSVModelChoiceField(
|
|
queryset=ContactGroup.objects.all(),
|
|
required=False,
|
|
to_field_name='name',
|
|
help_text=_('Assigned group')
|
|
)
|
|
|
|
class Meta:
|
|
model = Contact
|
|
fields = ('name', 'title', 'phone', 'email', 'address', 'link', 'group', 'description', 'comments', 'tags')
|