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 (
|
2022-06-22 15:09:50 -04:00
|
|
|
add_blank_choice, CommentField, DatePicker, DynamicModelChoiceField, DynamicModelMultipleChoiceField, SmallTextarea,
|
2022-03-30 17:17:36 -04:00
|
|
|
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):
|
2022-03-30 17:17:36 -04:00
|
|
|
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,
|
2022-11-03 11:58:26 -07:00
|
|
|
label=_('Account number')
|
2021-09-27 15:23:12 -04:00
|
|
|
)
|
2022-11-04 08:28:09 -04:00
|
|
|
description = forms.CharField(
|
|
|
|
max_length=200,
|
|
|
|
required=False
|
|
|
|
)
|
2021-09-27 15:23:12 -04:00
|
|
|
comments = CommentField(
|
|
|
|
widget=SmallTextarea,
|
2022-11-03 11:58:26 -07:00
|
|
|
label=_('Comments')
|
2021-09-27 15:23:12 -04:00
|
|
|
)
|
|
|
|
|
2022-02-01 11:00:18 -05:00
|
|
|
model = Provider
|
2022-02-04 09:59:53 -05:00
|
|
|
fieldsets = (
|
2022-09-28 12:22:19 -07:00
|
|
|
(None, ('asns', 'account', )),
|
2022-02-04 09:59:53 -05:00
|
|
|
)
|
2022-01-31 16:15:40 -05:00
|
|
|
nullable_fields = (
|
2022-11-04 08:28:09 -04:00
|
|
|
'asns', 'account', 'description', '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,
|
2022-11-03 11:58:26 -07:00
|
|
|
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,
|
2022-11-03 11:58:26 -07:00
|
|
|
label=_('Comments')
|
2021-09-27 15:23:12 -04:00
|
|
|
)
|
|
|
|
|
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
|
|
|
|
)
|
2022-06-22 15:09:50 -04:00
|
|
|
install_date = forms.DateField(
|
|
|
|
required=False,
|
|
|
|
widget=DatePicker()
|
|
|
|
)
|
|
|
|
termination_date = forms.DateField(
|
|
|
|
required=False,
|
|
|
|
widget=DatePicker()
|
|
|
|
)
|
2021-09-27 15:23:12 -04:00
|
|
|
commit_rate = forms.IntegerField(
|
|
|
|
required=False,
|
2022-11-03 11:58:26 -07:00
|
|
|
label=_('Commit rate (Kbps)')
|
2021-09-27 15:23:12 -04:00
|
|
|
)
|
|
|
|
description = forms.CharField(
|
|
|
|
max_length=100,
|
|
|
|
required=False
|
|
|
|
)
|
|
|
|
comments = CommentField(
|
|
|
|
widget=SmallTextarea,
|
2022-11-03 11:58:26 -07:00
|
|
|
label=_('Comments')
|
2021-09-27 15:23:12 -04:00
|
|
|
)
|
|
|
|
|
2022-02-01 11:00:18 -05:00
|
|
|
model = Circuit
|
2022-02-04 09:59:53 -05:00
|
|
|
fieldsets = (
|
2022-06-22 15:09:50 -04:00
|
|
|
('Circuit', ('provider', 'type', 'status', 'description')),
|
|
|
|
('Service Parameters', ('install_date', 'termination_date', 'commit_rate')),
|
|
|
|
('Tenancy', ('tenant',)),
|
2022-02-04 09:59:53 -05:00
|
|
|
)
|
2022-01-31 16:15:40 -05:00
|
|
|
nullable_fields = (
|
|
|
|
'tenant', 'commit_rate', 'description', 'comments',
|
|
|
|
)
|