mirror of
https://github.com/netbox-community/netbox.git
synced 2025-12-19 03:42:25 -06:00
Closes #13149: Wrap form field labels with gettext_lazy()
Co-authored-by: Jeremy Stretch <jstretch@netboxlabs.com>
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
from django import forms
|
||||
|
||||
from dcim.models import *
|
||||
from django.utils.translation import gettext as _
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from extras.forms import CustomFieldsMixin
|
||||
from extras.models import Tag
|
||||
from utilities.forms import BootstrapMixin, form_from_model
|
||||
@@ -32,10 +32,12 @@ class DeviceBulkAddComponentForm(BootstrapMixin, CustomFieldsMixin, ComponentCre
|
||||
widget=forms.MultipleHiddenInput()
|
||||
)
|
||||
description = forms.CharField(
|
||||
label=_('Description'),
|
||||
max_length=100,
|
||||
required=False
|
||||
)
|
||||
tags = DynamicModelMultipleChoiceField(
|
||||
label=_('Tags'),
|
||||
queryset=Tag.objects.all(),
|
||||
required=False
|
||||
)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -3,7 +3,7 @@ from django.contrib.contenttypes.models import ContentType
|
||||
from django.contrib.postgres.forms.array import SimpleArrayField
|
||||
from django.core.exceptions import ObjectDoesNotExist
|
||||
from django.utils.safestring import mark_safe
|
||||
from django.utils.translation import gettext as _
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from dcim.choices import *
|
||||
from dcim.constants import *
|
||||
@@ -56,6 +56,7 @@ __all__ = (
|
||||
|
||||
class RegionImportForm(NetBoxModelImportForm):
|
||||
parent = CSVModelChoiceField(
|
||||
label=_('Parent'),
|
||||
queryset=Region.objects.all(),
|
||||
required=False,
|
||||
to_field_name='name',
|
||||
@@ -69,6 +70,7 @@ class RegionImportForm(NetBoxModelImportForm):
|
||||
|
||||
class SiteGroupImportForm(NetBoxModelImportForm):
|
||||
parent = CSVModelChoiceField(
|
||||
label=_('Parent'),
|
||||
queryset=SiteGroup.objects.all(),
|
||||
required=False,
|
||||
to_field_name='name',
|
||||
@@ -82,22 +84,26 @@ class SiteGroupImportForm(NetBoxModelImportForm):
|
||||
|
||||
class SiteImportForm(NetBoxModelImportForm):
|
||||
status = CSVChoiceField(
|
||||
label=_('Status'),
|
||||
choices=SiteStatusChoices,
|
||||
help_text=_('Operational status')
|
||||
)
|
||||
region = CSVModelChoiceField(
|
||||
label=_('Region'),
|
||||
queryset=Region.objects.all(),
|
||||
required=False,
|
||||
to_field_name='name',
|
||||
help_text=_('Assigned region')
|
||||
)
|
||||
group = CSVModelChoiceField(
|
||||
label=_('Group'),
|
||||
queryset=SiteGroup.objects.all(),
|
||||
required=False,
|
||||
to_field_name='name',
|
||||
help_text=_('Assigned group')
|
||||
)
|
||||
tenant = CSVModelChoiceField(
|
||||
label=_('Tenant'),
|
||||
queryset=Tenant.objects.all(),
|
||||
required=False,
|
||||
to_field_name='name',
|
||||
@@ -119,11 +125,13 @@ class SiteImportForm(NetBoxModelImportForm):
|
||||
|
||||
class LocationImportForm(NetBoxModelImportForm):
|
||||
site = CSVModelChoiceField(
|
||||
label=_('Site'),
|
||||
queryset=Site.objects.all(),
|
||||
to_field_name='name',
|
||||
help_text=_('Assigned site')
|
||||
)
|
||||
parent = CSVModelChoiceField(
|
||||
label=_('Parent'),
|
||||
queryset=Location.objects.all(),
|
||||
required=False,
|
||||
to_field_name='name',
|
||||
@@ -133,10 +141,12 @@ class LocationImportForm(NetBoxModelImportForm):
|
||||
}
|
||||
)
|
||||
status = CSVChoiceField(
|
||||
label=_('Status'),
|
||||
choices=LocationStatusChoices,
|
||||
help_text=_('Operational status')
|
||||
)
|
||||
tenant = CSVModelChoiceField(
|
||||
label=_('Tenant'),
|
||||
queryset=Tenant.objects.all(),
|
||||
required=False,
|
||||
to_field_name='name',
|
||||
@@ -161,45 +171,54 @@ class RackRoleImportForm(NetBoxModelImportForm):
|
||||
|
||||
class RackImportForm(NetBoxModelImportForm):
|
||||
site = CSVModelChoiceField(
|
||||
label=_('Site'),
|
||||
queryset=Site.objects.all(),
|
||||
to_field_name='name'
|
||||
)
|
||||
location = CSVModelChoiceField(
|
||||
label=_('Location'),
|
||||
queryset=Location.objects.all(),
|
||||
required=False,
|
||||
to_field_name='name'
|
||||
)
|
||||
tenant = CSVModelChoiceField(
|
||||
label=_('Tenant'),
|
||||
queryset=Tenant.objects.all(),
|
||||
required=False,
|
||||
to_field_name='name',
|
||||
help_text=_('Name of assigned tenant')
|
||||
)
|
||||
status = CSVChoiceField(
|
||||
label=_('Status'),
|
||||
choices=RackStatusChoices,
|
||||
help_text=_('Operational status')
|
||||
)
|
||||
role = CSVModelChoiceField(
|
||||
label=_('Role'),
|
||||
queryset=RackRole.objects.all(),
|
||||
required=False,
|
||||
to_field_name='name',
|
||||
help_text=_('Name of assigned role')
|
||||
)
|
||||
type = CSVChoiceField(
|
||||
label=_('Type'),
|
||||
choices=RackTypeChoices,
|
||||
required=False,
|
||||
help_text=_('Rack type')
|
||||
)
|
||||
width = forms.ChoiceField(
|
||||
label=_('Width'),
|
||||
choices=RackWidthChoices,
|
||||
help_text=_('Rail-to-rail width (in inches)')
|
||||
)
|
||||
outer_unit = CSVChoiceField(
|
||||
label=_('Outer unit'),
|
||||
choices=RackDimensionUnitChoices,
|
||||
required=False,
|
||||
help_text=_('Unit for outer dimensions')
|
||||
)
|
||||
weight_unit = CSVChoiceField(
|
||||
label=_('Weight unit'),
|
||||
choices=WeightUnitChoices,
|
||||
required=False,
|
||||
help_text=_('Unit for rack weights')
|
||||
@@ -225,27 +244,32 @@ class RackImportForm(NetBoxModelImportForm):
|
||||
|
||||
class RackReservationImportForm(NetBoxModelImportForm):
|
||||
site = CSVModelChoiceField(
|
||||
label=_('Site'),
|
||||
queryset=Site.objects.all(),
|
||||
to_field_name='name',
|
||||
help_text=_('Parent site')
|
||||
)
|
||||
location = CSVModelChoiceField(
|
||||
label=_('Location'),
|
||||
queryset=Location.objects.all(),
|
||||
to_field_name='name',
|
||||
required=False,
|
||||
help_text=_("Rack's location (if any)")
|
||||
)
|
||||
rack = CSVModelChoiceField(
|
||||
label=_('Rack'),
|
||||
queryset=Rack.objects.all(),
|
||||
to_field_name='name',
|
||||
help_text=_('Rack')
|
||||
)
|
||||
units = SimpleArrayField(
|
||||
label=_('Units'),
|
||||
base_field=forms.IntegerField(),
|
||||
required=True,
|
||||
help_text=_('Comma-separated list of individual unit numbers')
|
||||
)
|
||||
tenant = CSVModelChoiceField(
|
||||
label=_('Tenant'),
|
||||
queryset=Tenant.objects.all(),
|
||||
required=False,
|
||||
to_field_name='name',
|
||||
@@ -282,21 +306,25 @@ class ManufacturerImportForm(NetBoxModelImportForm):
|
||||
|
||||
class DeviceTypeImportForm(NetBoxModelImportForm):
|
||||
manufacturer = forms.ModelChoiceField(
|
||||
label=_('Manufacturer'),
|
||||
queryset=Manufacturer.objects.all(),
|
||||
to_field_name='name',
|
||||
help_text=_('The manufacturer which produces this device type')
|
||||
)
|
||||
default_platform = forms.ModelChoiceField(
|
||||
label=_('Default platform'),
|
||||
queryset=Platform.objects.all(),
|
||||
to_field_name='name',
|
||||
required=False,
|
||||
help_text=_('The default platform for devices of this type (optional)')
|
||||
)
|
||||
weight = forms.DecimalField(
|
||||
label=_('Weight'),
|
||||
required=False,
|
||||
help_text=_('Device weight'),
|
||||
)
|
||||
weight_unit = CSVChoiceField(
|
||||
label=_('Weight unit'),
|
||||
choices=WeightUnitChoices,
|
||||
required=False,
|
||||
help_text=_('Unit for device weight')
|
||||
@@ -312,14 +340,17 @@ class DeviceTypeImportForm(NetBoxModelImportForm):
|
||||
|
||||
class ModuleTypeImportForm(NetBoxModelImportForm):
|
||||
manufacturer = forms.ModelChoiceField(
|
||||
label=_('Manufacturer'),
|
||||
queryset=Manufacturer.objects.all(),
|
||||
to_field_name='name'
|
||||
)
|
||||
weight = forms.DecimalField(
|
||||
label=_('Weight'),
|
||||
required=False,
|
||||
help_text=_('Module weight'),
|
||||
)
|
||||
weight_unit = CSVChoiceField(
|
||||
label=_('Weight unit'),
|
||||
choices=WeightUnitChoices,
|
||||
required=False,
|
||||
help_text=_('Unit for module weight')
|
||||
@@ -332,6 +363,7 @@ class ModuleTypeImportForm(NetBoxModelImportForm):
|
||||
|
||||
class DeviceRoleImportForm(NetBoxModelImportForm):
|
||||
config_template = CSVModelChoiceField(
|
||||
label=_('Config template'),
|
||||
queryset=ConfigTemplate.objects.all(),
|
||||
to_field_name='name',
|
||||
required=False,
|
||||
@@ -350,12 +382,14 @@ class DeviceRoleImportForm(NetBoxModelImportForm):
|
||||
class PlatformImportForm(NetBoxModelImportForm):
|
||||
slug = SlugField()
|
||||
manufacturer = CSVModelChoiceField(
|
||||
label=_('Manufacturer'),
|
||||
queryset=Manufacturer.objects.all(),
|
||||
required=False,
|
||||
to_field_name='name',
|
||||
help_text=_('Limit platform assignments to this manufacturer')
|
||||
)
|
||||
config_template = CSVModelChoiceField(
|
||||
label=_('Config template'),
|
||||
queryset=ConfigTemplate.objects.all(),
|
||||
to_field_name='name',
|
||||
required=False,
|
||||
@@ -371,43 +405,51 @@ class PlatformImportForm(NetBoxModelImportForm):
|
||||
|
||||
class BaseDeviceImportForm(NetBoxModelImportForm):
|
||||
device_role = CSVModelChoiceField(
|
||||
label=_('Device role'),
|
||||
queryset=DeviceRole.objects.all(),
|
||||
to_field_name='name',
|
||||
help_text=_('Assigned role')
|
||||
)
|
||||
tenant = CSVModelChoiceField(
|
||||
label=_('Tenant'),
|
||||
queryset=Tenant.objects.all(),
|
||||
required=False,
|
||||
to_field_name='name',
|
||||
help_text=_('Assigned tenant')
|
||||
)
|
||||
manufacturer = CSVModelChoiceField(
|
||||
label=_('Manufacturer'),
|
||||
queryset=Manufacturer.objects.all(),
|
||||
to_field_name='name',
|
||||
help_text=_('Device type manufacturer')
|
||||
)
|
||||
device_type = CSVModelChoiceField(
|
||||
label=_('Device type'),
|
||||
queryset=DeviceType.objects.all(),
|
||||
to_field_name='model',
|
||||
help_text=_('Device type model')
|
||||
)
|
||||
platform = CSVModelChoiceField(
|
||||
label=_('Platform'),
|
||||
queryset=Platform.objects.all(),
|
||||
required=False,
|
||||
to_field_name='name',
|
||||
help_text=_('Assigned platform')
|
||||
)
|
||||
status = CSVChoiceField(
|
||||
label=_('Status'),
|
||||
choices=DeviceStatusChoices,
|
||||
help_text=_('Operational status')
|
||||
)
|
||||
virtual_chassis = CSVModelChoiceField(
|
||||
label=_('Virtual chassis'),
|
||||
queryset=VirtualChassis.objects.all(),
|
||||
to_field_name='name',
|
||||
required=False,
|
||||
help_text=_('Virtual chassis')
|
||||
)
|
||||
cluster = CSVModelChoiceField(
|
||||
label=_('Cluster'),
|
||||
queryset=Cluster.objects.all(),
|
||||
to_field_name='name',
|
||||
required=False,
|
||||
@@ -430,45 +472,53 @@ class BaseDeviceImportForm(NetBoxModelImportForm):
|
||||
|
||||
class DeviceImportForm(BaseDeviceImportForm):
|
||||
site = CSVModelChoiceField(
|
||||
label=_('Site'),
|
||||
queryset=Site.objects.all(),
|
||||
to_field_name='name',
|
||||
help_text=_('Assigned site')
|
||||
)
|
||||
location = CSVModelChoiceField(
|
||||
label=_('Location'),
|
||||
queryset=Location.objects.all(),
|
||||
to_field_name='name',
|
||||
required=False,
|
||||
help_text=_("Assigned location (if any)")
|
||||
)
|
||||
rack = CSVModelChoiceField(
|
||||
label=_('Rack'),
|
||||
queryset=Rack.objects.all(),
|
||||
to_field_name='name',
|
||||
required=False,
|
||||
help_text=_("Assigned rack (if any)")
|
||||
)
|
||||
face = CSVChoiceField(
|
||||
label=_('Face'),
|
||||
choices=DeviceFaceChoices,
|
||||
required=False,
|
||||
help_text=_('Mounted rack face')
|
||||
)
|
||||
parent = CSVModelChoiceField(
|
||||
label=_('Parent'),
|
||||
queryset=Device.objects.all(),
|
||||
to_field_name='name',
|
||||
required=False,
|
||||
help_text=_('Parent device (for child devices)')
|
||||
)
|
||||
device_bay = CSVModelChoiceField(
|
||||
label=_('Device bay'),
|
||||
queryset=DeviceBay.objects.all(),
|
||||
to_field_name='name',
|
||||
required=False,
|
||||
help_text=_('Device bay in which this device is installed (for child devices)')
|
||||
)
|
||||
airflow = CSVChoiceField(
|
||||
label=_('Airflow'),
|
||||
choices=DeviceAirflowChoices,
|
||||
required=False,
|
||||
help_text=_('Airflow direction')
|
||||
)
|
||||
config_template = CSVModelChoiceField(
|
||||
label=_('Config template'),
|
||||
queryset=ConfigTemplate.objects.all(),
|
||||
to_field_name='name',
|
||||
required=False,
|
||||
@@ -523,29 +573,35 @@ class DeviceImportForm(BaseDeviceImportForm):
|
||||
|
||||
class ModuleImportForm(ModuleCommonForm, NetBoxModelImportForm):
|
||||
device = CSVModelChoiceField(
|
||||
label=_('Device'),
|
||||
queryset=Device.objects.all(),
|
||||
to_field_name='name',
|
||||
help_text=_('The device in which this module is installed')
|
||||
)
|
||||
module_bay = CSVModelChoiceField(
|
||||
label=_('Module bay'),
|
||||
queryset=ModuleBay.objects.all(),
|
||||
to_field_name='name',
|
||||
help_text=_('The module bay in which this module is installed')
|
||||
)
|
||||
module_type = CSVModelChoiceField(
|
||||
label=_('Module type'),
|
||||
queryset=ModuleType.objects.all(),
|
||||
to_field_name='model',
|
||||
help_text=_('The type of module')
|
||||
)
|
||||
status = CSVChoiceField(
|
||||
label=_('Status'),
|
||||
choices=ModuleStatusChoices,
|
||||
help_text=_('Operational status')
|
||||
)
|
||||
replicate_components = forms.BooleanField(
|
||||
label=_('Replicate components'),
|
||||
required=False,
|
||||
help_text=_('Automatically populate components associated with this module type (enabled by default)')
|
||||
)
|
||||
adopt_components = forms.BooleanField(
|
||||
label=_('Adopt components'),
|
||||
required=False,
|
||||
help_text=_('Adopt already existing components')
|
||||
)
|
||||
@@ -579,15 +635,18 @@ class ModuleImportForm(ModuleCommonForm, NetBoxModelImportForm):
|
||||
|
||||
class ConsolePortImportForm(NetBoxModelImportForm):
|
||||
device = CSVModelChoiceField(
|
||||
label=_('Device'),
|
||||
queryset=Device.objects.all(),
|
||||
to_field_name='name'
|
||||
)
|
||||
type = CSVChoiceField(
|
||||
label=_('Type'),
|
||||
choices=ConsolePortTypeChoices,
|
||||
required=False,
|
||||
help_text=_('Port type')
|
||||
)
|
||||
speed = CSVTypedChoiceField(
|
||||
label=_('Speed'),
|
||||
choices=ConsolePortSpeedChoices,
|
||||
coerce=int,
|
||||
empty_value=None,
|
||||
@@ -602,15 +661,18 @@ class ConsolePortImportForm(NetBoxModelImportForm):
|
||||
|
||||
class ConsoleServerPortImportForm(NetBoxModelImportForm):
|
||||
device = CSVModelChoiceField(
|
||||
label=_('Device'),
|
||||
queryset=Device.objects.all(),
|
||||
to_field_name='name'
|
||||
)
|
||||
type = CSVChoiceField(
|
||||
label=_('Type'),
|
||||
choices=ConsolePortTypeChoices,
|
||||
required=False,
|
||||
help_text=_('Port type')
|
||||
)
|
||||
speed = CSVTypedChoiceField(
|
||||
label=_('Speed'),
|
||||
choices=ConsolePortSpeedChoices,
|
||||
coerce=int,
|
||||
empty_value=None,
|
||||
@@ -625,10 +687,12 @@ class ConsoleServerPortImportForm(NetBoxModelImportForm):
|
||||
|
||||
class PowerPortImportForm(NetBoxModelImportForm):
|
||||
device = CSVModelChoiceField(
|
||||
label=_('Device'),
|
||||
queryset=Device.objects.all(),
|
||||
to_field_name='name'
|
||||
)
|
||||
type = CSVChoiceField(
|
||||
label=_('Type'),
|
||||
choices=PowerPortTypeChoices,
|
||||
required=False,
|
||||
help_text=_('Port type')
|
||||
@@ -643,21 +707,25 @@ class PowerPortImportForm(NetBoxModelImportForm):
|
||||
|
||||
class PowerOutletImportForm(NetBoxModelImportForm):
|
||||
device = CSVModelChoiceField(
|
||||
label=_('Device'),
|
||||
queryset=Device.objects.all(),
|
||||
to_field_name='name'
|
||||
)
|
||||
type = CSVChoiceField(
|
||||
label=_('Type'),
|
||||
choices=PowerOutletTypeChoices,
|
||||
required=False,
|
||||
help_text=_('Outlet type')
|
||||
)
|
||||
power_port = CSVModelChoiceField(
|
||||
label=_('Power port'),
|
||||
queryset=PowerPort.objects.all(),
|
||||
required=False,
|
||||
to_field_name='name',
|
||||
help_text=_('Local power port which feeds this outlet')
|
||||
)
|
||||
feed_leg = CSVChoiceField(
|
||||
label=_('Feed lag'),
|
||||
choices=PowerOutletFeedLegChoices,
|
||||
required=False,
|
||||
help_text=_('Electrical phase (for three-phase circuits)')
|
||||
@@ -692,63 +760,75 @@ class PowerOutletImportForm(NetBoxModelImportForm):
|
||||
|
||||
class InterfaceImportForm(NetBoxModelImportForm):
|
||||
device = CSVModelChoiceField(
|
||||
label=_('Device'),
|
||||
queryset=Device.objects.all(),
|
||||
to_field_name='name'
|
||||
)
|
||||
parent = CSVModelChoiceField(
|
||||
label=_('Parent'),
|
||||
queryset=Interface.objects.all(),
|
||||
required=False,
|
||||
to_field_name='name',
|
||||
help_text=_('Parent interface')
|
||||
)
|
||||
bridge = CSVModelChoiceField(
|
||||
label=_('Bridge'),
|
||||
queryset=Interface.objects.all(),
|
||||
required=False,
|
||||
to_field_name='name',
|
||||
help_text=_('Bridged interface')
|
||||
)
|
||||
lag = CSVModelChoiceField(
|
||||
label=_('Lag'),
|
||||
queryset=Interface.objects.all(),
|
||||
required=False,
|
||||
to_field_name='name',
|
||||
help_text=_('Parent LAG interface')
|
||||
)
|
||||
vdcs = CSVModelMultipleChoiceField(
|
||||
label=_('Vdcs'),
|
||||
queryset=VirtualDeviceContext.objects.all(),
|
||||
required=False,
|
||||
to_field_name='name',
|
||||
help_text='VDC names separated by commas, encased with double quotes (e.g. "vdc1, vdc2, vdc3")'
|
||||
help_text=_('VDC names separated by commas, encased with double quotes (e.g. "vdc1, vdc2, vdc3")')
|
||||
)
|
||||
type = CSVChoiceField(
|
||||
label=_('Type'),
|
||||
choices=InterfaceTypeChoices,
|
||||
help_text=_('Physical medium')
|
||||
)
|
||||
duplex = CSVChoiceField(
|
||||
label=_('Duplex'),
|
||||
choices=InterfaceDuplexChoices,
|
||||
required=False
|
||||
)
|
||||
poe_mode = CSVChoiceField(
|
||||
label=_('Poe mode'),
|
||||
choices=InterfacePoEModeChoices,
|
||||
required=False,
|
||||
help_text=_('PoE mode')
|
||||
)
|
||||
poe_type = CSVChoiceField(
|
||||
label=_('Poe type'),
|
||||
choices=InterfacePoETypeChoices,
|
||||
required=False,
|
||||
help_text=_('PoE type')
|
||||
)
|
||||
mode = CSVChoiceField(
|
||||
label=_('Mode'),
|
||||
choices=InterfaceModeChoices,
|
||||
required=False,
|
||||
help_text=_('IEEE 802.1Q operational mode (for L2 interfaces)')
|
||||
)
|
||||
vrf = CSVModelChoiceField(
|
||||
label=_('VRF'),
|
||||
queryset=VRF.objects.all(),
|
||||
required=False,
|
||||
to_field_name='rd',
|
||||
help_text=_('Assigned VRF')
|
||||
)
|
||||
rf_role = CSVChoiceField(
|
||||
label=_('Rf role'),
|
||||
choices=WirelessRoleChoices,
|
||||
required=False,
|
||||
help_text=_('Wireless role (AP/station)')
|
||||
@@ -792,15 +872,18 @@ class InterfaceImportForm(NetBoxModelImportForm):
|
||||
|
||||
class FrontPortImportForm(NetBoxModelImportForm):
|
||||
device = CSVModelChoiceField(
|
||||
label=_('Device'),
|
||||
queryset=Device.objects.all(),
|
||||
to_field_name='name'
|
||||
)
|
||||
rear_port = CSVModelChoiceField(
|
||||
label=_('Rear port'),
|
||||
queryset=RearPort.objects.all(),
|
||||
to_field_name='name',
|
||||
help_text=_('Corresponding rear port')
|
||||
)
|
||||
type = CSVChoiceField(
|
||||
label=_('Type'),
|
||||
choices=PortTypeChoices,
|
||||
help_text=_('Physical medium classification')
|
||||
)
|
||||
@@ -837,10 +920,12 @@ class FrontPortImportForm(NetBoxModelImportForm):
|
||||
|
||||
class RearPortImportForm(NetBoxModelImportForm):
|
||||
device = CSVModelChoiceField(
|
||||
label=_('Device'),
|
||||
queryset=Device.objects.all(),
|
||||
to_field_name='name'
|
||||
)
|
||||
type = CSVChoiceField(
|
||||
label=_('Type'),
|
||||
help_text=_('Physical medium classification'),
|
||||
choices=PortTypeChoices,
|
||||
)
|
||||
@@ -852,6 +937,7 @@ class RearPortImportForm(NetBoxModelImportForm):
|
||||
|
||||
class ModuleBayImportForm(NetBoxModelImportForm):
|
||||
device = CSVModelChoiceField(
|
||||
label=_('Device'),
|
||||
queryset=Device.objects.all(),
|
||||
to_field_name='name'
|
||||
)
|
||||
@@ -863,10 +949,12 @@ class ModuleBayImportForm(NetBoxModelImportForm):
|
||||
|
||||
class DeviceBayImportForm(NetBoxModelImportForm):
|
||||
device = CSVModelChoiceField(
|
||||
label=_('Device'),
|
||||
queryset=Device.objects.all(),
|
||||
to_field_name='name'
|
||||
)
|
||||
installed_device = CSVModelChoiceField(
|
||||
label=_('Installed device'),
|
||||
queryset=Device.objects.all(),
|
||||
required=False,
|
||||
to_field_name='name',
|
||||
@@ -909,32 +997,38 @@ class DeviceBayImportForm(NetBoxModelImportForm):
|
||||
|
||||
class InventoryItemImportForm(NetBoxModelImportForm):
|
||||
device = CSVModelChoiceField(
|
||||
label=_('Device'),
|
||||
queryset=Device.objects.all(),
|
||||
to_field_name='name'
|
||||
)
|
||||
role = CSVModelChoiceField(
|
||||
label=_('Role'),
|
||||
queryset=InventoryItemRole.objects.all(),
|
||||
to_field_name='name',
|
||||
required=False
|
||||
)
|
||||
manufacturer = CSVModelChoiceField(
|
||||
label=_('Manufacturer'),
|
||||
queryset=Manufacturer.objects.all(),
|
||||
to_field_name='name',
|
||||
required=False
|
||||
)
|
||||
parent = CSVModelChoiceField(
|
||||
label=_('Parent'),
|
||||
queryset=Device.objects.all(),
|
||||
to_field_name='name',
|
||||
required=False,
|
||||
help_text=_('Parent inventory item')
|
||||
)
|
||||
component_type = CSVContentTypeField(
|
||||
label=_('Component type'),
|
||||
queryset=ContentType.objects.all(),
|
||||
limit_choices_to=MODULAR_COMPONENT_MODELS,
|
||||
required=False,
|
||||
help_text=_('Component Type')
|
||||
)
|
||||
component_name = forms.CharField(
|
||||
label=_('Compnent name'),
|
||||
required=False,
|
||||
help_text=_('Component Name')
|
||||
)
|
||||
@@ -1002,52 +1096,62 @@ class InventoryItemRoleImportForm(NetBoxModelImportForm):
|
||||
class CableImportForm(NetBoxModelImportForm):
|
||||
# Termination A
|
||||
side_a_device = CSVModelChoiceField(
|
||||
label=_('Side a device'),
|
||||
queryset=Device.objects.all(),
|
||||
to_field_name='name',
|
||||
help_text=_('Side A device')
|
||||
)
|
||||
side_a_type = CSVContentTypeField(
|
||||
label=_('Side a type'),
|
||||
queryset=ContentType.objects.all(),
|
||||
limit_choices_to=CABLE_TERMINATION_MODELS,
|
||||
help_text=_('Side A type')
|
||||
)
|
||||
side_a_name = forms.CharField(
|
||||
label=_('Side a name'),
|
||||
help_text=_('Side A component name')
|
||||
)
|
||||
|
||||
# Termination B
|
||||
side_b_device = CSVModelChoiceField(
|
||||
label=_('Side b device'),
|
||||
queryset=Device.objects.all(),
|
||||
to_field_name='name',
|
||||
help_text=_('Side B device')
|
||||
)
|
||||
side_b_type = CSVContentTypeField(
|
||||
label=_('Side b type'),
|
||||
queryset=ContentType.objects.all(),
|
||||
limit_choices_to=CABLE_TERMINATION_MODELS,
|
||||
help_text=_('Side B type')
|
||||
)
|
||||
side_b_name = forms.CharField(
|
||||
label=_('Side b name'),
|
||||
help_text=_('Side B component name')
|
||||
)
|
||||
|
||||
# Cable attributes
|
||||
status = CSVChoiceField(
|
||||
label=_('Status'),
|
||||
choices=LinkStatusChoices,
|
||||
required=False,
|
||||
help_text=_('Connection status')
|
||||
)
|
||||
type = CSVChoiceField(
|
||||
label=_('Type'),
|
||||
choices=CableTypeChoices,
|
||||
required=False,
|
||||
help_text=_('Physical medium classification')
|
||||
)
|
||||
tenant = CSVModelChoiceField(
|
||||
label=_('Tenant'),
|
||||
queryset=Tenant.objects.all(),
|
||||
required=False,
|
||||
to_field_name='name',
|
||||
help_text=_('Assigned tenant')
|
||||
)
|
||||
length_unit = CSVChoiceField(
|
||||
label=_('Length unit'),
|
||||
choices=CableLengthUnitChoices,
|
||||
required=False,
|
||||
help_text=_('Length unit')
|
||||
@@ -1110,6 +1214,7 @@ class CableImportForm(NetBoxModelImportForm):
|
||||
|
||||
class VirtualChassisImportForm(NetBoxModelImportForm):
|
||||
master = CSVModelChoiceField(
|
||||
label=_('Master'),
|
||||
queryset=Device.objects.all(),
|
||||
to_field_name='name',
|
||||
required=False,
|
||||
@@ -1127,11 +1232,13 @@ class VirtualChassisImportForm(NetBoxModelImportForm):
|
||||
|
||||
class PowerPanelImportForm(NetBoxModelImportForm):
|
||||
site = CSVModelChoiceField(
|
||||
label=_('Site'),
|
||||
queryset=Site.objects.all(),
|
||||
to_field_name='name',
|
||||
help_text=_('Name of parent site')
|
||||
)
|
||||
location = CSVModelChoiceField(
|
||||
label=_('Location'),
|
||||
queryset=Location.objects.all(),
|
||||
required=False,
|
||||
to_field_name='name'
|
||||
@@ -1153,22 +1260,26 @@ class PowerPanelImportForm(NetBoxModelImportForm):
|
||||
|
||||
class PowerFeedImportForm(NetBoxModelImportForm):
|
||||
site = CSVModelChoiceField(
|
||||
label=_('Site'),
|
||||
queryset=Site.objects.all(),
|
||||
to_field_name='name',
|
||||
help_text=_('Assigned site')
|
||||
)
|
||||
power_panel = CSVModelChoiceField(
|
||||
label=_('Power panel'),
|
||||
queryset=PowerPanel.objects.all(),
|
||||
to_field_name='name',
|
||||
help_text=_('Upstream power panel')
|
||||
)
|
||||
location = CSVModelChoiceField(
|
||||
label=_('Location'),
|
||||
queryset=Location.objects.all(),
|
||||
to_field_name='name',
|
||||
required=False,
|
||||
help_text=_("Rack's location (if any)")
|
||||
)
|
||||
rack = CSVModelChoiceField(
|
||||
label=_('Rack'),
|
||||
queryset=Rack.objects.all(),
|
||||
to_field_name='name',
|
||||
required=False,
|
||||
@@ -1181,18 +1292,22 @@ class PowerFeedImportForm(NetBoxModelImportForm):
|
||||
help_text=_('Assigned tenant')
|
||||
)
|
||||
status = CSVChoiceField(
|
||||
label=_('Status'),
|
||||
choices=PowerFeedStatusChoices,
|
||||
help_text=_('Operational status')
|
||||
)
|
||||
type = CSVChoiceField(
|
||||
label=_('Type'),
|
||||
choices=PowerFeedTypeChoices,
|
||||
help_text=_('Primary or redundant')
|
||||
)
|
||||
supply = CSVChoiceField(
|
||||
label=_('Supply'),
|
||||
choices=PowerFeedSupplyChoices,
|
||||
help_text=_('Supply type (AC/DC)')
|
||||
)
|
||||
phase = CSVChoiceField(
|
||||
label=_('Phase'),
|
||||
choices=PowerFeedPhaseChoices,
|
||||
help_text=_('Single or three-phase')
|
||||
)
|
||||
@@ -1228,11 +1343,13 @@ class PowerFeedImportForm(NetBoxModelImportForm):
|
||||
class VirtualDeviceContextImportForm(NetBoxModelImportForm):
|
||||
|
||||
device = CSVModelChoiceField(
|
||||
label=_('Device'),
|
||||
queryset=Device.objects.all(),
|
||||
to_field_name='name',
|
||||
help_text='Assigned role'
|
||||
)
|
||||
tenant = CSVModelChoiceField(
|
||||
label=_('Tenant'),
|
||||
queryset=Tenant.objects.all(),
|
||||
required=False,
|
||||
to_field_name='name',
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from django import forms
|
||||
from django.utils.translation import gettext as _
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from dcim.choices import *
|
||||
from dcim.constants import *
|
||||
@@ -47,7 +47,7 @@ class InterfaceCommonForm(forms.Form):
|
||||
# Untagged interfaces cannot be assigned tagged VLANs
|
||||
if self.cleaned_data['mode'] == InterfaceModeChoices.MODE_ACCESS and tagged_vlans:
|
||||
raise forms.ValidationError({
|
||||
'mode': "An access interface cannot have tagged VLANs assigned."
|
||||
'mode': _("An access interface cannot have tagged VLANs assigned.")
|
||||
})
|
||||
|
||||
# Remove all tagged VLAN assignments from "tagged all" interfaces
|
||||
@@ -61,8 +61,10 @@ class InterfaceCommonForm(forms.Form):
|
||||
|
||||
if invalid_vlans:
|
||||
raise forms.ValidationError({
|
||||
'tagged_vlans': f"The tagged VLANs ({', '.join(invalid_vlans)}) must belong to the same site as "
|
||||
f"the interface's parent device/VM, or they must be global"
|
||||
'tagged_vlans': _(
|
||||
"The tagged VLANs ({vlans}) must belong to the same site as the interface's parent device/VM, "
|
||||
"or they must be global"
|
||||
).format(vlans=', '.join(invalid_vlans))
|
||||
})
|
||||
|
||||
|
||||
@@ -105,7 +107,7 @@ class ModuleCommonForm(forms.Form):
|
||||
# Installing modules with placeholders require that the bay has a position value
|
||||
if MODULE_TOKEN in template.name and not module_bay.position:
|
||||
raise forms.ValidationError(
|
||||
"Cannot install module with placeholder values in a module bay with no position defined"
|
||||
_("Cannot install module with placeholder values in a module bay with no position defined.")
|
||||
)
|
||||
|
||||
resolved_name = template.name.replace(MODULE_TOKEN, module_bay.position)
|
||||
@@ -114,12 +116,17 @@ class ModuleCommonForm(forms.Form):
|
||||
# It is not possible to adopt components already belonging to a module
|
||||
if adopt_components and existing_item and existing_item.module:
|
||||
raise forms.ValidationError(
|
||||
f"Cannot adopt {template.component_model.__name__} '{resolved_name}' as it already belongs "
|
||||
f"to a module"
|
||||
_("Cannot adopt {name} '{resolved_name}' as it already belongs to a module").format(
|
||||
name=template.component_model.__name__,
|
||||
resolved_name=resolved_name
|
||||
)
|
||||
)
|
||||
|
||||
# If we are not adopting components we error if the component exists
|
||||
if not adopt_components and resolved_name in installed_components:
|
||||
raise forms.ValidationError(
|
||||
f"{template.component_model.__name__} - {resolved_name} already exists"
|
||||
_("{name} - {resolved_name} already exists").format(
|
||||
name=template.component_model.__name__,
|
||||
resolved_name=resolved_name
|
||||
)
|
||||
)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from django import forms
|
||||
from django.utils.translation import gettext as _
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from circuits.models import Circuit, CircuitTermination
|
||||
from dcim.models import *
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from django import forms
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.utils.translation import gettext as _
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from dcim.choices import *
|
||||
from dcim.constants import *
|
||||
@@ -56,9 +56,11 @@ __all__ = (
|
||||
|
||||
class DeviceComponentFilterForm(NetBoxModelFilterSetForm):
|
||||
name = forms.CharField(
|
||||
label=_('Name'),
|
||||
required=False
|
||||
)
|
||||
label = forms.CharField(
|
||||
label=_('Label'),
|
||||
required=False
|
||||
)
|
||||
region_id = DynamicModelMultipleChoiceField(
|
||||
@@ -130,7 +132,7 @@ class RegionFilterForm(ContactModelFilterForm, NetBoxModelFilterSetForm):
|
||||
model = Region
|
||||
fieldsets = (
|
||||
(None, ('q', 'filter_id', 'tag', 'parent_id')),
|
||||
('Contacts', ('contact', 'contact_role', 'contact_group'))
|
||||
(_('Contacts'), ('contact', 'contact_role', 'contact_group'))
|
||||
)
|
||||
parent_id = DynamicModelMultipleChoiceField(
|
||||
queryset=Region.objects.all(),
|
||||
@@ -144,7 +146,7 @@ class SiteGroupFilterForm(ContactModelFilterForm, NetBoxModelFilterSetForm):
|
||||
model = SiteGroup
|
||||
fieldsets = (
|
||||
(None, ('q', 'filter_id', 'tag', 'parent_id')),
|
||||
('Contacts', ('contact', 'contact_role', 'contact_group'))
|
||||
(_('Contacts'), ('contact', 'contact_role', 'contact_group'))
|
||||
)
|
||||
parent_id = DynamicModelMultipleChoiceField(
|
||||
queryset=SiteGroup.objects.all(),
|
||||
@@ -158,11 +160,12 @@ class SiteFilterForm(TenancyFilterForm, ContactModelFilterForm, NetBoxModelFilte
|
||||
model = Site
|
||||
fieldsets = (
|
||||
(None, ('q', 'filter_id', 'tag')),
|
||||
('Attributes', ('status', 'region_id', 'group_id', 'asn_id')),
|
||||
('Tenant', ('tenant_group_id', 'tenant_id')),
|
||||
('Contacts', ('contact', 'contact_role', 'contact_group')),
|
||||
(_('Attributes'), ('status', 'region_id', 'group_id', 'asn_id')),
|
||||
(_('Tenant'), ('tenant_group_id', 'tenant_id')),
|
||||
(_('Contacts'), ('contact', 'contact_role', 'contact_group')),
|
||||
)
|
||||
status = forms.MultipleChoiceField(
|
||||
label=_('Status'),
|
||||
choices=SiteStatusChoices,
|
||||
required=False
|
||||
)
|
||||
@@ -188,9 +191,9 @@ class LocationFilterForm(TenancyFilterForm, ContactModelFilterForm, NetBoxModelF
|
||||
model = Location
|
||||
fieldsets = (
|
||||
(None, ('q', 'filter_id', 'tag')),
|
||||
('Attributes', ('region_id', 'site_group_id', 'site_id', 'parent_id', 'status')),
|
||||
('Tenant', ('tenant_group_id', 'tenant_id')),
|
||||
('Contacts', ('contact', 'contact_role', 'contact_group')),
|
||||
(_('Attributes'), ('region_id', 'site_group_id', 'site_id', 'parent_id', 'status')),
|
||||
(_('Tenant'), ('tenant_group_id', 'tenant_id')),
|
||||
(_('Contacts'), ('contact', 'contact_role', 'contact_group')),
|
||||
)
|
||||
region_id = DynamicModelMultipleChoiceField(
|
||||
queryset=Region.objects.all(),
|
||||
@@ -221,6 +224,7 @@ class LocationFilterForm(TenancyFilterForm, ContactModelFilterForm, NetBoxModelF
|
||||
label=_('Parent')
|
||||
)
|
||||
status = forms.MultipleChoiceField(
|
||||
label=_('Status'),
|
||||
choices=LocationStatusChoices,
|
||||
required=False
|
||||
)
|
||||
@@ -236,12 +240,12 @@ class RackFilterForm(TenancyFilterForm, ContactModelFilterForm, NetBoxModelFilte
|
||||
model = Rack
|
||||
fieldsets = (
|
||||
(None, ('q', 'filter_id', 'tag')),
|
||||
('Location', ('region_id', 'site_group_id', 'site_id', 'location_id')),
|
||||
('Function', ('status', 'role_id')),
|
||||
('Hardware', ('type', 'width', 'serial', 'asset_tag')),
|
||||
('Tenant', ('tenant_group_id', 'tenant_id')),
|
||||
('Contacts', ('contact', 'contact_role', 'contact_group')),
|
||||
('Weight', ('weight', 'max_weight', 'weight_unit')),
|
||||
(_('Location'), ('region_id', 'site_group_id', 'site_id', 'location_id')),
|
||||
(_('Function'), ('status', 'role_id')),
|
||||
(_('Hardware'), ('type', 'width', 'serial', 'asset_tag')),
|
||||
(_('Tenant'), ('tenant_group_id', 'tenant_id')),
|
||||
(_('Contacts'), ('contact', 'contact_role', 'contact_group')),
|
||||
(_('Weight'), ('weight', 'max_weight', 'weight_unit')),
|
||||
)
|
||||
region_id = DynamicModelMultipleChoiceField(
|
||||
queryset=Region.objects.all(),
|
||||
@@ -271,14 +275,17 @@ class RackFilterForm(TenancyFilterForm, ContactModelFilterForm, NetBoxModelFilte
|
||||
label=_('Location')
|
||||
)
|
||||
status = forms.MultipleChoiceField(
|
||||
label=_('Status'),
|
||||
choices=RackStatusChoices,
|
||||
required=False
|
||||
)
|
||||
type = forms.MultipleChoiceField(
|
||||
label=_('Type'),
|
||||
choices=RackTypeChoices,
|
||||
required=False
|
||||
)
|
||||
width = forms.MultipleChoiceField(
|
||||
label=_('Width'),
|
||||
choices=RackWidthChoices,
|
||||
required=False
|
||||
)
|
||||
@@ -289,21 +296,26 @@ class RackFilterForm(TenancyFilterForm, ContactModelFilterForm, NetBoxModelFilte
|
||||
label=_('Role')
|
||||
)
|
||||
serial = forms.CharField(
|
||||
label=_('Serial'),
|
||||
required=False
|
||||
)
|
||||
asset_tag = forms.CharField(
|
||||
label=_('Asset tag'),
|
||||
required=False
|
||||
)
|
||||
tag = TagFilterField(model)
|
||||
weight = forms.DecimalField(
|
||||
label=_('Weight'),
|
||||
required=False,
|
||||
min_value=1
|
||||
)
|
||||
max_weight = forms.IntegerField(
|
||||
label=_('Max weight'),
|
||||
required=False,
|
||||
min_value=1
|
||||
)
|
||||
weight_unit = forms.ChoiceField(
|
||||
label=_('Weight unit'),
|
||||
choices=add_blank_choice(WeightUnitChoices),
|
||||
required=False
|
||||
)
|
||||
@@ -312,12 +324,12 @@ class RackFilterForm(TenancyFilterForm, ContactModelFilterForm, NetBoxModelFilte
|
||||
class RackElevationFilterForm(RackFilterForm):
|
||||
fieldsets = (
|
||||
(None, ('q', 'filter_id', 'tag')),
|
||||
('Location', ('region_id', 'site_group_id', 'site_id', 'location_id', 'id')),
|
||||
('Function', ('status', 'role_id')),
|
||||
('Hardware', ('type', 'width', 'serial', 'asset_tag')),
|
||||
('Tenant', ('tenant_group_id', 'tenant_id')),
|
||||
('Contacts', ('contact', 'contact_role', 'contact_group')),
|
||||
('Weight', ('weight', 'max_weight', 'weight_unit')),
|
||||
(_('Location'), ('region_id', 'site_group_id', 'site_id', 'location_id', 'id')),
|
||||
(_('Function'), ('status', 'role_id')),
|
||||
(_('Hardware'), ('type', 'width', 'serial', 'asset_tag')),
|
||||
(_('Tenant'), ('tenant_group_id', 'tenant_id')),
|
||||
(_('Contacts'), ('contact', 'contact_role', 'contact_group')),
|
||||
(_('Weight'), ('weight', 'max_weight', 'weight_unit')),
|
||||
)
|
||||
id = DynamicModelMultipleChoiceField(
|
||||
queryset=Rack.objects.all(),
|
||||
@@ -334,9 +346,9 @@ class RackReservationFilterForm(TenancyFilterForm, NetBoxModelFilterSetForm):
|
||||
model = RackReservation
|
||||
fieldsets = (
|
||||
(None, ('q', 'filter_id', 'tag')),
|
||||
('User', ('user_id',)),
|
||||
('Rack', ('region_id', 'site_group_id', 'site_id', 'location_id', 'rack_id')),
|
||||
('Tenant', ('tenant_group_id', 'tenant_id')),
|
||||
(_('User'), ('user_id',)),
|
||||
(_('Rack'), ('region_id', 'site_group_id', 'site_id', 'location_id', 'rack_id')),
|
||||
(_('Tenant'), ('tenant_group_id', 'tenant_id')),
|
||||
)
|
||||
region_id = DynamicModelMultipleChoiceField(
|
||||
queryset=Region.objects.all(),
|
||||
@@ -390,7 +402,7 @@ class ManufacturerFilterForm(ContactModelFilterForm, NetBoxModelFilterSetForm):
|
||||
model = Manufacturer
|
||||
fieldsets = (
|
||||
(None, ('q', 'filter_id', 'tag')),
|
||||
('Contacts', ('contact', 'contact_role', 'contact_group'))
|
||||
(_('Contacts'), ('contact', 'contact_role', 'contact_group'))
|
||||
)
|
||||
tag = TagFilterField(model)
|
||||
|
||||
@@ -399,13 +411,13 @@ class DeviceTypeFilterForm(NetBoxModelFilterSetForm):
|
||||
model = DeviceType
|
||||
fieldsets = (
|
||||
(None, ('q', 'filter_id', 'tag')),
|
||||
('Hardware', ('manufacturer_id', 'default_platform_id', 'part_number', 'subdevice_role', 'airflow')),
|
||||
('Images', ('has_front_image', 'has_rear_image')),
|
||||
('Components', (
|
||||
(_('Hardware'), ('manufacturer_id', 'default_platform_id', 'part_number', 'subdevice_role', 'airflow')),
|
||||
(_('Images'), ('has_front_image', 'has_rear_image')),
|
||||
(_('Components'), (
|
||||
'console_ports', 'console_server_ports', 'power_ports', 'power_outlets', 'interfaces',
|
||||
'pass_through_ports', 'device_bays', 'module_bays', 'inventory_items',
|
||||
)),
|
||||
('Weight', ('weight', 'weight_unit')),
|
||||
(_('Weight'), ('weight', 'weight_unit')),
|
||||
)
|
||||
manufacturer_id = DynamicModelMultipleChoiceField(
|
||||
queryset=Manufacturer.objects.all(),
|
||||
@@ -418,98 +430,103 @@ class DeviceTypeFilterForm(NetBoxModelFilterSetForm):
|
||||
label=_('Default platform')
|
||||
)
|
||||
part_number = forms.CharField(
|
||||
label=_('Part number'),
|
||||
required=False
|
||||
)
|
||||
subdevice_role = forms.MultipleChoiceField(
|
||||
label=_('Subdevice role'),
|
||||
choices=add_blank_choice(SubdeviceRoleChoices),
|
||||
required=False
|
||||
)
|
||||
airflow = forms.MultipleChoiceField(
|
||||
label=_('Airflow'),
|
||||
choices=add_blank_choice(DeviceAirflowChoices),
|
||||
required=False
|
||||
)
|
||||
has_front_image = forms.NullBooleanField(
|
||||
required=False,
|
||||
label='Has a front image',
|
||||
label=_('Has a front image'),
|
||||
widget=forms.Select(
|
||||
choices=BOOLEAN_WITH_BLANK_CHOICES
|
||||
)
|
||||
)
|
||||
has_rear_image = forms.NullBooleanField(
|
||||
required=False,
|
||||
label='Has a rear image',
|
||||
label=_('Has a rear image'),
|
||||
widget=forms.Select(
|
||||
choices=BOOLEAN_WITH_BLANK_CHOICES
|
||||
)
|
||||
)
|
||||
console_ports = forms.NullBooleanField(
|
||||
required=False,
|
||||
label='Has console ports',
|
||||
label=_('Has console ports'),
|
||||
widget=forms.Select(
|
||||
choices=BOOLEAN_WITH_BLANK_CHOICES
|
||||
)
|
||||
)
|
||||
console_server_ports = forms.NullBooleanField(
|
||||
required=False,
|
||||
label='Has console server ports',
|
||||
label=_('Has console server ports'),
|
||||
widget=forms.Select(
|
||||
choices=BOOLEAN_WITH_BLANK_CHOICES
|
||||
)
|
||||
)
|
||||
power_ports = forms.NullBooleanField(
|
||||
required=False,
|
||||
label='Has power ports',
|
||||
label=_('Has power ports'),
|
||||
widget=forms.Select(
|
||||
choices=BOOLEAN_WITH_BLANK_CHOICES
|
||||
)
|
||||
)
|
||||
power_outlets = forms.NullBooleanField(
|
||||
required=False,
|
||||
label='Has power outlets',
|
||||
label=_('Has power outlets'),
|
||||
widget=forms.Select(
|
||||
choices=BOOLEAN_WITH_BLANK_CHOICES
|
||||
)
|
||||
)
|
||||
interfaces = forms.NullBooleanField(
|
||||
required=False,
|
||||
label='Has interfaces',
|
||||
label=_('Has interfaces'),
|
||||
widget=forms.Select(
|
||||
choices=BOOLEAN_WITH_BLANK_CHOICES
|
||||
)
|
||||
)
|
||||
pass_through_ports = forms.NullBooleanField(
|
||||
required=False,
|
||||
label='Has pass-through ports',
|
||||
label=_('Has pass-through ports'),
|
||||
widget=forms.Select(
|
||||
choices=BOOLEAN_WITH_BLANK_CHOICES
|
||||
)
|
||||
)
|
||||
device_bays = forms.NullBooleanField(
|
||||
required=False,
|
||||
label='Has device bays',
|
||||
label=_('Has device bays'),
|
||||
widget=forms.Select(
|
||||
choices=BOOLEAN_WITH_BLANK_CHOICES
|
||||
)
|
||||
)
|
||||
module_bays = forms.NullBooleanField(
|
||||
required=False,
|
||||
label='Has module bays',
|
||||
label=_('Has module bays'),
|
||||
widget=forms.Select(
|
||||
choices=BOOLEAN_WITH_BLANK_CHOICES
|
||||
)
|
||||
)
|
||||
inventory_items = forms.NullBooleanField(
|
||||
required=False,
|
||||
label='Has inventory items',
|
||||
label=_('Has inventory items'),
|
||||
widget=forms.Select(
|
||||
choices=BOOLEAN_WITH_BLANK_CHOICES
|
||||
)
|
||||
)
|
||||
tag = TagFilterField(model)
|
||||
weight = forms.DecimalField(
|
||||
label=_('Weight'),
|
||||
required=False
|
||||
)
|
||||
weight_unit = forms.ChoiceField(
|
||||
label=_('Weight unit'),
|
||||
choices=add_blank_choice(WeightUnitChoices),
|
||||
required=False
|
||||
)
|
||||
@@ -519,12 +536,12 @@ class ModuleTypeFilterForm(NetBoxModelFilterSetForm):
|
||||
model = ModuleType
|
||||
fieldsets = (
|
||||
(None, ('q', 'filter_id', 'tag')),
|
||||
('Hardware', ('manufacturer_id', 'part_number')),
|
||||
('Components', (
|
||||
(_('Hardware'), ('manufacturer_id', 'part_number')),
|
||||
(_('Components'), (
|
||||
'console_ports', 'console_server_ports', 'power_ports', 'power_outlets', 'interfaces',
|
||||
'pass_through_ports',
|
||||
)),
|
||||
('Weight', ('weight', 'weight_unit')),
|
||||
(_('Weight'), ('weight', 'weight_unit')),
|
||||
)
|
||||
manufacturer_id = DynamicModelMultipleChoiceField(
|
||||
queryset=Manufacturer.objects.all(),
|
||||
@@ -533,55 +550,58 @@ class ModuleTypeFilterForm(NetBoxModelFilterSetForm):
|
||||
fetch_trigger='open'
|
||||
)
|
||||
part_number = forms.CharField(
|
||||
label=_('Part number'),
|
||||
required=False
|
||||
)
|
||||
console_ports = forms.NullBooleanField(
|
||||
required=False,
|
||||
label='Has console ports',
|
||||
label=_('Has console ports'),
|
||||
widget=forms.Select(
|
||||
choices=BOOLEAN_WITH_BLANK_CHOICES
|
||||
)
|
||||
)
|
||||
console_server_ports = forms.NullBooleanField(
|
||||
required=False,
|
||||
label='Has console server ports',
|
||||
label=_('Has console server ports'),
|
||||
widget=forms.Select(
|
||||
choices=BOOLEAN_WITH_BLANK_CHOICES
|
||||
)
|
||||
)
|
||||
power_ports = forms.NullBooleanField(
|
||||
required=False,
|
||||
label='Has power ports',
|
||||
label=_('Has power ports'),
|
||||
widget=forms.Select(
|
||||
choices=BOOLEAN_WITH_BLANK_CHOICES
|
||||
)
|
||||
)
|
||||
power_outlets = forms.NullBooleanField(
|
||||
required=False,
|
||||
label='Has power outlets',
|
||||
label=_('Has power outlets'),
|
||||
widget=forms.Select(
|
||||
choices=BOOLEAN_WITH_BLANK_CHOICES
|
||||
)
|
||||
)
|
||||
interfaces = forms.NullBooleanField(
|
||||
required=False,
|
||||
label='Has interfaces',
|
||||
label=_('Has interfaces'),
|
||||
widget=forms.Select(
|
||||
choices=BOOLEAN_WITH_BLANK_CHOICES
|
||||
)
|
||||
)
|
||||
pass_through_ports = forms.NullBooleanField(
|
||||
required=False,
|
||||
label='Has pass-through ports',
|
||||
label=_('Has pass-through ports'),
|
||||
widget=forms.Select(
|
||||
choices=BOOLEAN_WITH_BLANK_CHOICES
|
||||
)
|
||||
)
|
||||
tag = TagFilterField(model)
|
||||
weight = forms.DecimalField(
|
||||
label=_('Weight'),
|
||||
required=False
|
||||
)
|
||||
weight_unit = forms.ChoiceField(
|
||||
label=_('Weight unit'),
|
||||
choices=add_blank_choice(WeightUnitChoices),
|
||||
required=False
|
||||
)
|
||||
@@ -621,15 +641,17 @@ class DeviceFilterForm(
|
||||
model = Device
|
||||
fieldsets = (
|
||||
(None, ('q', 'filter_id', 'tag')),
|
||||
('Location', ('region_id', 'site_group_id', 'site_id', 'location_id', 'rack_id')),
|
||||
('Operation', ('status', 'role_id', 'airflow', 'serial', 'asset_tag', 'mac_address')),
|
||||
('Hardware', ('manufacturer_id', 'device_type_id', 'platform_id')),
|
||||
('Tenant', ('tenant_group_id', 'tenant_id')),
|
||||
('Contacts', ('contact', 'contact_role', 'contact_group')),
|
||||
('Components', (
|
||||
(_('Location'), ('region_id', 'site_group_id', 'site_id', 'location_id', 'rack_id')),
|
||||
(_('Operation'), ('status', 'role_id', 'airflow', 'serial', 'asset_tag', 'mac_address')),
|
||||
(_('Hardware'), ('manufacturer_id', 'device_type_id', 'platform_id')),
|
||||
(_('Tenant'), ('tenant_group_id', 'tenant_id')),
|
||||
(_('Contacts'), ('contact', 'contact_role', 'contact_group')),
|
||||
(_('Components'), (
|
||||
'console_ports', 'console_server_ports', 'power_ports', 'power_outlets', 'interfaces', 'pass_through_ports',
|
||||
)),
|
||||
('Miscellaneous', ('has_primary_ip', 'has_oob_ip', 'virtual_chassis_member', 'config_template_id', 'local_context_data'))
|
||||
(_('Miscellaneous'), (
|
||||
'has_primary_ip', 'has_oob_ip', 'virtual_chassis_member', 'config_template_id', 'local_context_data',
|
||||
))
|
||||
)
|
||||
region_id = DynamicModelMultipleChoiceField(
|
||||
queryset=Region.objects.all(),
|
||||
@@ -694,22 +716,26 @@ class DeviceFilterForm(
|
||||
label=_('Platform')
|
||||
)
|
||||
status = forms.MultipleChoiceField(
|
||||
label=_('Status'),
|
||||
choices=DeviceStatusChoices,
|
||||
required=False
|
||||
)
|
||||
airflow = forms.MultipleChoiceField(
|
||||
label=_('Airflow'),
|
||||
choices=add_blank_choice(DeviceAirflowChoices),
|
||||
required=False
|
||||
)
|
||||
serial = forms.CharField(
|
||||
label=_('Serial'),
|
||||
required=False
|
||||
)
|
||||
asset_tag = forms.CharField(
|
||||
label=_('Asset tag'),
|
||||
required=False
|
||||
)
|
||||
mac_address = forms.CharField(
|
||||
required=False,
|
||||
label='MAC address'
|
||||
label=_('MAC address')
|
||||
)
|
||||
config_template_id = DynamicModelMultipleChoiceField(
|
||||
queryset=ConfigTemplate.objects.all(),
|
||||
@@ -718,7 +744,7 @@ class DeviceFilterForm(
|
||||
)
|
||||
has_primary_ip = forms.NullBooleanField(
|
||||
required=False,
|
||||
label='Has a primary IP',
|
||||
label=_('Has a primary IP'),
|
||||
widget=forms.Select(
|
||||
choices=BOOLEAN_WITH_BLANK_CHOICES
|
||||
)
|
||||
@@ -732,49 +758,49 @@ class DeviceFilterForm(
|
||||
)
|
||||
virtual_chassis_member = forms.NullBooleanField(
|
||||
required=False,
|
||||
label='Virtual chassis member',
|
||||
label=_('Virtual chassis member'),
|
||||
widget=forms.Select(
|
||||
choices=BOOLEAN_WITH_BLANK_CHOICES
|
||||
)
|
||||
)
|
||||
console_ports = forms.NullBooleanField(
|
||||
required=False,
|
||||
label='Has console ports',
|
||||
label=_('Has console ports'),
|
||||
widget=forms.Select(
|
||||
choices=BOOLEAN_WITH_BLANK_CHOICES
|
||||
)
|
||||
)
|
||||
console_server_ports = forms.NullBooleanField(
|
||||
required=False,
|
||||
label='Has console server ports',
|
||||
label=_('Has console server ports'),
|
||||
widget=forms.Select(
|
||||
choices=BOOLEAN_WITH_BLANK_CHOICES
|
||||
)
|
||||
)
|
||||
power_ports = forms.NullBooleanField(
|
||||
required=False,
|
||||
label='Has power ports',
|
||||
label=_('Has power ports'),
|
||||
widget=forms.Select(
|
||||
choices=BOOLEAN_WITH_BLANK_CHOICES
|
||||
)
|
||||
)
|
||||
power_outlets = forms.NullBooleanField(
|
||||
required=False,
|
||||
label='Has power outlets',
|
||||
label=_('Has power outlets'),
|
||||
widget=forms.Select(
|
||||
choices=BOOLEAN_WITH_BLANK_CHOICES
|
||||
)
|
||||
)
|
||||
interfaces = forms.NullBooleanField(
|
||||
required=False,
|
||||
label='Has interfaces',
|
||||
label=_('Has interfaces'),
|
||||
widget=forms.Select(
|
||||
choices=BOOLEAN_WITH_BLANK_CHOICES
|
||||
)
|
||||
)
|
||||
pass_through_ports = forms.NullBooleanField(
|
||||
required=False,
|
||||
label='Has pass-through ports',
|
||||
label=_('Has pass-through ports'),
|
||||
widget=forms.Select(
|
||||
choices=BOOLEAN_WITH_BLANK_CHOICES
|
||||
)
|
||||
@@ -789,8 +815,8 @@ class VirtualDeviceContextFilterForm(
|
||||
model = VirtualDeviceContext
|
||||
fieldsets = (
|
||||
(None, ('q', 'filter_id', 'tag')),
|
||||
('Attributes', ('device', 'status', 'has_primary_ip')),
|
||||
('Tenant', ('tenant_group_id', 'tenant_id')),
|
||||
(_('Attributes'), ('device', 'status', 'has_primary_ip')),
|
||||
(_('Tenant'), ('tenant_group_id', 'tenant_id')),
|
||||
)
|
||||
device = DynamicModelMultipleChoiceField(
|
||||
queryset=Device.objects.all(),
|
||||
@@ -799,12 +825,13 @@ class VirtualDeviceContextFilterForm(
|
||||
fetch_trigger='open'
|
||||
)
|
||||
status = forms.MultipleChoiceField(
|
||||
label=_('Status'),
|
||||
required=False,
|
||||
choices=add_blank_choice(VirtualDeviceContextStatusChoices)
|
||||
)
|
||||
has_primary_ip = forms.NullBooleanField(
|
||||
required=False,
|
||||
label='Has a primary IP',
|
||||
label=_('Has a primary IP'),
|
||||
widget=forms.Select(
|
||||
choices=BOOLEAN_WITH_BLANK_CHOICES
|
||||
)
|
||||
@@ -816,7 +843,7 @@ class ModuleFilterForm(LocalConfigContextFilterForm, TenancyFilterForm, NetBoxMo
|
||||
model = Module
|
||||
fieldsets = (
|
||||
(None, ('q', 'filter_id', 'tag')),
|
||||
('Hardware', ('manufacturer_id', 'module_type_id', 'status', 'serial', 'asset_tag')),
|
||||
(_('Hardware'), ('manufacturer_id', 'module_type_id', 'status', 'serial', 'asset_tag')),
|
||||
)
|
||||
manufacturer_id = DynamicModelMultipleChoiceField(
|
||||
queryset=Manufacturer.objects.all(),
|
||||
@@ -834,13 +861,16 @@ class ModuleFilterForm(LocalConfigContextFilterForm, TenancyFilterForm, NetBoxMo
|
||||
fetch_trigger='open'
|
||||
)
|
||||
status = forms.MultipleChoiceField(
|
||||
label=_('Status'),
|
||||
choices=ModuleStatusChoices,
|
||||
required=False
|
||||
)
|
||||
serial = forms.CharField(
|
||||
label=_('Serial'),
|
||||
required=False
|
||||
)
|
||||
asset_tag = forms.CharField(
|
||||
label=_('Asset tag'),
|
||||
required=False
|
||||
)
|
||||
tag = TagFilterField(model)
|
||||
@@ -850,8 +880,8 @@ class VirtualChassisFilterForm(TenancyFilterForm, NetBoxModelFilterSetForm):
|
||||
model = VirtualChassis
|
||||
fieldsets = (
|
||||
(None, ('q', 'filter_id', 'tag')),
|
||||
('Location', ('region_id', 'site_group_id', 'site_id')),
|
||||
('Tenant', ('tenant_group_id', 'tenant_id')),
|
||||
(_('Location'), ('region_id', 'site_group_id', 'site_id')),
|
||||
(_('Tenant'), ('tenant_group_id', 'tenant_id')),
|
||||
)
|
||||
region_id = DynamicModelMultipleChoiceField(
|
||||
queryset=Region.objects.all(),
|
||||
@@ -879,9 +909,9 @@ class CableFilterForm(TenancyFilterForm, NetBoxModelFilterSetForm):
|
||||
model = Cable
|
||||
fieldsets = (
|
||||
(None, ('q', 'filter_id', 'tag')),
|
||||
('Location', ('site_id', 'location_id', 'rack_id', 'device_id')),
|
||||
('Attributes', ('type', 'status', 'color', 'length', 'length_unit')),
|
||||
('Tenant', ('tenant_group_id', 'tenant_id')),
|
||||
(_('Location'), ('site_id', 'location_id', 'rack_id', 'device_id')),
|
||||
(_('Attributes'), ('type', 'status', 'color', 'length', 'length_unit')),
|
||||
(_('Tenant'), ('tenant_group_id', 'tenant_id')),
|
||||
)
|
||||
region_id = DynamicModelMultipleChoiceField(
|
||||
queryset=Region.objects.all(),
|
||||
@@ -927,20 +957,25 @@ class CableFilterForm(TenancyFilterForm, NetBoxModelFilterSetForm):
|
||||
label=_('Device')
|
||||
)
|
||||
type = forms.MultipleChoiceField(
|
||||
label=_('Type'),
|
||||
choices=add_blank_choice(CableTypeChoices),
|
||||
required=False
|
||||
)
|
||||
status = forms.MultipleChoiceField(
|
||||
label=_('Status'),
|
||||
required=False,
|
||||
choices=add_blank_choice(LinkStatusChoices)
|
||||
)
|
||||
color = ColorField(
|
||||
label=_('Color'),
|
||||
required=False
|
||||
)
|
||||
length = forms.IntegerField(
|
||||
label=_('Length'),
|
||||
required=False
|
||||
)
|
||||
length_unit = forms.ChoiceField(
|
||||
label=_('Length unit'),
|
||||
choices=add_blank_choice(CableLengthUnitChoices),
|
||||
required=False
|
||||
)
|
||||
@@ -951,8 +986,8 @@ class PowerPanelFilterForm(ContactModelFilterForm, NetBoxModelFilterSetForm):
|
||||
model = PowerPanel
|
||||
fieldsets = (
|
||||
(None, ('q', 'filter_id', 'tag')),
|
||||
('Location', ('region_id', 'site_group_id', 'site_id', 'location_id')),
|
||||
('Contacts', ('contact', 'contact_role', 'contact_group')),
|
||||
(_('Location'), ('region_id', 'site_group_id', 'site_id', 'location_id')),
|
||||
(_('Contacts'), ('contact', 'contact_role', 'contact_group')),
|
||||
)
|
||||
region_id = DynamicModelMultipleChoiceField(
|
||||
queryset=Region.objects.all(),
|
||||
@@ -989,9 +1024,9 @@ class PowerFeedFilterForm(TenancyFilterForm, NetBoxModelFilterSetForm):
|
||||
model = PowerFeed
|
||||
fieldsets = (
|
||||
(None, ('q', 'filter_id', 'tag')),
|
||||
('Location', ('region_id', 'site_group_id', 'site_id', 'power_panel_id', 'rack_id')),
|
||||
('Tenant', ('tenant_group_id', 'tenant_id')),
|
||||
('Attributes', ('status', 'type', 'supply', 'phase', 'voltage', 'amperage', 'max_utilization')),
|
||||
(_('Location'), ('region_id', 'site_group_id', 'site_id', 'power_panel_id', 'rack_id')),
|
||||
(_('Tenant'), ('tenant_group_id', 'tenant_id')),
|
||||
(_('Attributes'), ('status', 'type', 'supply', 'phase', 'voltage', 'amperage', 'max_utilization')),
|
||||
)
|
||||
region_id = DynamicModelMultipleChoiceField(
|
||||
queryset=Region.objects.all(),
|
||||
@@ -1030,28 +1065,35 @@ class PowerFeedFilterForm(TenancyFilterForm, NetBoxModelFilterSetForm):
|
||||
label=_('Rack')
|
||||
)
|
||||
status = forms.MultipleChoiceField(
|
||||
label=_('Status'),
|
||||
choices=PowerFeedStatusChoices,
|
||||
required=False
|
||||
)
|
||||
type = forms.ChoiceField(
|
||||
label=_('Type'),
|
||||
choices=add_blank_choice(PowerFeedTypeChoices),
|
||||
required=False
|
||||
)
|
||||
supply = forms.ChoiceField(
|
||||
label=_('Supply'),
|
||||
choices=add_blank_choice(PowerFeedSupplyChoices),
|
||||
required=False
|
||||
)
|
||||
phase = forms.ChoiceField(
|
||||
label=_('Phase'),
|
||||
choices=add_blank_choice(PowerFeedPhaseChoices),
|
||||
required=False
|
||||
)
|
||||
voltage = forms.IntegerField(
|
||||
label=_('Voltage'),
|
||||
required=False
|
||||
)
|
||||
amperage = forms.IntegerField(
|
||||
label=_('Amperage'),
|
||||
required=False
|
||||
)
|
||||
max_utilization = forms.IntegerField(
|
||||
label=_('Max utilization'),
|
||||
required=False
|
||||
)
|
||||
tag = TagFilterField(model)
|
||||
@@ -1063,12 +1105,14 @@ class PowerFeedFilterForm(TenancyFilterForm, NetBoxModelFilterSetForm):
|
||||
|
||||
class CabledFilterForm(forms.Form):
|
||||
cabled = forms.NullBooleanField(
|
||||
label=_('Cabled'),
|
||||
required=False,
|
||||
widget=forms.Select(
|
||||
choices=BOOLEAN_WITH_BLANK_CHOICES
|
||||
)
|
||||
)
|
||||
occupied = forms.NullBooleanField(
|
||||
label=_('Occupied'),
|
||||
required=False,
|
||||
widget=forms.Select(
|
||||
choices=BOOLEAN_WITH_BLANK_CHOICES
|
||||
@@ -1078,6 +1122,7 @@ class CabledFilterForm(forms.Form):
|
||||
|
||||
class PathEndpointFilterForm(CabledFilterForm):
|
||||
connected = forms.NullBooleanField(
|
||||
label=_('Connected'),
|
||||
required=False,
|
||||
widget=forms.Select(
|
||||
choices=BOOLEAN_WITH_BLANK_CHOICES
|
||||
@@ -1089,16 +1134,18 @@ class ConsolePortFilterForm(PathEndpointFilterForm, DeviceComponentFilterForm):
|
||||
model = ConsolePort
|
||||
fieldsets = (
|
||||
(None, ('q', 'filter_id', 'tag')),
|
||||
('Attributes', ('name', 'label', 'type', 'speed')),
|
||||
('Location', ('region_id', 'site_group_id', 'site_id', 'location_id', 'rack_id')),
|
||||
('Device', ('device_type_id', 'device_role_id', 'device_id', 'virtual_chassis_id')),
|
||||
('Connection', ('cabled', 'connected', 'occupied')),
|
||||
(_('Attributes'), ('name', 'label', 'type', 'speed')),
|
||||
(_('Location'), ('region_id', 'site_group_id', 'site_id', 'location_id', 'rack_id')),
|
||||
(_('Device'), ('device_type_id', 'device_role_id', 'device_id', 'virtual_chassis_id')),
|
||||
(_('Connection'), ('cabled', 'connected', 'occupied')),
|
||||
)
|
||||
type = forms.MultipleChoiceField(
|
||||
label=_('Type'),
|
||||
choices=ConsolePortTypeChoices,
|
||||
required=False
|
||||
)
|
||||
speed = forms.MultipleChoiceField(
|
||||
label=_('Speed'),
|
||||
choices=ConsolePortSpeedChoices,
|
||||
required=False
|
||||
)
|
||||
@@ -1109,16 +1156,18 @@ class ConsoleServerPortFilterForm(PathEndpointFilterForm, DeviceComponentFilterF
|
||||
model = ConsoleServerPort
|
||||
fieldsets = (
|
||||
(None, ('q', 'filter_id', 'tag')),
|
||||
('Attributes', ('name', 'label', 'type', 'speed')),
|
||||
('Location', ('region_id', 'site_group_id', 'site_id', 'location_id', 'rack_id')),
|
||||
('Device', ('device_type_id', 'device_role_id', 'device_id', 'virtual_chassis_id')),
|
||||
('Connection', ('cabled', 'connected', 'occupied')),
|
||||
(_('Attributes'), ('name', 'label', 'type', 'speed')),
|
||||
(_('Location'), ('region_id', 'site_group_id', 'site_id', 'location_id', 'rack_id')),
|
||||
(_('Device'), ('device_type_id', 'device_role_id', 'device_id', 'virtual_chassis_id')),
|
||||
(_('Connection'), ('cabled', 'connected', 'occupied')),
|
||||
)
|
||||
type = forms.MultipleChoiceField(
|
||||
label=_('Type'),
|
||||
choices=ConsolePortTypeChoices,
|
||||
required=False
|
||||
)
|
||||
speed = forms.MultipleChoiceField(
|
||||
label=_('Speed'),
|
||||
choices=ConsolePortSpeedChoices,
|
||||
required=False
|
||||
)
|
||||
@@ -1129,12 +1178,13 @@ class PowerPortFilterForm(PathEndpointFilterForm, DeviceComponentFilterForm):
|
||||
model = PowerPort
|
||||
fieldsets = (
|
||||
(None, ('q', 'filter_id', 'tag')),
|
||||
('Attributes', ('name', 'label', 'type')),
|
||||
('Location', ('region_id', 'site_group_id', 'site_id', 'location_id', 'rack_id')),
|
||||
('Device', ('device_type_id', 'device_role_id', 'device_id', 'virtual_chassis_id')),
|
||||
('Connection', ('cabled', 'connected', 'occupied')),
|
||||
(_('Attributes'), ('name', 'label', 'type')),
|
||||
(_('Location'), ('region_id', 'site_group_id', 'site_id', 'location_id', 'rack_id')),
|
||||
(_('Device'), ('device_type_id', 'device_role_id', 'device_id', 'virtual_chassis_id')),
|
||||
(_('Connection'), ('cabled', 'connected', 'occupied')),
|
||||
)
|
||||
type = forms.MultipleChoiceField(
|
||||
label=_('Type'),
|
||||
choices=PowerPortTypeChoices,
|
||||
required=False
|
||||
)
|
||||
@@ -1145,12 +1195,13 @@ class PowerOutletFilterForm(PathEndpointFilterForm, DeviceComponentFilterForm):
|
||||
model = PowerOutlet
|
||||
fieldsets = (
|
||||
(None, ('q', 'filter_id', 'tag')),
|
||||
('Attributes', ('name', 'label', 'type')),
|
||||
('Location', ('region_id', 'site_group_id', 'site_id', 'location_id', 'rack_id')),
|
||||
('Device', ('device_type_id', 'device_role_id', 'device_id', 'virtual_chassis_id')),
|
||||
('Connection', ('cabled', 'connected', 'occupied')),
|
||||
(_('Attributes'), ('name', 'label', 'type')),
|
||||
(_('Location'), ('region_id', 'site_group_id', 'site_id', 'location_id', 'rack_id')),
|
||||
(_('Device'), ('device_type_id', 'device_role_id', 'device_id', 'virtual_chassis_id')),
|
||||
(_('Connection'), ('cabled', 'connected', 'occupied')),
|
||||
)
|
||||
type = forms.MultipleChoiceField(
|
||||
label=_('Type'),
|
||||
choices=PowerOutletTypeChoices,
|
||||
required=False
|
||||
)
|
||||
@@ -1161,13 +1212,13 @@ class InterfaceFilterForm(PathEndpointFilterForm, DeviceComponentFilterForm):
|
||||
model = Interface
|
||||
fieldsets = (
|
||||
(None, ('q', 'filter_id', 'tag')),
|
||||
('Attributes', ('name', 'label', 'kind', 'type', 'speed', 'duplex', 'enabled', 'mgmt_only')),
|
||||
('Addressing', ('vrf_id', 'l2vpn_id', 'mac_address', 'wwn')),
|
||||
('PoE', ('poe_mode', 'poe_type')),
|
||||
('Wireless', ('rf_role', 'rf_channel', 'rf_channel_width', 'tx_power')),
|
||||
('Location', ('region_id', 'site_group_id', 'site_id', 'location_id', 'rack_id')),
|
||||
('Device', ('device_type_id', 'device_role_id', 'device_id', 'virtual_chassis_id', 'vdc_id')),
|
||||
('Connection', ('cabled', 'connected', 'occupied')),
|
||||
(_('Attributes'), ('name', 'label', 'kind', 'type', 'speed', 'duplex', 'enabled', 'mgmt_only')),
|
||||
(_('Addressing'), ('vrf_id', 'l2vpn_id', 'mac_address', 'wwn')),
|
||||
(_('PoE'), ('poe_mode', 'poe_type')),
|
||||
(_('Wireless'), ('rf_role', 'rf_channel', 'rf_channel_width', 'tx_power')),
|
||||
(_('Location'), ('region_id', 'site_group_id', 'site_id', 'location_id', 'rack_id')),
|
||||
(_('Device'), ('device_type_id', 'device_role_id', 'device_id', 'virtual_chassis_id', 'vdc_id')),
|
||||
(_('Connection'), ('cabled', 'connected', 'occupied')),
|
||||
)
|
||||
vdc_id = DynamicModelMultipleChoiceField(
|
||||
queryset=VirtualDeviceContext.objects.all(),
|
||||
@@ -1178,30 +1229,36 @@ class InterfaceFilterForm(PathEndpointFilterForm, DeviceComponentFilterForm):
|
||||
label=_('Virtual Device Context')
|
||||
)
|
||||
kind = forms.MultipleChoiceField(
|
||||
label=_('Kind'),
|
||||
choices=InterfaceKindChoices,
|
||||
required=False
|
||||
)
|
||||
type = forms.MultipleChoiceField(
|
||||
label=_('Type'),
|
||||
choices=InterfaceTypeChoices,
|
||||
required=False
|
||||
)
|
||||
speed = forms.IntegerField(
|
||||
label=_('Speed'),
|
||||
required=False,
|
||||
widget=NumberWithOptions(
|
||||
options=InterfaceSpeedChoices
|
||||
)
|
||||
)
|
||||
duplex = forms.MultipleChoiceField(
|
||||
label=_('Duplex'),
|
||||
choices=InterfaceDuplexChoices,
|
||||
required=False
|
||||
)
|
||||
enabled = forms.NullBooleanField(
|
||||
label=_('Enabled'),
|
||||
required=False,
|
||||
widget=forms.Select(
|
||||
choices=BOOLEAN_WITH_BLANK_CHOICES
|
||||
)
|
||||
)
|
||||
mgmt_only = forms.NullBooleanField(
|
||||
label=_('Mgmt only'),
|
||||
required=False,
|
||||
widget=forms.Select(
|
||||
choices=BOOLEAN_WITH_BLANK_CHOICES
|
||||
@@ -1209,50 +1266,50 @@ class InterfaceFilterForm(PathEndpointFilterForm, DeviceComponentFilterForm):
|
||||
)
|
||||
mac_address = forms.CharField(
|
||||
required=False,
|
||||
label='MAC address'
|
||||
label=_('MAC address')
|
||||
)
|
||||
wwn = forms.CharField(
|
||||
required=False,
|
||||
label='WWN'
|
||||
label=_('WWN')
|
||||
)
|
||||
poe_mode = forms.MultipleChoiceField(
|
||||
choices=InterfacePoEModeChoices,
|
||||
required=False,
|
||||
label='PoE mode'
|
||||
label=_('PoE mode')
|
||||
)
|
||||
poe_type = forms.MultipleChoiceField(
|
||||
choices=InterfacePoETypeChoices,
|
||||
required=False,
|
||||
label='PoE type'
|
||||
label=_('PoE type')
|
||||
)
|
||||
rf_role = forms.MultipleChoiceField(
|
||||
choices=WirelessRoleChoices,
|
||||
required=False,
|
||||
label='Wireless role'
|
||||
label=_('Wireless role')
|
||||
)
|
||||
rf_channel = forms.MultipleChoiceField(
|
||||
choices=WirelessChannelChoices,
|
||||
required=False,
|
||||
label='Wireless channel'
|
||||
label=_('Wireless channel')
|
||||
)
|
||||
rf_channel_frequency = forms.IntegerField(
|
||||
required=False,
|
||||
label='Channel frequency (MHz)'
|
||||
label=_('Channel frequency (MHz)')
|
||||
)
|
||||
rf_channel_width = forms.IntegerField(
|
||||
required=False,
|
||||
label='Channel width (MHz)'
|
||||
label=_('Channel width (MHz)')
|
||||
)
|
||||
tx_power = forms.IntegerField(
|
||||
required=False,
|
||||
label='Transmit power (dBm)',
|
||||
label=_('Transmit power (dBm)'),
|
||||
min_value=0,
|
||||
max_value=127
|
||||
)
|
||||
vrf_id = DynamicModelMultipleChoiceField(
|
||||
queryset=VRF.objects.all(),
|
||||
required=False,
|
||||
label='VRF'
|
||||
label=_('VRF')
|
||||
)
|
||||
l2vpn_id = DynamicModelMultipleChoiceField(
|
||||
queryset=L2VPN.objects.all(),
|
||||
@@ -1265,17 +1322,19 @@ class InterfaceFilterForm(PathEndpointFilterForm, DeviceComponentFilterForm):
|
||||
class FrontPortFilterForm(CabledFilterForm, DeviceComponentFilterForm):
|
||||
fieldsets = (
|
||||
(None, ('q', 'filter_id', 'tag')),
|
||||
('Attributes', ('name', 'label', 'type', 'color')),
|
||||
('Location', ('region_id', 'site_group_id', 'site_id', 'location_id', 'rack_id')),
|
||||
('Device', ('device_type_id', 'device_role_id', 'device_id', 'virtual_chassis_id')),
|
||||
('Cable', ('cabled', 'occupied')),
|
||||
(_('Attributes'), ('name', 'label', 'type', 'color')),
|
||||
(_('Location'), ('region_id', 'site_group_id', 'site_id', 'location_id', 'rack_id')),
|
||||
(_('Device'), ('device_type_id', 'device_role_id', 'device_id', 'virtual_chassis_id')),
|
||||
(_('Cable'), ('cabled', 'occupied')),
|
||||
)
|
||||
model = FrontPort
|
||||
type = forms.MultipleChoiceField(
|
||||
label=_('Type'),
|
||||
choices=PortTypeChoices,
|
||||
required=False
|
||||
)
|
||||
color = ColorField(
|
||||
label=_('Color'),
|
||||
required=False
|
||||
)
|
||||
tag = TagFilterField(model)
|
||||
@@ -1285,16 +1344,18 @@ class RearPortFilterForm(CabledFilterForm, DeviceComponentFilterForm):
|
||||
model = RearPort
|
||||
fieldsets = (
|
||||
(None, ('q', 'filter_id', 'tag')),
|
||||
('Attributes', ('name', 'label', 'type', 'color')),
|
||||
('Location', ('region_id', 'site_group_id', 'site_id', 'location_id', 'rack_id')),
|
||||
('Device', ('device_type_id', 'device_role_id', 'device_id', 'virtual_chassis_id')),
|
||||
('Cable', ('cabled', 'occupied')),
|
||||
(_('Attributes'), ('name', 'label', 'type', 'color')),
|
||||
(_('Location'), ('region_id', 'site_group_id', 'site_id', 'location_id', 'rack_id')),
|
||||
(_('Device'), ('device_type_id', 'device_role_id', 'device_id', 'virtual_chassis_id')),
|
||||
(_('Cable'), ('cabled', 'occupied')),
|
||||
)
|
||||
type = forms.MultipleChoiceField(
|
||||
label=_('Type'),
|
||||
choices=PortTypeChoices,
|
||||
required=False
|
||||
)
|
||||
color = ColorField(
|
||||
label=_('Color'),
|
||||
required=False
|
||||
)
|
||||
tag = TagFilterField(model)
|
||||
@@ -1304,12 +1365,13 @@ class ModuleBayFilterForm(DeviceComponentFilterForm):
|
||||
model = ModuleBay
|
||||
fieldsets = (
|
||||
(None, ('q', 'filter_id', 'tag')),
|
||||
('Attributes', ('name', 'label', 'position')),
|
||||
('Location', ('region_id', 'site_group_id', 'site_id', 'location_id', 'rack_id')),
|
||||
('Device', ('device_type_id', 'device_role_id', 'device_id', 'virtual_chassis_id')),
|
||||
(_('Attributes'), ('name', 'label', 'position')),
|
||||
(_('Location'), ('region_id', 'site_group_id', 'site_id', 'location_id', 'rack_id')),
|
||||
(_('Device'), ('device_type_id', 'device_role_id', 'device_id', 'virtual_chassis_id')),
|
||||
)
|
||||
tag = TagFilterField(model)
|
||||
position = forms.CharField(
|
||||
label=_('Position'),
|
||||
required=False
|
||||
)
|
||||
|
||||
@@ -1318,9 +1380,9 @@ class DeviceBayFilterForm(DeviceComponentFilterForm):
|
||||
model = DeviceBay
|
||||
fieldsets = (
|
||||
(None, ('q', 'filter_id', 'tag')),
|
||||
('Attributes', ('name', 'label')),
|
||||
('Location', ('region_id', 'site_group_id', 'site_id', 'location_id', 'rack_id')),
|
||||
('Device', ('device_type_id', 'device_role_id', 'device_id', 'virtual_chassis_id')),
|
||||
(_('Attributes'), ('name', 'label')),
|
||||
(_('Location'), ('region_id', 'site_group_id', 'site_id', 'location_id', 'rack_id')),
|
||||
(_('Device'), ('device_type_id', 'device_role_id', 'device_id', 'virtual_chassis_id')),
|
||||
)
|
||||
tag = TagFilterField(model)
|
||||
|
||||
@@ -1329,9 +1391,9 @@ class InventoryItemFilterForm(DeviceComponentFilterForm):
|
||||
model = InventoryItem
|
||||
fieldsets = (
|
||||
(None, ('q', 'filter_id', 'tag')),
|
||||
('Attributes', ('name', 'label', 'role_id', 'manufacturer_id', 'serial', 'asset_tag', 'discovered')),
|
||||
('Location', ('region_id', 'site_group_id', 'site_id', 'location_id', 'rack_id')),
|
||||
('Device', ('device_type_id', 'device_role_id', 'device_id', 'virtual_chassis_id')),
|
||||
(_('Attributes'), ('name', 'label', 'role_id', 'manufacturer_id', 'serial', 'asset_tag', 'discovered')),
|
||||
(_('Location'), ('region_id', 'site_group_id', 'site_id', 'location_id', 'rack_id')),
|
||||
(_('Device'), ('device_type_id', 'device_role_id', 'device_id', 'virtual_chassis_id')),
|
||||
)
|
||||
role_id = DynamicModelMultipleChoiceField(
|
||||
queryset=InventoryItemRole.objects.all(),
|
||||
@@ -1345,12 +1407,15 @@ class InventoryItemFilterForm(DeviceComponentFilterForm):
|
||||
label=_('Manufacturer')
|
||||
)
|
||||
serial = forms.CharField(
|
||||
label=_('Serial'),
|
||||
required=False
|
||||
)
|
||||
asset_tag = forms.CharField(
|
||||
label=_('Asset tag'),
|
||||
required=False
|
||||
)
|
||||
discovered = forms.NullBooleanField(
|
||||
label=_('Discovered'),
|
||||
required=False,
|
||||
widget=forms.Select(
|
||||
choices=BOOLEAN_WITH_BLANK_CHOICES
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
from django import forms
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
__all__ = (
|
||||
'BaseVCMemberFormSet',
|
||||
@@ -16,6 +17,8 @@ class BaseVCMemberFormSet(forms.BaseModelFormSet):
|
||||
vc_position = form.cleaned_data.get('vc_position')
|
||||
if vc_position:
|
||||
if vc_position in vc_position_list:
|
||||
error_msg = f"A virtual chassis member already exists in position {vc_position}."
|
||||
error_msg = _("A virtual chassis member already exists in position {vc_position}.").format(
|
||||
vc_position=vc_position
|
||||
)
|
||||
form.add_error('vc_position', error_msg)
|
||||
vc_position_list.append(vc_position)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from django import forms
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.utils.translation import gettext as _
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from timezone_field import TimeZoneFormField
|
||||
|
||||
from dcim.choices import *
|
||||
@@ -70,13 +70,14 @@ __all__ = (
|
||||
|
||||
class RegionForm(NetBoxModelForm):
|
||||
parent = DynamicModelChoiceField(
|
||||
label=_('Parent'),
|
||||
queryset=Region.objects.all(),
|
||||
required=False
|
||||
)
|
||||
slug = SlugField()
|
||||
|
||||
fieldsets = (
|
||||
('Region', (
|
||||
(_('Region'), (
|
||||
'parent', 'name', 'slug', 'description', 'tags',
|
||||
)),
|
||||
)
|
||||
@@ -90,13 +91,14 @@ class RegionForm(NetBoxModelForm):
|
||||
|
||||
class SiteGroupForm(NetBoxModelForm):
|
||||
parent = DynamicModelChoiceField(
|
||||
label=_('Parent'),
|
||||
queryset=SiteGroup.objects.all(),
|
||||
required=False
|
||||
)
|
||||
slug = SlugField()
|
||||
|
||||
fieldsets = (
|
||||
('Site Group', (
|
||||
(_('Site Group'), (
|
||||
'parent', 'name', 'slug', 'description', 'tags',
|
||||
)),
|
||||
)
|
||||
@@ -110,10 +112,12 @@ class SiteGroupForm(NetBoxModelForm):
|
||||
|
||||
class SiteForm(TenancyForm, NetBoxModelForm):
|
||||
region = DynamicModelChoiceField(
|
||||
label=_('Region'),
|
||||
queryset=Region.objects.all(),
|
||||
required=False
|
||||
)
|
||||
group = DynamicModelChoiceField(
|
||||
label=_('Group'),
|
||||
queryset=SiteGroup.objects.all(),
|
||||
required=False
|
||||
)
|
||||
@@ -124,17 +128,18 @@ class SiteForm(TenancyForm, NetBoxModelForm):
|
||||
)
|
||||
slug = SlugField()
|
||||
time_zone = TimeZoneFormField(
|
||||
label=_('Time zone'),
|
||||
choices=add_blank_choice(TimeZoneFormField().choices),
|
||||
required=False
|
||||
)
|
||||
comments = CommentField()
|
||||
|
||||
fieldsets = (
|
||||
('Site', (
|
||||
(_('Site'), (
|
||||
'name', 'slug', 'status', 'region', 'group', 'facility', 'asns', 'time_zone', 'description', 'tags',
|
||||
)),
|
||||
('Tenancy', ('tenant_group', 'tenant')),
|
||||
('Contact Info', ('physical_address', 'shipping_address', 'latitude', 'longitude')),
|
||||
(_('Tenancy'), ('tenant_group', 'tenant')),
|
||||
(_('Contact Info'), ('physical_address', 'shipping_address', 'latitude', 'longitude')),
|
||||
)
|
||||
|
||||
class Meta:
|
||||
@@ -159,10 +164,12 @@ class SiteForm(TenancyForm, NetBoxModelForm):
|
||||
|
||||
class LocationForm(TenancyForm, NetBoxModelForm):
|
||||
site = DynamicModelChoiceField(
|
||||
label=_('Site'),
|
||||
queryset=Site.objects.all(),
|
||||
selector=True
|
||||
)
|
||||
parent = DynamicModelChoiceField(
|
||||
label=_('Parent'),
|
||||
queryset=Location.objects.all(),
|
||||
required=False,
|
||||
query_params={
|
||||
@@ -172,8 +179,8 @@ class LocationForm(TenancyForm, NetBoxModelForm):
|
||||
slug = SlugField()
|
||||
|
||||
fieldsets = (
|
||||
('Location', ('site', 'parent', 'name', 'slug', 'status', 'description', 'tags')),
|
||||
('Tenancy', ('tenant_group', 'tenant')),
|
||||
(_('Location'), ('site', 'parent', 'name', 'slug', 'status', 'description', 'tags')),
|
||||
(_('Tenancy'), ('tenant_group', 'tenant')),
|
||||
)
|
||||
|
||||
class Meta:
|
||||
@@ -187,7 +194,7 @@ class RackRoleForm(NetBoxModelForm):
|
||||
slug = SlugField()
|
||||
|
||||
fieldsets = (
|
||||
('Rack Role', (
|
||||
(_('Rack Role'), (
|
||||
'name', 'slug', 'color', 'description', 'tags',
|
||||
)),
|
||||
)
|
||||
@@ -201,10 +208,12 @@ class RackRoleForm(NetBoxModelForm):
|
||||
|
||||
class RackForm(TenancyForm, NetBoxModelForm):
|
||||
site = DynamicModelChoiceField(
|
||||
label=_('Site'),
|
||||
queryset=Site.objects.all(),
|
||||
selector=True
|
||||
)
|
||||
location = DynamicModelChoiceField(
|
||||
label=_('Location'),
|
||||
queryset=Location.objects.all(),
|
||||
required=False,
|
||||
query_params={
|
||||
@@ -212,6 +221,7 @@ class RackForm(TenancyForm, NetBoxModelForm):
|
||||
}
|
||||
)
|
||||
role = DynamicModelChoiceField(
|
||||
label=_('Role'),
|
||||
queryset=RackRole.objects.all(),
|
||||
required=False
|
||||
)
|
||||
@@ -228,14 +238,17 @@ class RackForm(TenancyForm, NetBoxModelForm):
|
||||
|
||||
class RackReservationForm(TenancyForm, NetBoxModelForm):
|
||||
rack = DynamicModelChoiceField(
|
||||
label=_('Rack'),
|
||||
queryset=Rack.objects.all(),
|
||||
selector=True
|
||||
)
|
||||
units = NumericArrayField(
|
||||
label=_('Units'),
|
||||
base_field=forms.IntegerField(),
|
||||
help_text=_("Comma-separated list of numeric unit IDs. A range may be specified using a hyphen.")
|
||||
)
|
||||
user = forms.ModelChoiceField(
|
||||
label=_('User'),
|
||||
queryset=get_user_model().objects.order_by(
|
||||
'username'
|
||||
)
|
||||
@@ -243,8 +256,8 @@ class RackReservationForm(TenancyForm, NetBoxModelForm):
|
||||
comments = CommentField()
|
||||
|
||||
fieldsets = (
|
||||
('Reservation', ('rack', 'units', 'user', 'description', 'tags')),
|
||||
('Tenancy', ('tenant_group', 'tenant')),
|
||||
(_('Reservation'), ('rack', 'units', 'user', 'description', 'tags')),
|
||||
(_('Tenancy'), ('tenant_group', 'tenant')),
|
||||
)
|
||||
|
||||
class Meta:
|
||||
@@ -258,7 +271,7 @@ class ManufacturerForm(NetBoxModelForm):
|
||||
slug = SlugField()
|
||||
|
||||
fieldsets = (
|
||||
('Manufacturer', (
|
||||
(_('Manufacturer'), (
|
||||
'name', 'slug', 'description', 'tags',
|
||||
)),
|
||||
)
|
||||
@@ -272,23 +285,26 @@ class ManufacturerForm(NetBoxModelForm):
|
||||
|
||||
class DeviceTypeForm(NetBoxModelForm):
|
||||
manufacturer = DynamicModelChoiceField(
|
||||
label=_('Manufacturer'),
|
||||
queryset=Manufacturer.objects.all()
|
||||
)
|
||||
default_platform = DynamicModelChoiceField(
|
||||
label=_('Default platform'),
|
||||
queryset=Platform.objects.all(),
|
||||
required=False
|
||||
)
|
||||
slug = SlugField(
|
||||
label=_('Slug'),
|
||||
slug_source='model'
|
||||
)
|
||||
comments = CommentField()
|
||||
|
||||
fieldsets = (
|
||||
('Device Type', ('manufacturer', 'model', 'slug', 'default_platform', 'description', 'tags')),
|
||||
('Chassis', (
|
||||
(_('Device Type'), ('manufacturer', 'model', 'slug', 'default_platform', 'description', 'tags')),
|
||||
(_('Chassis'), (
|
||||
'u_height', 'is_full_depth', 'part_number', 'subdevice_role', 'airflow', 'weight', 'weight_unit',
|
||||
)),
|
||||
('Images', ('front_image', 'rear_image')),
|
||||
(_('Images'), ('front_image', 'rear_image')),
|
||||
)
|
||||
|
||||
class Meta:
|
||||
@@ -310,13 +326,14 @@ class DeviceTypeForm(NetBoxModelForm):
|
||||
|
||||
class ModuleTypeForm(NetBoxModelForm):
|
||||
manufacturer = DynamicModelChoiceField(
|
||||
label=_('Manufacturer'),
|
||||
queryset=Manufacturer.objects.all()
|
||||
)
|
||||
comments = CommentField()
|
||||
|
||||
fieldsets = (
|
||||
('Module Type', ('manufacturer', 'model', 'part_number', 'description', 'tags')),
|
||||
('Weight', ('weight', 'weight_unit'))
|
||||
(_('Module Type'), ('manufacturer', 'model', 'part_number', 'description', 'tags')),
|
||||
(_('Weight'), ('weight', 'weight_unit'))
|
||||
)
|
||||
|
||||
class Meta:
|
||||
@@ -328,13 +345,14 @@ class ModuleTypeForm(NetBoxModelForm):
|
||||
|
||||
class DeviceRoleForm(NetBoxModelForm):
|
||||
config_template = DynamicModelChoiceField(
|
||||
label=_('Config template'),
|
||||
queryset=ConfigTemplate.objects.all(),
|
||||
required=False
|
||||
)
|
||||
slug = SlugField()
|
||||
|
||||
fieldsets = (
|
||||
('Device Role', (
|
||||
(_('Device Role'), (
|
||||
'name', 'slug', 'color', 'vm_role', 'config_template', 'description', 'tags',
|
||||
)),
|
||||
)
|
||||
@@ -348,19 +366,22 @@ class DeviceRoleForm(NetBoxModelForm):
|
||||
|
||||
class PlatformForm(NetBoxModelForm):
|
||||
manufacturer = DynamicModelChoiceField(
|
||||
label=_('Manufacturer'),
|
||||
queryset=Manufacturer.objects.all(),
|
||||
required=False
|
||||
)
|
||||
config_template = DynamicModelChoiceField(
|
||||
label=_('Config template'),
|
||||
queryset=ConfigTemplate.objects.all(),
|
||||
required=False
|
||||
)
|
||||
slug = SlugField(
|
||||
label=_('Slug'),
|
||||
max_length=64
|
||||
)
|
||||
|
||||
fieldsets = (
|
||||
('Platform', ('name', 'slug', 'manufacturer', 'config_template', 'description', 'tags')),
|
||||
(_('Platform'), ('name', 'slug', 'manufacturer', 'config_template', 'description', 'tags')),
|
||||
)
|
||||
|
||||
class Meta:
|
||||
@@ -372,10 +393,12 @@ class PlatformForm(NetBoxModelForm):
|
||||
|
||||
class DeviceForm(TenancyForm, NetBoxModelForm):
|
||||
site = DynamicModelChoiceField(
|
||||
label=_('Site'),
|
||||
queryset=Site.objects.all(),
|
||||
selector=True
|
||||
)
|
||||
location = DynamicModelChoiceField(
|
||||
label=_('Location'),
|
||||
queryset=Location.objects.all(),
|
||||
required=False,
|
||||
query_params={
|
||||
@@ -386,6 +409,7 @@ class DeviceForm(TenancyForm, NetBoxModelForm):
|
||||
}
|
||||
)
|
||||
rack = DynamicModelChoiceField(
|
||||
label=_('Rack'),
|
||||
queryset=Rack.objects.all(),
|
||||
required=False,
|
||||
query_params={
|
||||
@@ -394,6 +418,7 @@ class DeviceForm(TenancyForm, NetBoxModelForm):
|
||||
}
|
||||
)
|
||||
position = forms.DecimalField(
|
||||
label=_('Position'),
|
||||
required=False,
|
||||
help_text=_("The lowest-numbered unit occupied by the device"),
|
||||
widget=APISelect(
|
||||
@@ -405,17 +430,21 @@ class DeviceForm(TenancyForm, NetBoxModelForm):
|
||||
)
|
||||
)
|
||||
device_type = DynamicModelChoiceField(
|
||||
label=_('Device type'),
|
||||
queryset=DeviceType.objects.all(),
|
||||
selector=True
|
||||
)
|
||||
device_role = DynamicModelChoiceField(
|
||||
label=_('Device role'),
|
||||
queryset=DeviceRole.objects.all()
|
||||
)
|
||||
platform = DynamicModelChoiceField(
|
||||
label=_('Platform'),
|
||||
queryset=Platform.objects.all(),
|
||||
required=False
|
||||
)
|
||||
cluster = DynamicModelChoiceField(
|
||||
label=_('Cluster'),
|
||||
queryset=Cluster.objects.all(),
|
||||
required=False,
|
||||
selector=True
|
||||
@@ -426,6 +455,7 @@ class DeviceForm(TenancyForm, NetBoxModelForm):
|
||||
label=''
|
||||
)
|
||||
virtual_chassis = DynamicModelChoiceField(
|
||||
label=_('Virtual chassis'),
|
||||
queryset=VirtualChassis.objects.all(),
|
||||
required=False,
|
||||
selector=True
|
||||
@@ -441,6 +471,7 @@ class DeviceForm(TenancyForm, NetBoxModelForm):
|
||||
help_text=_("The priority of the device in the virtual chassis")
|
||||
)
|
||||
config_template = DynamicModelChoiceField(
|
||||
label=_('Config template'),
|
||||
queryset=ConfigTemplate.objects.all(),
|
||||
required=False
|
||||
)
|
||||
@@ -518,36 +549,41 @@ class DeviceForm(TenancyForm, NetBoxModelForm):
|
||||
|
||||
class ModuleForm(ModuleCommonForm, NetBoxModelForm):
|
||||
device = DynamicModelChoiceField(
|
||||
label=_('Device'),
|
||||
queryset=Device.objects.all(),
|
||||
initial_params={
|
||||
'modulebays': '$module_bay'
|
||||
}
|
||||
)
|
||||
module_bay = DynamicModelChoiceField(
|
||||
label=_('Module bay'),
|
||||
queryset=ModuleBay.objects.all(),
|
||||
query_params={
|
||||
'device_id': '$device'
|
||||
}
|
||||
)
|
||||
module_type = DynamicModelChoiceField(
|
||||
label=_('Module type'),
|
||||
queryset=ModuleType.objects.all(),
|
||||
selector=True
|
||||
)
|
||||
comments = CommentField()
|
||||
replicate_components = forms.BooleanField(
|
||||
label=_('Replicate components'),
|
||||
required=False,
|
||||
initial=True,
|
||||
help_text=_("Automatically populate components associated with this module type")
|
||||
)
|
||||
adopt_components = forms.BooleanField(
|
||||
label=_('Adopt components'),
|
||||
required=False,
|
||||
initial=False,
|
||||
help_text=_("Adopt already existing components")
|
||||
)
|
||||
|
||||
fieldsets = (
|
||||
('Module', ('device', 'module_bay', 'module_type', 'status', 'description', 'tags')),
|
||||
('Hardware', (
|
||||
(_('Module'), ('device', 'module_bay', 'module_type', 'status', 'description', 'tags')),
|
||||
(_('Hardware'), (
|
||||
'serial', 'asset_tag', 'replicate_components', 'adopt_components',
|
||||
)),
|
||||
)
|
||||
@@ -581,17 +617,19 @@ class CableForm(TenancyForm, NetBoxModelForm):
|
||||
]
|
||||
error_messages = {
|
||||
'length': {
|
||||
'max_value': 'Maximum length is 32767 (any unit)'
|
||||
'max_value': _('Maximum length is 32767 (any unit)')
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class PowerPanelForm(NetBoxModelForm):
|
||||
site = DynamicModelChoiceField(
|
||||
label=_('Site'),
|
||||
queryset=Site.objects.all(),
|
||||
selector=True
|
||||
)
|
||||
location = DynamicModelChoiceField(
|
||||
label=_('Location'),
|
||||
queryset=Location.objects.all(),
|
||||
required=False,
|
||||
query_params={
|
||||
@@ -613,10 +651,12 @@ class PowerPanelForm(NetBoxModelForm):
|
||||
|
||||
class PowerFeedForm(TenancyForm, NetBoxModelForm):
|
||||
power_panel = DynamicModelChoiceField(
|
||||
label=_('Power panel'),
|
||||
queryset=PowerPanel.objects.all(),
|
||||
selector=True
|
||||
)
|
||||
rack = DynamicModelChoiceField(
|
||||
label=_('Rack'),
|
||||
queryset=Rack.objects.all(),
|
||||
required=False,
|
||||
selector=True
|
||||
@@ -624,9 +664,9 @@ class PowerFeedForm(TenancyForm, NetBoxModelForm):
|
||||
comments = CommentField()
|
||||
|
||||
fieldsets = (
|
||||
('Power Feed', ('power_panel', 'rack', 'name', 'status', 'type', 'description', 'mark_connected', 'tags')),
|
||||
('Characteristics', ('supply', 'voltage', 'amperage', 'phase', 'max_utilization')),
|
||||
('Tenancy', ('tenant_group', 'tenant')),
|
||||
(_('Power Feed'), ('power_panel', 'rack', 'name', 'status', 'type', 'description', 'mark_connected', 'tags')),
|
||||
(_('Characteristics'), ('supply', 'voltage', 'amperage', 'phase', 'max_utilization')),
|
||||
(_('Tenancy'), ('tenant_group', 'tenant')),
|
||||
)
|
||||
|
||||
class Meta:
|
||||
@@ -643,6 +683,7 @@ class PowerFeedForm(TenancyForm, NetBoxModelForm):
|
||||
|
||||
class VirtualChassisForm(NetBoxModelForm):
|
||||
master = forms.ModelChoiceField(
|
||||
label=_('Master'),
|
||||
queryset=Device.objects.all(),
|
||||
required=False,
|
||||
)
|
||||
@@ -706,6 +747,7 @@ class DeviceVCMembershipForm(forms.ModelForm):
|
||||
|
||||
class VCMemberSelectForm(BootstrapMixin, forms.Form):
|
||||
device = DynamicModelChoiceField(
|
||||
label=_('Device'),
|
||||
queryset=Device.objects.all(),
|
||||
query_params={
|
||||
'virtual_chassis_id': 'null',
|
||||
@@ -728,6 +770,7 @@ class VCMemberSelectForm(BootstrapMixin, forms.Form):
|
||||
|
||||
class ComponentTemplateForm(BootstrapMixin, forms.ModelForm):
|
||||
device_type = DynamicModelChoiceField(
|
||||
label=_('Device type'),
|
||||
queryset=DeviceType.objects.all()
|
||||
)
|
||||
|
||||
@@ -741,10 +784,12 @@ class ComponentTemplateForm(BootstrapMixin, forms.ModelForm):
|
||||
|
||||
class ModularComponentTemplateForm(ComponentTemplateForm):
|
||||
device_type = DynamicModelChoiceField(
|
||||
label=_('Device type'),
|
||||
queryset=DeviceType.objects.all().all(),
|
||||
required=False
|
||||
)
|
||||
module_type = DynamicModelChoiceField(
|
||||
label=_('Module type'),
|
||||
queryset=ModuleType.objects.all(),
|
||||
required=False
|
||||
)
|
||||
@@ -797,6 +842,7 @@ class PowerPortTemplateForm(ModularComponentTemplateForm):
|
||||
|
||||
class PowerOutletTemplateForm(ModularComponentTemplateForm):
|
||||
power_port = DynamicModelChoiceField(
|
||||
label=_('Power port'),
|
||||
queryset=PowerPortTemplate.objects.all(),
|
||||
required=False,
|
||||
query_params={
|
||||
@@ -817,6 +863,7 @@ class PowerOutletTemplateForm(ModularComponentTemplateForm):
|
||||
|
||||
class InterfaceTemplateForm(ModularComponentTemplateForm):
|
||||
bridge = DynamicModelChoiceField(
|
||||
label=_('Bridge'),
|
||||
queryset=InterfaceTemplate.objects.all(),
|
||||
required=False,
|
||||
query_params={
|
||||
@@ -827,8 +874,8 @@ class InterfaceTemplateForm(ModularComponentTemplateForm):
|
||||
|
||||
fieldsets = (
|
||||
(None, ('device_type', 'module_type', 'name', 'label', 'type', 'enabled', 'mgmt_only', 'description', 'bridge')),
|
||||
('PoE', ('poe_mode', 'poe_type')),
|
||||
('Wireless', ('rf_role',))
|
||||
(_('PoE'), ('poe_mode', 'poe_type')),
|
||||
(_('Wireless'), ('rf_role',)),
|
||||
)
|
||||
|
||||
class Meta:
|
||||
@@ -840,6 +887,7 @@ class InterfaceTemplateForm(ModularComponentTemplateForm):
|
||||
|
||||
class FrontPortTemplateForm(ModularComponentTemplateForm):
|
||||
rear_port = DynamicModelChoiceField(
|
||||
label=_('Rear port'),
|
||||
queryset=RearPortTemplate.objects.all(),
|
||||
required=False,
|
||||
query_params={
|
||||
@@ -901,6 +949,7 @@ class DeviceBayTemplateForm(ComponentTemplateForm):
|
||||
|
||||
class InventoryItemTemplateForm(ComponentTemplateForm):
|
||||
parent = DynamicModelChoiceField(
|
||||
label=_('Parent'),
|
||||
queryset=InventoryItemTemplate.objects.all(),
|
||||
required=False,
|
||||
query_params={
|
||||
@@ -908,10 +957,12 @@ class InventoryItemTemplateForm(ComponentTemplateForm):
|
||||
}
|
||||
)
|
||||
role = DynamicModelChoiceField(
|
||||
label=_('Role'),
|
||||
queryset=InventoryItemRole.objects.all(),
|
||||
required=False
|
||||
)
|
||||
manufacturer = DynamicModelChoiceField(
|
||||
label=_('Manufacturer'),
|
||||
queryset=Manufacturer.objects.all(),
|
||||
required=False
|
||||
)
|
||||
@@ -947,6 +998,7 @@ class InventoryItemTemplateForm(ComponentTemplateForm):
|
||||
|
||||
class DeviceComponentForm(NetBoxModelForm):
|
||||
device = DynamicModelChoiceField(
|
||||
label=_('Device'),
|
||||
queryset=Device.objects.all(),
|
||||
selector=True
|
||||
)
|
||||
@@ -961,6 +1013,7 @@ class DeviceComponentForm(NetBoxModelForm):
|
||||
|
||||
class ModularDeviceComponentForm(DeviceComponentForm):
|
||||
module = DynamicModelChoiceField(
|
||||
label=_('Module'),
|
||||
queryset=Module.objects.all(),
|
||||
required=False,
|
||||
query_params={
|
||||
@@ -1017,6 +1070,7 @@ class PowerPortForm(ModularDeviceComponentForm):
|
||||
|
||||
class PowerOutletForm(ModularDeviceComponentForm):
|
||||
power_port = DynamicModelChoiceField(
|
||||
label=_('Power port'),
|
||||
queryset=PowerPort.objects.all(),
|
||||
required=False,
|
||||
query_params={
|
||||
@@ -1043,7 +1097,7 @@ class InterfaceForm(InterfaceCommonForm, ModularDeviceComponentForm):
|
||||
vdcs = DynamicModelMultipleChoiceField(
|
||||
queryset=VirtualDeviceContext.objects.all(),
|
||||
required=False,
|
||||
label='Virtual Device Contexts',
|
||||
label=_('Virtual device contexts'),
|
||||
query_params={
|
||||
'device_id': '$device',
|
||||
}
|
||||
@@ -1121,13 +1175,13 @@ class InterfaceForm(InterfaceCommonForm, ModularDeviceComponentForm):
|
||||
)
|
||||
|
||||
fieldsets = (
|
||||
('Interface', ('device', 'module', 'name', 'label', 'type', 'speed', 'duplex', 'description', 'tags')),
|
||||
('Addressing', ('vrf', 'mac_address', 'wwn')),
|
||||
('Operation', ('vdcs', 'mtu', 'tx_power', 'enabled', 'mgmt_only', 'mark_connected')),
|
||||
('Related Interfaces', ('parent', 'bridge', 'lag')),
|
||||
('PoE', ('poe_mode', 'poe_type')),
|
||||
('802.1Q Switching', ('mode', 'vlan_group', 'untagged_vlan', 'tagged_vlans')),
|
||||
('Wireless', (
|
||||
(_('Interface'), ('device', 'module', 'name', 'label', 'type', 'speed', 'duplex', 'description', 'tags')),
|
||||
(_('Addressing'), ('vrf', 'mac_address', 'wwn')),
|
||||
(_('Operation'), ('vdcs', 'mtu', 'tx_power', 'enabled', 'mgmt_only', 'mark_connected')),
|
||||
(_('Related Interfaces'), ('parent', 'bridge', 'lag')),
|
||||
(_('PoE'), ('poe_mode', 'poe_type')),
|
||||
(_('802.1Q Switching'), ('mode', 'vlan_group', 'untagged_vlan', 'tagged_vlans')),
|
||||
(_('Wireless'), (
|
||||
'rf_role', 'rf_channel', 'rf_channel_frequency', 'rf_channel_width', 'wireless_lan_group', 'wireless_lans',
|
||||
)),
|
||||
)
|
||||
@@ -1233,6 +1287,7 @@ class PopulateDeviceBayForm(BootstrapMixin, forms.Form):
|
||||
|
||||
class InventoryItemForm(DeviceComponentForm):
|
||||
parent = DynamicModelChoiceField(
|
||||
label=_('Parent'),
|
||||
queryset=InventoryItem.objects.all(),
|
||||
required=False,
|
||||
query_params={
|
||||
@@ -1240,10 +1295,12 @@ class InventoryItemForm(DeviceComponentForm):
|
||||
}
|
||||
)
|
||||
role = DynamicModelChoiceField(
|
||||
label=_('Role'),
|
||||
queryset=InventoryItemRole.objects.all(),
|
||||
required=False
|
||||
)
|
||||
manufacturer = DynamicModelChoiceField(
|
||||
label=_('Manufacturer'),
|
||||
queryset=Manufacturer.objects.all(),
|
||||
required=False
|
||||
)
|
||||
@@ -1307,8 +1364,8 @@ class InventoryItemForm(DeviceComponentForm):
|
||||
)
|
||||
|
||||
fieldsets = (
|
||||
('Inventory Item', ('device', 'parent', 'name', 'label', 'role', 'description', 'tags')),
|
||||
('Hardware', ('manufacturer', 'part_id', 'serial', 'asset_tag')),
|
||||
(_('Inventory Item'), ('device', 'parent', 'name', 'label', 'role', 'description', 'tags')),
|
||||
(_('Hardware'), ('manufacturer', 'part_id', 'serial', 'asset_tag')),
|
||||
)
|
||||
|
||||
class Meta:
|
||||
@@ -1359,7 +1416,7 @@ class InventoryItemForm(DeviceComponentForm):
|
||||
) if self.cleaned_data[field]
|
||||
]
|
||||
if len(selected_objects) > 1:
|
||||
raise forms.ValidationError("An InventoryItem can only be assigned to a single component.")
|
||||
raise forms.ValidationError(_("An InventoryItem can only be assigned to a single component."))
|
||||
elif selected_objects:
|
||||
self.instance.component = self.cleaned_data[selected_objects[0]]
|
||||
else:
|
||||
@@ -1373,7 +1430,7 @@ class InventoryItemRoleForm(NetBoxModelForm):
|
||||
slug = SlugField()
|
||||
|
||||
fieldsets = (
|
||||
('Inventory Item Role', (
|
||||
(_('Inventory Item Role'), (
|
||||
'name', 'slug', 'color', 'description', 'tags',
|
||||
)),
|
||||
)
|
||||
@@ -1387,12 +1444,13 @@ class InventoryItemRoleForm(NetBoxModelForm):
|
||||
|
||||
class VirtualDeviceContextForm(TenancyForm, NetBoxModelForm):
|
||||
device = DynamicModelChoiceField(
|
||||
label=_('Device'),
|
||||
queryset=Device.objects.all(),
|
||||
selector=True
|
||||
)
|
||||
primary_ip4 = DynamicModelChoiceField(
|
||||
queryset=IPAddress.objects.all(),
|
||||
label='Primary IPv4',
|
||||
label=_('Primary IPv4'),
|
||||
required=False,
|
||||
query_params={
|
||||
'device_id': '$device',
|
||||
@@ -1401,7 +1459,7 @@ class VirtualDeviceContextForm(TenancyForm, NetBoxModelForm):
|
||||
)
|
||||
primary_ip6 = DynamicModelChoiceField(
|
||||
queryset=IPAddress.objects.all(),
|
||||
label='Primary IPv6',
|
||||
label=_('Primary IPv6'),
|
||||
required=False,
|
||||
query_params={
|
||||
'device_id': '$device',
|
||||
@@ -1410,8 +1468,8 @@ class VirtualDeviceContextForm(TenancyForm, NetBoxModelForm):
|
||||
)
|
||||
|
||||
fieldsets = (
|
||||
('Virtual Device Context', ('device', 'name', 'status', 'identifier', 'primary_ip4', 'primary_ip6', 'tags')),
|
||||
('Tenancy', ('tenant_group', 'tenant'))
|
||||
(_('Virtual Device Context'), ('device', 'name', 'status', 'identifier', 'primary_ip4', 'primary_ip6', 'tags')),
|
||||
(_('Tenancy'), ('tenant_group', 'tenant'))
|
||||
)
|
||||
|
||||
class Meta:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from django import forms
|
||||
from django.utils.translation import gettext as _
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from dcim.models import *
|
||||
from netbox.forms import NetBoxModelForm
|
||||
@@ -38,8 +38,11 @@ class ComponentCreateForm(forms.Form):
|
||||
Subclass this form when facilitating the creation of one or more component or component template objects based on
|
||||
a name pattern.
|
||||
"""
|
||||
name = ExpandableNameField()
|
||||
name = ExpandableNameField(
|
||||
label=_('Name'),
|
||||
)
|
||||
label = ExpandableNameField(
|
||||
label=_('Label'),
|
||||
required=False,
|
||||
help_text=_('Alphanumeric ranges are supported. (Must match the number of objects being created.)')
|
||||
)
|
||||
@@ -57,8 +60,9 @@ class ComponentCreateForm(forms.Form):
|
||||
value_count = len(self.cleaned_data[field_name])
|
||||
if self.cleaned_data[field_name] and value_count != pattern_count:
|
||||
raise forms.ValidationError({
|
||||
field_name: f'The provided pattern specifies {value_count} values, but {pattern_count} are '
|
||||
f'expected.'
|
||||
field_name: _(
|
||||
"The provided pattern specifies {value_count} values, but {pattern_count} are expected."
|
||||
).format(value_count=value_count, pattern_count=pattern_count)
|
||||
}, code='label_pattern_mismatch')
|
||||
|
||||
|
||||
@@ -222,12 +226,14 @@ class InterfaceCreateForm(ComponentCreateForm, model_forms.InterfaceForm):
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
if 'module' in self.fields:
|
||||
self.fields['name'].help_text += ' The string <code>{module}</code> will be replaced with the position ' \
|
||||
'of the assigned module, if any'
|
||||
self.fields['name'].help_text += _(
|
||||
"The string <code>{module}</code> will be replaced with the position of the assigned module, if any."
|
||||
)
|
||||
|
||||
|
||||
class FrontPortCreateForm(ComponentCreateForm, model_forms.FrontPortForm):
|
||||
device = DynamicModelChoiceField(
|
||||
label=_('Device'),
|
||||
queryset=Device.objects.all(),
|
||||
selector=True,
|
||||
widget=APISelect(
|
||||
@@ -329,6 +335,7 @@ class InventoryItemCreateForm(ComponentCreateForm, model_forms.InventoryItemForm
|
||||
|
||||
class VirtualChassisCreateForm(NetBoxModelForm):
|
||||
region = DynamicModelChoiceField(
|
||||
label=_('Region'),
|
||||
queryset=Region.objects.all(),
|
||||
required=False,
|
||||
initial_params={
|
||||
@@ -336,6 +343,7 @@ class VirtualChassisCreateForm(NetBoxModelForm):
|
||||
}
|
||||
)
|
||||
site_group = DynamicModelChoiceField(
|
||||
label=_('Site group'),
|
||||
queryset=SiteGroup.objects.all(),
|
||||
required=False,
|
||||
initial_params={
|
||||
@@ -343,6 +351,7 @@ class VirtualChassisCreateForm(NetBoxModelForm):
|
||||
}
|
||||
)
|
||||
site = DynamicModelChoiceField(
|
||||
label=_('Site'),
|
||||
queryset=Site.objects.all(),
|
||||
required=False,
|
||||
query_params={
|
||||
@@ -351,6 +360,7 @@ class VirtualChassisCreateForm(NetBoxModelForm):
|
||||
}
|
||||
)
|
||||
rack = DynamicModelChoiceField(
|
||||
label=_('Rack'),
|
||||
queryset=Rack.objects.all(),
|
||||
required=False,
|
||||
null_option='None',
|
||||
@@ -359,6 +369,7 @@ class VirtualChassisCreateForm(NetBoxModelForm):
|
||||
}
|
||||
)
|
||||
members = DynamicModelMultipleChoiceField(
|
||||
label=_('Members'),
|
||||
queryset=Device.objects.all(),
|
||||
required=False,
|
||||
query_params={
|
||||
@@ -367,6 +378,7 @@ class VirtualChassisCreateForm(NetBoxModelForm):
|
||||
}
|
||||
)
|
||||
initial_position = forms.IntegerField(
|
||||
label=_('Initial position'),
|
||||
initial=1,
|
||||
required=False,
|
||||
help_text=_('Position of the first member device. Increases by one for each additional member.')
|
||||
@@ -383,7 +395,7 @@ class VirtualChassisCreateForm(NetBoxModelForm):
|
||||
|
||||
if self.cleaned_data['members'] and self.cleaned_data['initial_position'] is None:
|
||||
raise forms.ValidationError({
|
||||
'initial_position': "A position must be specified for the first VC member."
|
||||
'initial_position': _("A position must be specified for the first VC member.")
|
||||
})
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from django import forms
|
||||
from django.utils.translation import gettext as _
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from dcim.choices import InterfacePoEModeChoices, InterfacePoETypeChoices, InterfaceTypeChoices, PortTypeChoices
|
||||
from dcim.models import *
|
||||
@@ -57,6 +57,7 @@ class PowerPortTemplateImportForm(ComponentTemplateImportForm):
|
||||
|
||||
class PowerOutletTemplateImportForm(ComponentTemplateImportForm):
|
||||
power_port = forms.ModelChoiceField(
|
||||
label=_('Power port'),
|
||||
queryset=PowerPortTemplate.objects.all(),
|
||||
to_field_name='name',
|
||||
required=False
|
||||
@@ -85,6 +86,7 @@ class PowerOutletTemplateImportForm(ComponentTemplateImportForm):
|
||||
|
||||
class InterfaceTemplateImportForm(ComponentTemplateImportForm):
|
||||
type = forms.ChoiceField(
|
||||
label=_('Type'),
|
||||
choices=InterfaceTypeChoices.CHOICES
|
||||
)
|
||||
poe_mode = forms.ChoiceField(
|
||||
@@ -113,9 +115,11 @@ class InterfaceTemplateImportForm(ComponentTemplateImportForm):
|
||||
|
||||
class FrontPortTemplateImportForm(ComponentTemplateImportForm):
|
||||
type = forms.ChoiceField(
|
||||
label=_('Type'),
|
||||
choices=PortTypeChoices.CHOICES
|
||||
)
|
||||
rear_port = forms.ModelChoiceField(
|
||||
label=_('Rear port'),
|
||||
queryset=RearPortTemplate.objects.all(),
|
||||
to_field_name='name'
|
||||
)
|
||||
@@ -143,6 +147,7 @@ class FrontPortTemplateImportForm(ComponentTemplateImportForm):
|
||||
|
||||
class RearPortTemplateImportForm(ComponentTemplateImportForm):
|
||||
type = forms.ChoiceField(
|
||||
label=_('Type'),
|
||||
choices=PortTypeChoices.CHOICES
|
||||
)
|
||||
|
||||
@@ -173,15 +178,18 @@ class DeviceBayTemplateImportForm(ComponentTemplateImportForm):
|
||||
|
||||
class InventoryItemTemplateImportForm(ComponentTemplateImportForm):
|
||||
parent = forms.ModelChoiceField(
|
||||
label=_('Parent'),
|
||||
queryset=InventoryItemTemplate.objects.all(),
|
||||
required=False
|
||||
)
|
||||
role = forms.ModelChoiceField(
|
||||
label=_('Role'),
|
||||
queryset=InventoryItemRole.objects.all(),
|
||||
to_field_name='name',
|
||||
required=False
|
||||
)
|
||||
manufacturer = forms.ModelChoiceField(
|
||||
label=_('Manufacturer'),
|
||||
queryset=Manufacturer.objects.all(),
|
||||
to_field_name='name',
|
||||
required=False
|
||||
|
||||
Reference in New Issue
Block a user