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

Initial work on contacts

This commit is contained in:
jeremystretch
2021-10-18 11:45:05 -04:00
parent 6015c47587
commit 2e78568d4d
24 changed files with 1594 additions and 29 deletions

View File

@ -1,16 +1,23 @@
from extras.forms import CustomFieldModelForm
from extras.models import Tag
from tenancy.models import Tenant, TenantGroup
from tenancy.models import *
from utilities.forms import (
BootstrapMixin, CommentField, DynamicModelChoiceField, DynamicModelMultipleChoiceField, SlugField,
BootstrapMixin, CommentField, DynamicModelChoiceField, DynamicModelMultipleChoiceField, SlugField, SmallTextarea,
)
__all__ = (
'ContactForm',
'ContactGroupForm',
'ContactRoleForm',
'TenantForm',
'TenantGroupForm',
)
#
# Tenants
#
class TenantGroupForm(BootstrapMixin, CustomFieldModelForm):
parent = DynamicModelChoiceField(
queryset=TenantGroup.objects.all(),
@ -45,3 +52,51 @@ class TenantForm(BootstrapMixin, CustomFieldModelForm):
fieldsets = (
('Tenant', ('name', 'slug', 'group', 'description', 'tags')),
)
#
# Contacts
#
class ContactGroupForm(BootstrapMixin, CustomFieldModelForm):
parent = DynamicModelChoiceField(
queryset=ContactGroup.objects.all(),
required=False
)
slug = SlugField()
class Meta:
model = ContactGroup
fields = ['parent', 'name', 'slug', 'description']
class ContactRoleForm(BootstrapMixin, CustomFieldModelForm):
slug = SlugField()
class Meta:
model = ContactRole
fields = ['name', 'slug', 'description']
class ContactForm(BootstrapMixin, CustomFieldModelForm):
group = DynamicModelChoiceField(
queryset=ContactGroup.objects.all(),
required=False
)
comments = CommentField()
tags = DynamicModelMultipleChoiceField(
queryset=Tag.objects.all(),
required=False
)
class Meta:
model = Contact
fields = (
'group', 'name', 'title', 'phone', 'email', 'address', 'comments', 'tags',
)
fieldsets = (
('Contact', ('group', 'name', 'title', 'phone', 'email', 'address', 'tags')),
)
widgets = {
'address': SmallTextarea(attrs={'rows': 3}),
}