2021-09-27 15:23:12 -04:00
|
|
|
from django import forms
|
|
|
|
|
|
|
|
from circuits.choices import CircuitStatusChoices
|
|
|
|
from circuits.models import *
|
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
|
2021-11-18 16:48:29 -05:00
|
|
|
from utilities.forms import add_blank_choice, CommentField, DynamicModelChoiceField, 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
|
|
|
pk = forms.ModelMultipleChoiceField(
|
|
|
|
queryset=Provider.objects.all(),
|
|
|
|
widget=forms.MultipleHiddenInput
|
|
|
|
)
|
|
|
|
asn = forms.IntegerField(
|
|
|
|
required=False,
|
|
|
|
label='ASN'
|
|
|
|
)
|
|
|
|
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'
|
|
|
|
)
|
|
|
|
|
|
|
|
class Meta:
|
2022-01-28 16:47:54 -05:00
|
|
|
nullable_fields = (
|
2021-09-27 15:23:12 -04:00
|
|
|
'asn', 'account', 'portal_url', 'noc_contact', 'admin_contact', 'comments',
|
2022-01-28 16:47:54 -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
|
|
|
pk = forms.ModelMultipleChoiceField(
|
|
|
|
queryset=ProviderNetwork.objects.all(),
|
|
|
|
widget=forms.MultipleHiddenInput
|
|
|
|
)
|
|
|
|
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,
|
|
|
|
required=False
|
|
|
|
)
|
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'
|
|
|
|
)
|
|
|
|
|
|
|
|
class Meta:
|
2022-01-28 16:47:54 -05:00
|
|
|
nullable_fields = (
|
2021-12-23 13:50:01 -05:00
|
|
|
'service_id', 'description', 'comments',
|
2022-01-28 16:47:54 -05:00
|
|
|
)
|
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
|
|
|
pk = forms.ModelMultipleChoiceField(
|
|
|
|
queryset=CircuitType.objects.all(),
|
|
|
|
widget=forms.MultipleHiddenInput
|
|
|
|
)
|
|
|
|
description = forms.CharField(
|
|
|
|
max_length=200,
|
|
|
|
required=False
|
|
|
|
)
|
|
|
|
|
|
|
|
class Meta:
|
2022-01-28 16:47:54 -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
|
|
|
pk = forms.ModelMultipleChoiceField(
|
|
|
|
queryset=Circuit.objects.all(),
|
|
|
|
widget=forms.MultipleHiddenInput
|
|
|
|
)
|
|
|
|
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'
|
|
|
|
)
|
|
|
|
|
|
|
|
class Meta:
|
2022-01-28 16:47:54 -05:00
|
|
|
nullable_fields = (
|
2021-09-27 15:23:12 -04:00
|
|
|
'tenant', 'commit_rate', 'description', 'comments',
|
2022-01-28 16:47:54 -05:00
|
|
|
)
|