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

Establish 4 core forms in netbox.forms.base

This commit is contained in:
jeremystretch
2022-01-28 15:48:15 -05:00
parent 0fe72376b1
commit f4776731ec
32 changed files with 380 additions and 366 deletions

View File

@@ -7,8 +7,8 @@ from django.utils.safestring import mark_safe
from dcim.choices import *
from dcim.constants import *
from dcim.models import *
from extras.forms import CustomFieldModelCSVForm
from ipam.models import VRF
from netbox.forms import NetBoxModelCSVForm
from tenancy.models import Tenant
from utilities.forms import CSVChoiceField, CSVContentTypeField, CSVModelChoiceField, CSVTypedChoiceField, SlugField
from virtualization.models import Cluster
@@ -46,7 +46,7 @@ __all__ = (
)
class RegionCSVForm(CustomFieldModelCSVForm):
class RegionCSVForm(NetBoxModelCSVForm):
parent = CSVModelChoiceField(
queryset=Region.objects.all(),
required=False,
@@ -59,7 +59,7 @@ class RegionCSVForm(CustomFieldModelCSVForm):
fields = ('name', 'slug', 'parent', 'description')
class SiteGroupCSVForm(CustomFieldModelCSVForm):
class SiteGroupCSVForm(NetBoxModelCSVForm):
parent = CSVModelChoiceField(
queryset=SiteGroup.objects.all(),
required=False,
@@ -72,7 +72,7 @@ class SiteGroupCSVForm(CustomFieldModelCSVForm):
fields = ('name', 'slug', 'parent', 'description')
class SiteCSVForm(CustomFieldModelCSVForm):
class SiteCSVForm(NetBoxModelCSVForm):
status = CSVChoiceField(
choices=SiteStatusChoices,
help_text='Operational status'
@@ -109,7 +109,7 @@ class SiteCSVForm(CustomFieldModelCSVForm):
}
class LocationCSVForm(CustomFieldModelCSVForm):
class LocationCSVForm(NetBoxModelCSVForm):
site = CSVModelChoiceField(
queryset=Site.objects.all(),
to_field_name='name',
@@ -136,7 +136,7 @@ class LocationCSVForm(CustomFieldModelCSVForm):
fields = ('site', 'parent', 'name', 'slug', 'tenant', 'description')
class RackRoleCSVForm(CustomFieldModelCSVForm):
class RackRoleCSVForm(NetBoxModelCSVForm):
slug = SlugField()
class Meta:
@@ -147,7 +147,7 @@ class RackRoleCSVForm(CustomFieldModelCSVForm):
}
class RackCSVForm(CustomFieldModelCSVForm):
class RackCSVForm(NetBoxModelCSVForm):
site = CSVModelChoiceField(
queryset=Site.objects.all(),
to_field_name='name'
@@ -205,7 +205,7 @@ class RackCSVForm(CustomFieldModelCSVForm):
self.fields['location'].queryset = self.fields['location'].queryset.filter(**params)
class RackReservationCSVForm(CustomFieldModelCSVForm):
class RackReservationCSVForm(NetBoxModelCSVForm):
site = CSVModelChoiceField(
queryset=Site.objects.all(),
to_field_name='name',
@@ -255,14 +255,14 @@ class RackReservationCSVForm(CustomFieldModelCSVForm):
self.fields['rack'].queryset = self.fields['rack'].queryset.filter(**params)
class ManufacturerCSVForm(CustomFieldModelCSVForm):
class ManufacturerCSVForm(NetBoxModelCSVForm):
class Meta:
model = Manufacturer
fields = ('name', 'slug', 'description')
class DeviceRoleCSVForm(CustomFieldModelCSVForm):
class DeviceRoleCSVForm(NetBoxModelCSVForm):
slug = SlugField()
class Meta:
@@ -273,7 +273,7 @@ class DeviceRoleCSVForm(CustomFieldModelCSVForm):
}
class PlatformCSVForm(CustomFieldModelCSVForm):
class PlatformCSVForm(NetBoxModelCSVForm):
slug = SlugField()
manufacturer = CSVModelChoiceField(
queryset=Manufacturer.objects.all(),
@@ -287,7 +287,7 @@ class PlatformCSVForm(CustomFieldModelCSVForm):
fields = ('name', 'slug', 'manufacturer', 'napalm_driver', 'napalm_args', 'description')
class BaseDeviceCSVForm(CustomFieldModelCSVForm):
class BaseDeviceCSVForm(NetBoxModelCSVForm):
device_role = CSVModelChoiceField(
queryset=DeviceRole.objects.all(),
to_field_name='name',
@@ -403,7 +403,7 @@ class DeviceCSVForm(BaseDeviceCSVForm):
self.fields['rack'].queryset = self.fields['rack'].queryset.filter(**params)
class ModuleCSVForm(CustomFieldModelCSVForm):
class ModuleCSVForm(NetBoxModelCSVForm):
device = CSVModelChoiceField(
queryset=Device.objects.all(),
to_field_name='name'
@@ -478,7 +478,7 @@ class ChildDeviceCSVForm(BaseDeviceCSVForm):
# Device components
#
class ConsolePortCSVForm(CustomFieldModelCSVForm):
class ConsolePortCSVForm(NetBoxModelCSVForm):
device = CSVModelChoiceField(
queryset=Device.objects.all(),
to_field_name='name'
@@ -501,7 +501,7 @@ class ConsolePortCSVForm(CustomFieldModelCSVForm):
fields = ('device', 'name', 'label', 'type', 'speed', 'mark_connected', 'description')
class ConsoleServerPortCSVForm(CustomFieldModelCSVForm):
class ConsoleServerPortCSVForm(NetBoxModelCSVForm):
device = CSVModelChoiceField(
queryset=Device.objects.all(),
to_field_name='name'
@@ -524,7 +524,7 @@ class ConsoleServerPortCSVForm(CustomFieldModelCSVForm):
fields = ('device', 'name', 'label', 'type', 'speed', 'mark_connected', 'description')
class PowerPortCSVForm(CustomFieldModelCSVForm):
class PowerPortCSVForm(NetBoxModelCSVForm):
device = CSVModelChoiceField(
queryset=Device.objects.all(),
to_field_name='name'
@@ -542,7 +542,7 @@ class PowerPortCSVForm(CustomFieldModelCSVForm):
)
class PowerOutletCSVForm(CustomFieldModelCSVForm):
class PowerOutletCSVForm(NetBoxModelCSVForm):
device = CSVModelChoiceField(
queryset=Device.objects.all(),
to_field_name='name'
@@ -591,7 +591,7 @@ class PowerOutletCSVForm(CustomFieldModelCSVForm):
self.fields['power_port'].queryset = PowerPort.objects.none()
class InterfaceCSVForm(CustomFieldModelCSVForm):
class InterfaceCSVForm(NetBoxModelCSVForm):
device = CSVModelChoiceField(
queryset=Device.objects.all(),
to_field_name='name'
@@ -655,7 +655,7 @@ class InterfaceCSVForm(CustomFieldModelCSVForm):
return self.cleaned_data['enabled']
class FrontPortCSVForm(CustomFieldModelCSVForm):
class FrontPortCSVForm(NetBoxModelCSVForm):
device = CSVModelChoiceField(
queryset=Device.objects.all(),
to_field_name='name'
@@ -703,7 +703,7 @@ class FrontPortCSVForm(CustomFieldModelCSVForm):
self.fields['rear_port'].queryset = RearPort.objects.none()
class RearPortCSVForm(CustomFieldModelCSVForm):
class RearPortCSVForm(NetBoxModelCSVForm):
device = CSVModelChoiceField(
queryset=Device.objects.all(),
to_field_name='name'
@@ -721,7 +721,7 @@ class RearPortCSVForm(CustomFieldModelCSVForm):
}
class ModuleBayCSVForm(CustomFieldModelCSVForm):
class ModuleBayCSVForm(NetBoxModelCSVForm):
device = CSVModelChoiceField(
queryset=Device.objects.all(),
to_field_name='name'
@@ -732,7 +732,7 @@ class ModuleBayCSVForm(CustomFieldModelCSVForm):
fields = ('device', 'name', 'label', 'position', 'description')
class DeviceBayCSVForm(CustomFieldModelCSVForm):
class DeviceBayCSVForm(NetBoxModelCSVForm):
device = CSVModelChoiceField(
queryset=Device.objects.all(),
to_field_name='name'
@@ -778,7 +778,7 @@ class DeviceBayCSVForm(CustomFieldModelCSVForm):
self.fields['installed_device'].queryset = Interface.objects.none()
class InventoryItemCSVForm(CustomFieldModelCSVForm):
class InventoryItemCSVForm(NetBoxModelCSVForm):
device = CSVModelChoiceField(
queryset=Device.objects.all(),
to_field_name='name'
@@ -827,7 +827,7 @@ class InventoryItemCSVForm(CustomFieldModelCSVForm):
# Device component roles
#
class InventoryItemRoleCSVForm(CustomFieldModelCSVForm):
class InventoryItemRoleCSVForm(NetBoxModelCSVForm):
slug = SlugField()
class Meta:
@@ -842,7 +842,7 @@ class InventoryItemRoleCSVForm(CustomFieldModelCSVForm):
# Cables
#
class CableCSVForm(CustomFieldModelCSVForm):
class CableCSVForm(NetBoxModelCSVForm):
# Termination A
side_a_device = CSVModelChoiceField(
queryset=Device.objects.all(),
@@ -947,7 +947,7 @@ class CableCSVForm(CustomFieldModelCSVForm):
# Virtual chassis
#
class VirtualChassisCSVForm(CustomFieldModelCSVForm):
class VirtualChassisCSVForm(NetBoxModelCSVForm):
master = CSVModelChoiceField(
queryset=Device.objects.all(),
to_field_name='name',
@@ -964,7 +964,7 @@ class VirtualChassisCSVForm(CustomFieldModelCSVForm):
# Power
#
class PowerPanelCSVForm(CustomFieldModelCSVForm):
class PowerPanelCSVForm(NetBoxModelCSVForm):
site = CSVModelChoiceField(
queryset=Site.objects.all(),
to_field_name='name',
@@ -990,7 +990,7 @@ class PowerPanelCSVForm(CustomFieldModelCSVForm):
self.fields['location'].queryset = self.fields['location'].queryset.filter(**params)
class PowerFeedCSVForm(CustomFieldModelCSVForm):
class PowerFeedCSVForm(NetBoxModelCSVForm):
site = CSVModelChoiceField(
queryset=Site.objects.all(),
to_field_name='name',