2021-09-27 15:23:12 -04:00
|
|
|
from circuits.choices import CircuitStatusChoices
|
|
|
|
from circuits.models import *
|
2022-11-03 11:58:26 -07:00
|
|
|
from django.utils.translation import gettext as _
|
2022-11-15 12:24:57 -05:00
|
|
|
from netbox.forms import NetBoxModelImportForm
|
2021-09-27 15:23:12 -04:00
|
|
|
from tenancy.models import Tenant
|
|
|
|
from utilities.forms import CSVChoiceField, CSVModelChoiceField, SlugField
|
|
|
|
|
|
|
|
__all__ = (
|
2022-11-15 12:24:57 -05:00
|
|
|
'CircuitImportForm',
|
|
|
|
'CircuitTypeImportForm',
|
|
|
|
'ProviderImportForm',
|
|
|
|
'ProviderNetworkImportForm',
|
2021-09-27 15:23:12 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
|
2022-11-15 12:24:57 -05:00
|
|
|
class ProviderImportForm(NetBoxModelImportForm):
|
2021-09-27 15:23:12 -04:00
|
|
|
slug = SlugField()
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
model = Provider
|
|
|
|
fields = (
|
2022-11-04 07:50:43 -07:00
|
|
|
'name', 'slug', 'account', 'description', 'comments', 'tags',
|
2021-09-27 15:23:12 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
|
2022-11-15 12:24:57 -05:00
|
|
|
class ProviderNetworkImportForm(NetBoxModelImportForm):
|
2021-09-27 15:23:12 -04:00
|
|
|
provider = CSVModelChoiceField(
|
|
|
|
queryset=Provider.objects.all(),
|
|
|
|
to_field_name='name',
|
2022-11-03 11:58:26 -07:00
|
|
|
help_text=_('Assigned provider')
|
2021-09-27 15:23:12 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
model = ProviderNetwork
|
|
|
|
fields = [
|
2022-11-04 07:50:43 -07:00
|
|
|
'provider', 'name', 'service_id', 'description', 'comments', 'tags'
|
2021-09-27 15:23:12 -04:00
|
|
|
]
|
|
|
|
|
|
|
|
|
2022-11-15 12:24:57 -05:00
|
|
|
class CircuitTypeImportForm(NetBoxModelImportForm):
|
2021-09-27 15:23:12 -04:00
|
|
|
slug = SlugField()
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
model = CircuitType
|
2022-11-04 07:50:43 -07:00
|
|
|
fields = ('name', 'slug', 'description', 'tags')
|
2021-09-27 15:23:12 -04:00
|
|
|
help_texts = {
|
2022-11-03 11:58:26 -07:00
|
|
|
'name': _('Name of circuit type'),
|
2021-09-27 15:23:12 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-11-15 12:24:57 -05:00
|
|
|
class CircuitImportForm(NetBoxModelImportForm):
|
2021-09-27 15:23:12 -04:00
|
|
|
provider = CSVModelChoiceField(
|
|
|
|
queryset=Provider.objects.all(),
|
|
|
|
to_field_name='name',
|
2022-11-03 11:58:26 -07:00
|
|
|
help_text=_('Assigned provider')
|
2021-09-27 15:23:12 -04:00
|
|
|
)
|
|
|
|
type = CSVModelChoiceField(
|
|
|
|
queryset=CircuitType.objects.all(),
|
|
|
|
to_field_name='name',
|
2022-11-03 11:58:26 -07:00
|
|
|
help_text=_('Type of circuit')
|
2021-09-27 15:23:12 -04:00
|
|
|
)
|
|
|
|
status = CSVChoiceField(
|
|
|
|
choices=CircuitStatusChoices,
|
2022-11-03 11:58:26 -07:00
|
|
|
help_text=_('Operational status')
|
2021-09-27 15:23:12 -04:00
|
|
|
)
|
|
|
|
tenant = CSVModelChoiceField(
|
|
|
|
queryset=Tenant.objects.all(),
|
|
|
|
required=False,
|
|
|
|
to_field_name='name',
|
2022-11-03 11:58:26 -07:00
|
|
|
help_text=_('Assigned tenant')
|
2021-09-27 15:23:12 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
model = Circuit
|
|
|
|
fields = [
|
2022-06-22 15:09:50 -04:00
|
|
|
'cid', 'provider', 'type', 'status', 'tenant', 'install_date', 'termination_date', 'commit_rate',
|
2022-11-04 07:50:43 -07:00
|
|
|
'description', 'comments', 'tags'
|
2021-09-27 15:23:12 -04:00
|
|
|
]
|