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

145 lines
3.5 KiB
Python
Raw Normal View History

2021-09-27 15:23:12 -04:00
from django import forms
from django.utils.translation import gettext as _
2021-09-27 15:23:12 -04:00
from circuits.choices import CircuitStatusChoices
from circuits.models import *
from ipam.models import ASN
from netbox.forms import NetBoxModelBulkEditForm
2021-09-27 15:23:12 -04:00
from tenancy.models import Tenant
from utilities.forms import (
add_blank_choice, CommentField, DynamicModelChoiceField, DynamicModelMultipleChoiceField, SmallTextarea,
StaticSelect,
)
2021-09-27 15:23:12 -04:00
__all__ = (
'CircuitBulkEditForm',
'CircuitTypeBulkEditForm',
'ProviderBulkEditForm',
'ProviderNetworkBulkEditForm',
)
class ProviderBulkEditForm(NetBoxModelBulkEditForm):
2021-09-27 15:23:12 -04:00
asn = forms.IntegerField(
required=False,
label='ASN (legacy)'
)
asns = DynamicModelMultipleChoiceField(
queryset=ASN.objects.all(),
label=_('ASNs'),
required=False
2021-09-27 15:23:12 -04:00
)
account = forms.CharField(
max_length=30,
required=False,
label='Account number'
)
portal_url = forms.URLField(
required=False,
label='Portal'
)
noc_contact = forms.CharField(
required=False,
widget=SmallTextarea,
label='NOC contact'
)
admin_contact = forms.CharField(
required=False,
widget=SmallTextarea,
label='Admin contact'
)
comments = CommentField(
widget=SmallTextarea,
label='Comments'
)
model = Provider
fieldsets = (
(None, ('asn', 'asns', 'account', 'portal_url', 'noc_contact', 'admin_contact')),
)
nullable_fields = (
'asn', 'asns', 'account', 'portal_url', 'noc_contact', 'admin_contact', 'comments',
)
2021-09-27 15:23:12 -04:00
class ProviderNetworkBulkEditForm(NetBoxModelBulkEditForm):
2021-09-27 15:23:12 -04:00
provider = DynamicModelChoiceField(
queryset=Provider.objects.all(),
required=False
)
service_id = forms.CharField(
2021-09-27 15:23:12 -04:00
max_length=100,
required=False,
label='Service ID'
2021-09-27 15:23:12 -04:00
)
description = forms.CharField(
max_length=200,
required=False
)
2021-09-27 15:23:12 -04:00
comments = CommentField(
widget=SmallTextarea,
label='Comments'
)
model = ProviderNetwork
fieldsets = (
(None, ('provider', 'service_id', 'description')),
)
nullable_fields = (
'service_id', 'description', 'comments',
)
2021-09-27 15:23:12 -04:00
class CircuitTypeBulkEditForm(NetBoxModelBulkEditForm):
2021-09-27 15:23:12 -04:00
description = forms.CharField(
max_length=200,
required=False
)
model = CircuitType
fieldsets = (
(None, ('description',)),
)
nullable_fields = ('description',)
2021-09-27 15:23:12 -04:00
class CircuitBulkEditForm(NetBoxModelBulkEditForm):
2021-09-27 15:23:12 -04:00
type = DynamicModelChoiceField(
queryset=CircuitType.objects.all(),
required=False
)
provider = DynamicModelChoiceField(
queryset=Provider.objects.all(),
required=False
)
status = forms.ChoiceField(
choices=add_blank_choice(CircuitStatusChoices),
required=False,
initial='',
widget=StaticSelect()
)
tenant = DynamicModelChoiceField(
queryset=Tenant.objects.all(),
required=False
)
commit_rate = forms.IntegerField(
required=False,
label='Commit rate (Kbps)'
)
description = forms.CharField(
max_length=100,
required=False
)
comments = CommentField(
widget=SmallTextarea,
label='Comments'
)
model = Circuit
fieldsets = (
(None, ('type', 'provider', 'status', 'tenant', 'commit_rate', 'description')),
)
nullable_fields = (
'tenant', 'commit_rate', 'description', 'comments',
)