2021-09-27 15:23:12 -04:00
|
|
|
from django import forms
|
2022-03-30 17:17:36 -04:00
|
|
|
from django.utils.translation import gettext as _
|
2021-09-27 15:23:12 -04:00
|
|
|
|
|
|
|
from circuits.choices import CircuitStatusChoices
|
|
|
|
from circuits.models import *
|
2022-03-30 17:17:36 -04:00
|
|
|
from ipam.models import ASN
|
2022-01-28 15:48:15 -05:00
|
|
|
from netbox.forms import NetBoxModelBulkEditForm
|
2021-09-27 15:23:12 -04:00
|
|
|
from tenancy.models import Tenant
|
2022-03-30 17:17:36 -04:00
|
|
|
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',
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2022-01-28 15:48:15 -05:00
|
|
|
class ProviderBulkEditForm(NetBoxModelBulkEditForm):
|
2021-09-27 15:23:12 -04:00
|
|
|
asn = forms.IntegerField(
|
|
|
|
required=False,
|
2022-03-30 17:17:36 -04:00
|
|
|
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'
|
|
|
|
)
|
|
|
|
|
2022-02-01 11:00:18 -05:00
|
|
|
model = Provider
|
2022-02-04 09:59:53 -05:00
|
|
|
fieldsets = (
|
2022-03-30 17:17:36 -04:00
|
|
|
(None, ('asn', 'asns', 'account', 'portal_url', 'noc_contact', 'admin_contact')),
|
2022-02-04 09:59:53 -05:00
|
|
|
)
|
2022-01-31 16:15:40 -05:00
|
|
|
nullable_fields = (
|
2022-03-30 17:17:36 -04:00
|
|
|
'asn', 'asns', 'account', 'portal_url', 'noc_contact', 'admin_contact', 'comments',
|
2022-01-31 16:15:40 -05:00
|
|
|
)
|
2021-09-27 15:23:12 -04:00
|
|
|
|
|
|
|
|
2022-01-28 15:48:15 -05:00
|
|
|
class ProviderNetworkBulkEditForm(NetBoxModelBulkEditForm):
|
2021-09-27 15:23:12 -04:00
|
|
|
provider = DynamicModelChoiceField(
|
|
|
|
queryset=Provider.objects.all(),
|
|
|
|
required=False
|
|
|
|
)
|
2021-12-23 13:50:01 -05:00
|
|
|
service_id = forms.CharField(
|
2021-09-27 15:23:12 -04:00
|
|
|
max_length=100,
|
2022-02-04 09:59:53 -05:00
|
|
|
required=False,
|
|
|
|
label='Service ID'
|
2021-09-27 15:23:12 -04:00
|
|
|
)
|
2021-12-23 13:50:01 -05:00
|
|
|
description = forms.CharField(
|
|
|
|
max_length=200,
|
|
|
|
required=False
|
|
|
|
)
|
2021-09-27 15:23:12 -04:00
|
|
|
comments = CommentField(
|
|
|
|
widget=SmallTextarea,
|
|
|
|
label='Comments'
|
|
|
|
)
|
|
|
|
|
2022-02-01 11:00:18 -05:00
|
|
|
model = ProviderNetwork
|
2022-02-04 09:59:53 -05:00
|
|
|
fieldsets = (
|
|
|
|
(None, ('provider', 'service_id', 'description')),
|
|
|
|
)
|
2022-01-31 16:15:40 -05:00
|
|
|
nullable_fields = (
|
|
|
|
'service_id', 'description', 'comments',
|
|
|
|
)
|
2021-09-27 15:23:12 -04:00
|
|
|
|
|
|
|
|
2022-01-28 15:48:15 -05:00
|
|
|
class CircuitTypeBulkEditForm(NetBoxModelBulkEditForm):
|
2021-09-27 15:23:12 -04:00
|
|
|
description = forms.CharField(
|
|
|
|
max_length=200,
|
|
|
|
required=False
|
|
|
|
)
|
|
|
|
|
2022-02-01 11:00:18 -05:00
|
|
|
model = CircuitType
|
2022-02-04 09:59:53 -05:00
|
|
|
fieldsets = (
|
|
|
|
(None, ('description',)),
|
|
|
|
)
|
2022-01-31 16:15:40 -05:00
|
|
|
nullable_fields = ('description',)
|
2021-09-27 15:23:12 -04:00
|
|
|
|
|
|
|
|
2022-01-28 15:48:15 -05: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'
|
|
|
|
)
|
|
|
|
|
2022-02-01 11:00:18 -05:00
|
|
|
model = Circuit
|
2022-02-04 09:59:53 -05:00
|
|
|
fieldsets = (
|
|
|
|
(None, ('type', 'provider', 'status', 'tenant', 'commit_rate', 'description')),
|
|
|
|
)
|
2022-01-31 16:15:40 -05:00
|
|
|
nullable_fields = (
|
|
|
|
'tenant', 'commit_rate', 'description', 'comments',
|
|
|
|
)
|