mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Use FieldSet instances for all forms
This commit is contained in:
@@ -6,6 +6,7 @@ from tenancy.choices import ContactPriorityChoices
|
||||
from tenancy.models import *
|
||||
from utilities.forms import add_blank_choice
|
||||
from utilities.forms.fields import CommentField, DynamicModelChoiceField
|
||||
from utilities.forms.rendering import FieldSet
|
||||
|
||||
__all__ = (
|
||||
'ContactAssignmentBulkEditForm',
|
||||
@@ -46,7 +47,7 @@ class TenantBulkEditForm(NetBoxModelBulkEditForm):
|
||||
|
||||
model = Tenant
|
||||
fieldsets = (
|
||||
(None, ('group',)),
|
||||
FieldSet('group'),
|
||||
)
|
||||
nullable_fields = ('group',)
|
||||
|
||||
@@ -69,7 +70,7 @@ class ContactGroupBulkEditForm(NetBoxModelBulkEditForm):
|
||||
|
||||
model = ContactGroup
|
||||
fieldsets = (
|
||||
(None, ('parent', 'description')),
|
||||
FieldSet('parent', 'description'),
|
||||
)
|
||||
nullable_fields = ('parent', 'description')
|
||||
|
||||
@@ -83,7 +84,7 @@ class ContactRoleBulkEditForm(NetBoxModelBulkEditForm):
|
||||
|
||||
model = ContactRole
|
||||
fieldsets = (
|
||||
(None, ('description',)),
|
||||
FieldSet('description'),
|
||||
)
|
||||
nullable_fields = ('description',)
|
||||
|
||||
@@ -126,7 +127,7 @@ class ContactBulkEditForm(NetBoxModelBulkEditForm):
|
||||
|
||||
model = Contact
|
||||
fieldsets = (
|
||||
(None, ('group', 'title', 'phone', 'email', 'address', 'link', 'description')),
|
||||
FieldSet('group', 'title', 'phone', 'email', 'address', 'link', 'description'),
|
||||
)
|
||||
nullable_fields = ('group', 'title', 'phone', 'email', 'address', 'link', 'description', 'comments')
|
||||
|
||||
@@ -150,6 +151,6 @@ class ContactAssignmentBulkEditForm(NetBoxModelBulkEditForm):
|
||||
|
||||
model = ContactAssignment
|
||||
fieldsets = (
|
||||
(None, ('contact', 'role', 'priority')),
|
||||
FieldSet('contact', 'role', 'priority'),
|
||||
)
|
||||
nullable_fields = ('priority',)
|
||||
|
@@ -9,6 +9,7 @@ from tenancy.forms import ContactModelFilterForm
|
||||
from utilities.forms.fields import (
|
||||
ContentTypeMultipleChoiceField, DynamicModelMultipleChoiceField, TagFilterField,
|
||||
)
|
||||
from utilities.forms.rendering import FieldSet
|
||||
|
||||
__all__ = (
|
||||
'ContactAssignmentFilterForm',
|
||||
@@ -37,8 +38,8 @@ class TenantGroupFilterForm(NetBoxModelFilterSetForm):
|
||||
class TenantFilterForm(ContactModelFilterForm, NetBoxModelFilterSetForm):
|
||||
model = Tenant
|
||||
fieldsets = (
|
||||
(None, ('q', 'filter_id', 'tag', 'group_id')),
|
||||
('Contacts', ('contact', 'contact_role', 'contact_group'))
|
||||
FieldSet('q', 'filter_id', 'tag', 'group_id'),
|
||||
FieldSet('contact', 'contact_role', 'contact_group', name=_('Contacts'))
|
||||
)
|
||||
group_id = DynamicModelMultipleChoiceField(
|
||||
queryset=TenantGroup.objects.all(),
|
||||
@@ -82,8 +83,8 @@ class ContactFilterForm(NetBoxModelFilterSetForm):
|
||||
class ContactAssignmentFilterForm(NetBoxModelFilterSetForm):
|
||||
model = ContactAssignment
|
||||
fieldsets = (
|
||||
(None, ('q', 'filter_id', 'tag')),
|
||||
(_('Assignment'), ('object_type_id', 'group_id', 'contact_id', 'role_id', 'priority')),
|
||||
FieldSet('q', 'filter_id', 'tag'),
|
||||
FieldSet('object_type_id', 'group_id', 'contact_id', 'role_id', 'priority', name=_('Assignment')),
|
||||
)
|
||||
object_type_id = ContentTypeMultipleChoiceField(
|
||||
queryset=ObjectType.objects.with_feature('contacts'),
|
||||
|
@@ -4,7 +4,7 @@ from django.utils.translation import gettext_lazy as _
|
||||
from netbox.forms import NetBoxModelForm
|
||||
from tenancy.models import *
|
||||
from utilities.forms.fields import CommentField, DynamicModelChoiceField, SlugField
|
||||
from utilities.forms.rendering import ObjectAttribute
|
||||
from utilities.forms.rendering import FieldSet, ObjectAttribute
|
||||
|
||||
__all__ = (
|
||||
'ContactAssignmentForm',
|
||||
@@ -29,9 +29,7 @@ class TenantGroupForm(NetBoxModelForm):
|
||||
slug = SlugField()
|
||||
|
||||
fieldsets = (
|
||||
(_('Tenant Group'), (
|
||||
'parent', 'name', 'slug', 'description', 'tags',
|
||||
)),
|
||||
FieldSet('parent', 'name', 'slug', 'description', 'tags', name=_('Tenant Group')),
|
||||
)
|
||||
|
||||
class Meta:
|
||||
@@ -51,7 +49,7 @@ class TenantForm(NetBoxModelForm):
|
||||
comments = CommentField()
|
||||
|
||||
fieldsets = (
|
||||
(_('Tenant'), ('name', 'slug', 'group', 'description', 'tags')),
|
||||
FieldSet('name', 'slug', 'group', 'description', 'tags', name=_('Tenant')),
|
||||
)
|
||||
|
||||
class Meta:
|
||||
@@ -74,9 +72,7 @@ class ContactGroupForm(NetBoxModelForm):
|
||||
slug = SlugField()
|
||||
|
||||
fieldsets = (
|
||||
(_('Contact Group'), (
|
||||
'parent', 'name', 'slug', 'description', 'tags',
|
||||
)),
|
||||
FieldSet('parent', 'name', 'slug', 'description', 'tags', name=_('Contact Group')),
|
||||
)
|
||||
|
||||
class Meta:
|
||||
@@ -88,9 +84,7 @@ class ContactRoleForm(NetBoxModelForm):
|
||||
slug = SlugField()
|
||||
|
||||
fieldsets = (
|
||||
(_('Contact Role'), (
|
||||
'name', 'slug', 'description', 'tags',
|
||||
)),
|
||||
FieldSet('name', 'slug', 'description', 'tags', name=_('Contact Role')),
|
||||
)
|
||||
|
||||
class Meta:
|
||||
@@ -107,7 +101,10 @@ class ContactForm(NetBoxModelForm):
|
||||
comments = CommentField()
|
||||
|
||||
fieldsets = (
|
||||
(_('Contact'), ('group', 'name', 'title', 'phone', 'email', 'address', 'link', 'description', 'tags')),
|
||||
FieldSet(
|
||||
'group', 'name', 'title', 'phone', 'email', 'address', 'link', 'description', 'tags',
|
||||
name=_('Contact')
|
||||
),
|
||||
)
|
||||
|
||||
class Meta:
|
||||
@@ -142,7 +139,7 @@ class ContactAssignmentForm(NetBoxModelForm):
|
||||
)
|
||||
|
||||
fieldsets = (
|
||||
(None, (ObjectAttribute('object'), 'group', 'contact', 'role', 'priority', 'tags')),
|
||||
FieldSet(ObjectAttribute('object'), 'group', 'contact', 'role', 'priority', 'tags'),
|
||||
)
|
||||
|
||||
class Meta:
|
||||
|
Reference in New Issue
Block a user