diff --git a/netbox/dcim/forms/bulk_create.py b/netbox/dcim/forms/bulk_create.py index 2d86a1718..499c1996f 100644 --- a/netbox/dcim/forms/bulk_create.py +++ b/netbox/dcim/forms/bulk_create.py @@ -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 @@ -28,14 +28,17 @@ __all__ = ( class DeviceBulkAddComponentForm(BootstrapMixin, CustomFieldsMixin, ComponentCreateForm): pk = forms.ModelMultipleChoiceField( + label=_('Pk'), queryset=Device.objects.all(), widget=forms.MultipleHiddenInput() ) description = forms.CharField( + label=_('Description'), max_length=100, required=False ) tags = DynamicModelMultipleChoiceField( + label=_('Tags'), queryset=Tag.objects.all(), required=False ) diff --git a/netbox/dcim/forms/bulk_edit.py b/netbox/dcim/forms/bulk_edit.py index 5a465bfc8..3a5fc6efd 100644 --- a/netbox/dcim/forms/bulk_edit.py +++ b/netbox/dcim/forms/bulk_edit.py @@ -1,7 +1,7 @@ from django import forms from django.conf import settings from django.contrib.auth import get_user_model -from django.utils.translation import gettext as _ +from django.utils.translation import gettext_lazy as _ from timezone_field import TimeZoneFormField from dcim.choices import * @@ -63,10 +63,12 @@ __all__ = ( class RegionBulkEditForm(NetBoxModelBulkEditForm): parent = DynamicModelChoiceField( + label=_('Parent'), queryset=Region.objects.all(), required=False ) description = forms.CharField( + label=_('Description'), max_length=200, required=False ) @@ -80,10 +82,12 @@ class RegionBulkEditForm(NetBoxModelBulkEditForm): class SiteGroupBulkEditForm(NetBoxModelBulkEditForm): parent = DynamicModelChoiceField( + label=_('Parent'), queryset=SiteGroup.objects.all(), required=False ) description = forms.CharField( + label=_('Description'), max_length=200, required=False ) @@ -97,19 +101,23 @@ class SiteGroupBulkEditForm(NetBoxModelBulkEditForm): class SiteBulkEditForm(NetBoxModelBulkEditForm): status = forms.ChoiceField( + label=_('Status'), choices=add_blank_choice(SiteStatusChoices), required=False, initial='' ) region = DynamicModelChoiceField( + label=_('Region'), queryset=Region.objects.all(), required=False ) group = DynamicModelChoiceField( + label=_('Group'), queryset=SiteGroup.objects.all(), required=False ) tenant = DynamicModelChoiceField( + label=_('Tenant'), queryset=Tenant.objects.all(), required=False ) @@ -119,10 +127,12 @@ class SiteBulkEditForm(NetBoxModelBulkEditForm): required=False ) contact_name = forms.CharField( + label=_('Contact name'), max_length=50, required=False ) contact_phone = forms.CharField( + label=_('Contact phone'), max_length=20, required=False ) @@ -131,15 +141,17 @@ class SiteBulkEditForm(NetBoxModelBulkEditForm): label=_('Contact E-mail') ) time_zone = TimeZoneFormField( + label=_('Time zone'), choices=add_blank_choice(TimeZoneFormField().choices), required=False ) description = forms.CharField( + label=_('Description'), max_length=200, required=False ) comments = CommentField( - label='Comments' + label=_('Comments') ) model = Site @@ -153,10 +165,12 @@ class SiteBulkEditForm(NetBoxModelBulkEditForm): class LocationBulkEditForm(NetBoxModelBulkEditForm): site = DynamicModelChoiceField( + label=_('Site'), queryset=Site.objects.all(), required=False ) parent = DynamicModelChoiceField( + label=_('Parent'), queryset=Location.objects.all(), required=False, query_params={ @@ -164,15 +178,18 @@ class LocationBulkEditForm(NetBoxModelBulkEditForm): } ) status = forms.ChoiceField( + label=_('Status'), choices=add_blank_choice(LocationStatusChoices), required=False, initial='' ) tenant = DynamicModelChoiceField( + label=_('Tenant'), queryset=Tenant.objects.all(), required=False ) description = forms.CharField( + label=_('Description'), max_length=200, required=False ) @@ -186,9 +203,11 @@ class LocationBulkEditForm(NetBoxModelBulkEditForm): class RackRoleBulkEditForm(NetBoxModelBulkEditForm): color = ColorField( + label=_('Color'), required=False ) description = forms.CharField( + label=_('Description'), max_length=200, required=False ) @@ -202,6 +221,7 @@ class RackRoleBulkEditForm(NetBoxModelBulkEditForm): class RackBulkEditForm(NetBoxModelBulkEditForm): region = DynamicModelChoiceField( + label=_('Region'), queryset=Region.objects.all(), required=False, initial_params={ @@ -209,6 +229,7 @@ class RackBulkEditForm(NetBoxModelBulkEditForm): } ) site_group = DynamicModelChoiceField( + label=_('Site group'), queryset=SiteGroup.objects.all(), required=False, initial_params={ @@ -216,6 +237,7 @@ class RackBulkEditForm(NetBoxModelBulkEditForm): } ) site = DynamicModelChoiceField( + label=_('Site'), queryset=Site.objects.all(), required=False, query_params={ @@ -224,6 +246,7 @@ class RackBulkEditForm(NetBoxModelBulkEditForm): } ) location = DynamicModelChoiceField( + label=_('Location'), queryset=Location.objects.all(), required=False, query_params={ @@ -231,15 +254,18 @@ class RackBulkEditForm(NetBoxModelBulkEditForm): } ) tenant = DynamicModelChoiceField( + label=_('Tenant'), queryset=Tenant.objects.all(), required=False ) status = forms.ChoiceField( + label=_('Status'), choices=add_blank_choice(RackStatusChoices), required=False, initial='' ) role = DynamicModelChoiceField( + label=_('Role'), queryset=RackRole.objects.all(), required=False ) @@ -249,14 +275,17 @@ class RackBulkEditForm(NetBoxModelBulkEditForm): label=_('Serial Number') ) asset_tag = forms.CharField( + label=_('Asset tag'), max_length=50, required=False ) type = forms.ChoiceField( + label=_('Type'), choices=add_blank_choice(RackTypeChoices), required=False ) width = forms.ChoiceField( + label=_('Width'), choices=add_blank_choice(RackWidthChoices), required=False ) @@ -270,50 +299,58 @@ class RackBulkEditForm(NetBoxModelBulkEditForm): label=_('Descending units') ) outer_width = forms.IntegerField( + label=_('Outer width'), required=False, min_value=1 ) outer_depth = forms.IntegerField( + label=_('Outer depth'), required=False, min_value=1 ) outer_unit = forms.ChoiceField( + label=_('Outer unit'), choices=add_blank_choice(RackDimensionUnitChoices), required=False ) mounting_depth = forms.IntegerField( + label=_('Mounting depth'), required=False, min_value=1 ) weight = forms.DecimalField( + label=_('Weight'), min_value=0, required=False ) max_weight = forms.IntegerField( + label=_('Max weight'), min_value=0, required=False ) weight_unit = forms.ChoiceField( + label=_('Weight unit'), choices=add_blank_choice(WeightUnitChoices), required=False, initial='' ) description = forms.CharField( + label=_('Description'), max_length=200, required=False ) comments = CommentField( - label='Comments' + label=_('Comments') ) model = Rack fieldsets = ( - ('Rack', ('status', 'role', 'tenant', 'serial', 'asset_tag', 'description')), - ('Location', ('region', 'site_group', 'site', 'location')), - ('Hardware', ( + (_('Rack'), ('status', 'role', 'tenant', 'serial', 'asset_tag', 'description')), + (_('Location'), ('region', 'site_group', 'site', 'location')), + (_('Hardware'), ( 'type', 'width', 'u_height', 'desc_units', 'outer_width', 'outer_depth', 'outer_unit', 'mounting_depth', )), - ('Weight', ('weight', 'max_weight', 'weight_unit')), + (_('Weight'), ('weight', 'max_weight', 'weight_unit')), ) nullable_fields = ( 'location', 'tenant', 'role', 'serial', 'asset_tag', 'outer_width', 'outer_depth', 'outer_unit', 'weight', @@ -323,21 +360,24 @@ class RackBulkEditForm(NetBoxModelBulkEditForm): class RackReservationBulkEditForm(NetBoxModelBulkEditForm): user = forms.ModelChoiceField( + label=_('User'), queryset=get_user_model().objects.order_by( 'username' ), required=False ) tenant = DynamicModelChoiceField( + label=_('Tenant'), queryset=Tenant.objects.all(), required=False ) description = forms.CharField( + label=_('Description'), max_length=200, required=False ) comments = CommentField( - label='Comments' + label=_('Comments') ) model = RackReservation @@ -349,6 +389,7 @@ class RackReservationBulkEditForm(NetBoxModelBulkEditForm): class ManufacturerBulkEditForm(NetBoxModelBulkEditForm): description = forms.CharField( + label=_('Description'), max_length=200, required=False ) @@ -362,17 +403,21 @@ class ManufacturerBulkEditForm(NetBoxModelBulkEditForm): class DeviceTypeBulkEditForm(NetBoxModelBulkEditForm): manufacturer = DynamicModelChoiceField( + label=_('Manufacturer'), queryset=Manufacturer.objects.all(), required=False ) default_platform = DynamicModelChoiceField( + label=_('Default platform'), queryset=Platform.objects.all(), required=False ) part_number = forms.CharField( + label=_('Part number'), required=False ) u_height = forms.IntegerField( + label=_('U height'), min_value=1, required=False ) @@ -382,69 +427,79 @@ class DeviceTypeBulkEditForm(NetBoxModelBulkEditForm): label=_('Is full depth') ) airflow = forms.ChoiceField( + label=_('Airflow'), choices=add_blank_choice(DeviceAirflowChoices), required=False ) weight = forms.DecimalField( + label=_('Weight'), min_value=0, required=False ) weight_unit = forms.ChoiceField( + label=_('Weight unit'), choices=add_blank_choice(WeightUnitChoices), required=False, initial='' ) description = forms.CharField( + label=_('Description'), max_length=200, required=False ) comments = CommentField( - label='Comments' + label=_('Comments') ) model = DeviceType fieldsets = ( - ('Device Type', ('manufacturer', 'default_platform', 'part_number', 'u_height', 'is_full_depth', 'airflow', 'description')), - ('Weight', ('weight', 'weight_unit')), + (_('Device Type'), ('manufacturer', 'default_platform', 'part_number', 'u_height', 'is_full_depth', 'airflow', 'description')), + (_('Weight'), ('weight', 'weight_unit')), ) nullable_fields = ('part_number', 'airflow', 'weight', 'weight_unit', 'description', 'comments') class ModuleTypeBulkEditForm(NetBoxModelBulkEditForm): manufacturer = DynamicModelChoiceField( + label=_('Manufacturer'), queryset=Manufacturer.objects.all(), required=False ) part_number = forms.CharField( + label=_('Part number'), required=False ) weight = forms.DecimalField( + label=_('Weight'), min_value=0, required=False ) weight_unit = forms.ChoiceField( + label=_('Weight unit'), choices=add_blank_choice(WeightUnitChoices), required=False, initial='' ) description = forms.CharField( + label=_('Description'), max_length=200, required=False ) comments = CommentField( - label='Comments' + label=_('Comments') ) model = ModuleType fieldsets = ( - ('Module Type', ('manufacturer', 'part_number', 'description')), - ('Weight', ('weight', 'weight_unit')), + (_('Module Type'), ('manufacturer', 'part_number', 'description')), + (_('Weight'), ('weight', 'weight_unit')), ) nullable_fields = ('part_number', 'weight', 'weight_unit', 'description', 'comments') class DeviceRoleBulkEditForm(NetBoxModelBulkEditForm): color = ColorField( + label=_('Color'), required=False ) vm_role = forms.NullBooleanField( @@ -453,10 +508,12 @@ class DeviceRoleBulkEditForm(NetBoxModelBulkEditForm): label=_('VM role') ) config_template = DynamicModelChoiceField( + label=_('Config template'), queryset=ConfigTemplate.objects.all(), required=False ) description = forms.CharField( + label=_('Description'), max_length=200, required=False ) @@ -470,14 +527,17 @@ class DeviceRoleBulkEditForm(NetBoxModelBulkEditForm): class PlatformBulkEditForm(NetBoxModelBulkEditForm): manufacturer = DynamicModelChoiceField( + label=_('Manufacturer'), queryset=Manufacturer.objects.all(), required=False ) config_template = DynamicModelChoiceField( + label=_('Config template'), queryset=ConfigTemplate.objects.all(), required=False ) description = forms.CharField( + label=_('Description'), max_length=200, required=False ) @@ -491,10 +551,12 @@ class PlatformBulkEditForm(NetBoxModelBulkEditForm): class DeviceBulkEditForm(NetBoxModelBulkEditForm): manufacturer = DynamicModelChoiceField( + label=_('Manufacturer'), queryset=Manufacturer.objects.all(), required=False ) device_type = DynamicModelChoiceField( + label=_('Device type'), queryset=DeviceType.objects.all(), required=False, query_params={ @@ -502,14 +564,17 @@ class DeviceBulkEditForm(NetBoxModelBulkEditForm): } ) device_role = DynamicModelChoiceField( + label=_('Device role'), queryset=DeviceRole.objects.all(), required=False ) site = DynamicModelChoiceField( + label=_('Site'), queryset=Site.objects.all(), required=False ) location = DynamicModelChoiceField( + label=_('Location'), queryset=Location.objects.all(), required=False, query_params={ @@ -517,18 +582,22 @@ class DeviceBulkEditForm(NetBoxModelBulkEditForm): } ) tenant = DynamicModelChoiceField( + label=_('Tenant'), queryset=Tenant.objects.all(), required=False ) platform = DynamicModelChoiceField( + label=_('Platform'), queryset=Platform.objects.all(), required=False ) status = forms.ChoiceField( + label=_('Status'), choices=add_blank_choice(DeviceStatusChoices), required=False ) airflow = forms.ChoiceField( + label=_('Airflow'), choices=add_blank_choice(DeviceAirflowChoices), required=False ) @@ -538,23 +607,25 @@ class DeviceBulkEditForm(NetBoxModelBulkEditForm): label=_('Serial Number') ) description = forms.CharField( + label=_('Description'), max_length=200, required=False ) config_template = DynamicModelChoiceField( + label=_('Config template'), queryset=ConfigTemplate.objects.all(), required=False ) comments = CommentField( - label='Comments' + label=_('Comments') ) model = Device fieldsets = ( - ('Device', ('device_role', 'status', 'tenant', 'platform', 'description')), - ('Location', ('site', 'location')), - ('Hardware', ('manufacturer', 'device_type', 'airflow', 'serial')), - ('Configuration', ('config_template',)), + (_('Device'), ('device_role', 'status', 'tenant', 'platform', 'description')), + (_('Location'), ('site', 'location')), + (_('Hardware'), ('manufacturer', 'device_type', 'airflow', 'serial')), + (_('Configuration'), ('config_template',)), ) nullable_fields = ( 'location', 'tenant', 'platform', 'serial', 'airflow', 'description', 'comments', @@ -563,10 +634,12 @@ class DeviceBulkEditForm(NetBoxModelBulkEditForm): class ModuleBulkEditForm(NetBoxModelBulkEditForm): manufacturer = DynamicModelChoiceField( + label=_('Manufacturer'), queryset=Manufacturer.objects.all(), required=False ) module_type = DynamicModelChoiceField( + label=_('Module type'), queryset=ModuleType.objects.all(), required=False, query_params={ @@ -574,6 +647,7 @@ class ModuleBulkEditForm(NetBoxModelBulkEditForm): } ) status = forms.ChoiceField( + label=_('Status'), choices=add_blank_choice(ModuleStatusChoices), required=False, initial='' @@ -584,11 +658,12 @@ class ModuleBulkEditForm(NetBoxModelBulkEditForm): label=_('Serial Number') ) description = forms.CharField( + label=_('Description'), max_length=200, required=False ) comments = CommentField( - label='Comments' + label=_('Comments') ) model = Module @@ -600,47 +675,55 @@ class ModuleBulkEditForm(NetBoxModelBulkEditForm): class CableBulkEditForm(NetBoxModelBulkEditForm): type = forms.ChoiceField( + label=_('Type'), choices=add_blank_choice(CableTypeChoices), required=False, initial='' ) status = forms.ChoiceField( + label=_('Status'), choices=add_blank_choice(LinkStatusChoices), required=False, initial='' ) tenant = DynamicModelChoiceField( + label=_('Tenant'), queryset=Tenant.objects.all(), required=False ) label = forms.CharField( + label=_('Label'), max_length=100, required=False ) color = ColorField( + label=_('Color'), required=False ) length = forms.DecimalField( + label=_('Length'), min_value=0, required=False ) length_unit = forms.ChoiceField( + label=_('Length unit'), choices=add_blank_choice(CableLengthUnitChoices), required=False, initial='' ) description = forms.CharField( + label=_('Description'), max_length=200, required=False ) comments = CommentField( - label='Comments' + label=_('Comments') ) model = Cable fieldsets = ( (None, ('type', 'status', 'tenant', 'label', 'description')), - ('Attributes', ('color', 'length', 'length_unit')), + (_('Attributes'), ('color', 'length', 'length_unit')), ) nullable_fields = ( 'type', 'status', 'tenant', 'label', 'color', 'length', 'description', 'comments', @@ -649,15 +732,17 @@ class CableBulkEditForm(NetBoxModelBulkEditForm): class VirtualChassisBulkEditForm(NetBoxModelBulkEditForm): domain = forms.CharField( + label=_('Domain'), max_length=30, required=False ) description = forms.CharField( + label=_('Description'), max_length=200, required=False ) comments = CommentField( - label='Comments' + label=_('Comments') ) model = VirtualChassis @@ -669,6 +754,7 @@ class VirtualChassisBulkEditForm(NetBoxModelBulkEditForm): class PowerPanelBulkEditForm(NetBoxModelBulkEditForm): region = DynamicModelChoiceField( + label=_('Region'), queryset=Region.objects.all(), required=False, initial_params={ @@ -676,6 +762,7 @@ class PowerPanelBulkEditForm(NetBoxModelBulkEditForm): } ) site_group = DynamicModelChoiceField( + label=_('Site group'), queryset=SiteGroup.objects.all(), required=False, initial_params={ @@ -683,6 +770,7 @@ class PowerPanelBulkEditForm(NetBoxModelBulkEditForm): } ) site = DynamicModelChoiceField( + label=_('Site'), queryset=Site.objects.all(), required=False, query_params={ @@ -691,6 +779,7 @@ class PowerPanelBulkEditForm(NetBoxModelBulkEditForm): } ) location = DynamicModelChoiceField( + label=_('Location'), queryset=Location.objects.all(), required=False, query_params={ @@ -698,11 +787,12 @@ class PowerPanelBulkEditForm(NetBoxModelBulkEditForm): } ) description = forms.CharField( + label=_('Description'), max_length=200, required=False ) comments = CommentField( - label='Comments' + label=_('Comments') ) model = PowerPanel @@ -714,47 +804,58 @@ class PowerPanelBulkEditForm(NetBoxModelBulkEditForm): class PowerFeedBulkEditForm(NetBoxModelBulkEditForm): power_panel = DynamicModelChoiceField( + label=_('Power panel'), queryset=PowerPanel.objects.all(), required=False ) rack = DynamicModelChoiceField( + label=_('Rack'), queryset=Rack.objects.all(), required=False, ) status = forms.ChoiceField( + label=_('Status'), choices=add_blank_choice(PowerFeedStatusChoices), required=False, initial='' ) type = forms.ChoiceField( + label=_('Type'), choices=add_blank_choice(PowerFeedTypeChoices), required=False, initial='' ) supply = forms.ChoiceField( + label=_('Supply'), choices=add_blank_choice(PowerFeedSupplyChoices), required=False, initial='' ) phase = forms.ChoiceField( + label=_('Phase'), choices=add_blank_choice(PowerFeedPhaseChoices), required=False, initial='' ) voltage = forms.IntegerField( + label=_('Voltage'), required=False ) amperage = forms.IntegerField( + label=_('Amperage'), required=False ) max_utilization = forms.IntegerField( + label=_('Max utilization'), required=False ) mark_connected = forms.NullBooleanField( + label=_('Mark connected'), required=False, widget=BulkEditNullBooleanSelect ) description = forms.CharField( + label=_('Description'), max_length=200, required=False ) @@ -765,7 +866,7 @@ class PowerFeedBulkEditForm(NetBoxModelBulkEditForm): model = PowerFeed fieldsets = ( (None, ('power_panel', 'rack', 'status', 'type', 'mark_connected', 'description')), - ('Power', ('supply', 'phase', 'voltage', 'amperage', 'max_utilization')) + (_('Power'), ('supply', 'phase', 'voltage', 'amperage', 'max_utilization')) ) nullable_fields = ('location', 'description', 'comments') @@ -776,14 +877,17 @@ class PowerFeedBulkEditForm(NetBoxModelBulkEditForm): class ConsolePortTemplateBulkEditForm(BulkEditForm): pk = forms.ModelMultipleChoiceField( + label=_('Pk'), queryset=ConsolePortTemplate.objects.all(), widget=forms.MultipleHiddenInput() ) label = forms.CharField( + label=_('Label'), max_length=64, required=False ) type = forms.ChoiceField( + label=_('Type'), choices=add_blank_choice(ConsolePortTypeChoices), required=False ) @@ -793,18 +897,22 @@ class ConsolePortTemplateBulkEditForm(BulkEditForm): class ConsoleServerPortTemplateBulkEditForm(BulkEditForm): pk = forms.ModelMultipleChoiceField( + label=_('Pk'), queryset=ConsoleServerPortTemplate.objects.all(), widget=forms.MultipleHiddenInput() ) label = forms.CharField( + label=_('Label'), max_length=64, required=False ) type = forms.ChoiceField( + label=_('Type'), choices=add_blank_choice(ConsolePortTypeChoices), required=False ) description = forms.CharField( + label=_('Description'), required=False ) @@ -813,28 +921,34 @@ class ConsoleServerPortTemplateBulkEditForm(BulkEditForm): class PowerPortTemplateBulkEditForm(BulkEditForm): pk = forms.ModelMultipleChoiceField( + label=_('Pk'), queryset=PowerPortTemplate.objects.all(), widget=forms.MultipleHiddenInput() ) label = forms.CharField( + label=_('Label'), max_length=64, required=False ) type = forms.ChoiceField( + label=_('Type'), choices=add_blank_choice(PowerPortTypeChoices), required=False ) maximum_draw = forms.IntegerField( + label=_('Maximum draw'), min_value=1, required=False, help_text=_("Maximum power draw (watts)") ) allocated_draw = forms.IntegerField( + label=_('Allocated draw'), min_value=1, required=False, help_text=_("Allocated power draw (watts)") ) description = forms.CharField( + label=_('Description'), required=False ) @@ -843,32 +957,39 @@ class PowerPortTemplateBulkEditForm(BulkEditForm): class PowerOutletTemplateBulkEditForm(BulkEditForm): pk = forms.ModelMultipleChoiceField( + label=_('Pk'), queryset=PowerOutletTemplate.objects.all(), widget=forms.MultipleHiddenInput() ) device_type = forms.ModelChoiceField( + label=_('Device type'), queryset=DeviceType.objects.all(), required=False, disabled=True, widget=forms.HiddenInput() ) label = forms.CharField( + label=_('Label'), max_length=64, required=False ) type = forms.ChoiceField( + label=_('Type'), choices=add_blank_choice(PowerOutletTypeChoices), required=False ) power_port = forms.ModelChoiceField( + label=_('Power port'), queryset=PowerPortTemplate.objects.all(), required=False ) feed_leg = forms.ChoiceField( + label=_('Feed leg'), choices=add_blank_choice(PowerOutletFeedLegChoices), required=False ) description = forms.CharField( + label=_('Description'), required=False ) @@ -888,18 +1009,22 @@ class PowerOutletTemplateBulkEditForm(BulkEditForm): class InterfaceTemplateBulkEditForm(BulkEditForm): pk = forms.ModelMultipleChoiceField( + label=_('Pk'), queryset=InterfaceTemplate.objects.all(), widget=forms.MultipleHiddenInput() ) label = forms.CharField( + label=_('Label'), max_length=64, required=False ) type = forms.ChoiceField( + label=_('Type'), choices=add_blank_choice(InterfaceTypeChoices), required=False ) enabled = forms.NullBooleanField( + label=_('Enabled'), required=False, widget=BulkEditNullBooleanSelect ) @@ -909,6 +1034,7 @@ class InterfaceTemplateBulkEditForm(BulkEditForm): label=_('Management only') ) description = forms.CharField( + label=_('Description'), required=False ) poe_mode = forms.ChoiceField( @@ -935,21 +1061,26 @@ class InterfaceTemplateBulkEditForm(BulkEditForm): class FrontPortTemplateBulkEditForm(BulkEditForm): pk = forms.ModelMultipleChoiceField( + label=_('Pk'), queryset=FrontPortTemplate.objects.all(), widget=forms.MultipleHiddenInput() ) label = forms.CharField( + label=_('Label'), max_length=64, required=False ) type = forms.ChoiceField( + label=_('Type'), choices=add_blank_choice(PortTypeChoices), required=False ) color = ColorField( + label=_('Color'), required=False ) description = forms.CharField( + label=_('Description'), required=False ) @@ -958,21 +1089,26 @@ class FrontPortTemplateBulkEditForm(BulkEditForm): class RearPortTemplateBulkEditForm(BulkEditForm): pk = forms.ModelMultipleChoiceField( + label=_('Pk'), queryset=RearPortTemplate.objects.all(), widget=forms.MultipleHiddenInput() ) label = forms.CharField( + label=_('Label'), max_length=64, required=False ) type = forms.ChoiceField( + label=_('Type'), choices=add_blank_choice(PortTypeChoices), required=False ) color = ColorField( + label=_('Color'), required=False ) description = forms.CharField( + label=_('Description'), required=False ) @@ -981,14 +1117,17 @@ class RearPortTemplateBulkEditForm(BulkEditForm): class ModuleBayTemplateBulkEditForm(BulkEditForm): pk = forms.ModelMultipleChoiceField( + label=_('Pk'), queryset=ModuleBayTemplate.objects.all(), widget=forms.MultipleHiddenInput() ) label = forms.CharField( + label=_('Label'), max_length=64, required=False ) description = forms.CharField( + label=_('Description'), required=False ) @@ -997,14 +1136,17 @@ class ModuleBayTemplateBulkEditForm(BulkEditForm): class DeviceBayTemplateBulkEditForm(BulkEditForm): pk = forms.ModelMultipleChoiceField( + label=_('Pk'), queryset=DeviceBayTemplate.objects.all(), widget=forms.MultipleHiddenInput() ) label = forms.CharField( + label=_('Label'), max_length=64, required=False ) description = forms.CharField( + label=_('Description'), required=False ) @@ -1013,21 +1155,26 @@ class DeviceBayTemplateBulkEditForm(BulkEditForm): class InventoryItemTemplateBulkEditForm(BulkEditForm): pk = forms.ModelMultipleChoiceField( + label=_('Pk'), queryset=InventoryItemTemplate.objects.all(), widget=forms.MultipleHiddenInput() ) label = forms.CharField( + label=_('Label'), max_length=64, required=False ) description = forms.CharField( + label=_('Description'), required=False ) role = DynamicModelChoiceField( + label=_('Role'), queryset=InventoryItemRole.objects.all(), required=False ) manufacturer = DynamicModelChoiceField( + label=_('Manufacturer'), queryset=Manufacturer.objects.all(), required=False ) @@ -1041,12 +1188,14 @@ class InventoryItemTemplateBulkEditForm(BulkEditForm): class ComponentBulkEditForm(NetBoxModelBulkEditForm): device = forms.ModelChoiceField( + label=_('Device'), queryset=Device.objects.all(), required=False, disabled=True, widget=forms.HiddenInput() ) module = forms.ModelChoiceField( + label=_('Module'), queryset=Module.objects.all(), required=False ) @@ -1068,6 +1217,7 @@ class ConsolePortBulkEditForm( ComponentBulkEditForm ): mark_connected = forms.NullBooleanField( + label=_('Mark connected'), required=False, widget=BulkEditNullBooleanSelect ) @@ -1084,6 +1234,7 @@ class ConsoleServerPortBulkEditForm( ComponentBulkEditForm ): mark_connected = forms.NullBooleanField( + label=_('Mark connected'), required=False, widget=BulkEditNullBooleanSelect ) @@ -1100,6 +1251,7 @@ class PowerPortBulkEditForm( ComponentBulkEditForm ): mark_connected = forms.NullBooleanField( + label=_('Mark connected'), required=False, widget=BulkEditNullBooleanSelect ) @@ -1107,7 +1259,7 @@ class PowerPortBulkEditForm( model = PowerPort fieldsets = ( (None, ('module', 'type', 'label', 'description', 'mark_connected')), - ('Power', ('maximum_draw', 'allocated_draw')), + (_('Power'), ('maximum_draw', 'allocated_draw')), ) nullable_fields = ('module', 'label', 'description', 'maximum_draw', 'allocated_draw') @@ -1117,6 +1269,7 @@ class PowerOutletBulkEditForm( ComponentBulkEditForm ): mark_connected = forms.NullBooleanField( + label=_('Mark connected'), required=False, widget=BulkEditNullBooleanSelect ) @@ -1124,7 +1277,7 @@ class PowerOutletBulkEditForm( model = PowerOutlet fieldsets = ( (None, ('module', 'type', 'label', 'description', 'mark_connected')), - ('Power', ('feed_leg', 'power_port')), + (_('Power'), ('feed_leg', 'power_port')), ) nullable_fields = ('module', 'label', 'type', 'feed_leg', 'power_port', 'description') @@ -1149,14 +1302,17 @@ class InterfaceBulkEditForm( ComponentBulkEditForm ): enabled = forms.NullBooleanField( + label=_('Enabled'), required=False, widget=BulkEditNullBooleanSelect ) parent = DynamicModelChoiceField( + label=_('Parent'), queryset=Interface.objects.all(), required=False ) bridge = DynamicModelChoiceField( + label=_('Bridge'), queryset=Interface.objects.all(), required=False ) @@ -1171,12 +1327,13 @@ class InterfaceBulkEditForm( vdcs = DynamicModelMultipleChoiceField( queryset=VirtualDeviceContext.objects.all(), required=False, - label='Virtual Device Contexts', + label=_('Virtual Device Contexts'), query_params={ 'device_id': '$device', } ) speed = forms.IntegerField( + label=_('Speed'), required=False, widget=NumberWithOptions( options=InterfaceSpeedChoices @@ -1200,10 +1357,12 @@ class InterfaceBulkEditForm( label=_('PoE type') ) mark_connected = forms.NullBooleanField( + label=_('Mark connected'), required=False, widget=BulkEditNullBooleanSelect ) mode = forms.ChoiceField( + label=_('Mode'), choices=add_blank_choice(InterfaceModeChoices), required=False, initial='' @@ -1251,12 +1410,12 @@ class InterfaceBulkEditForm( model = Interface fieldsets = ( (None, ('module', 'type', 'label', 'speed', 'duplex', 'description')), - ('Addressing', ('vrf', 'mac_address', 'wwn')), - ('Operation', ('vdcs', 'mtu', 'tx_power', 'enabled', 'mgmt_only', 'mark_connected')), - ('PoE', ('poe_mode', 'poe_type')), - ('Related Interfaces', ('parent', 'bridge', 'lag')), - ('802.1Q Switching', ('mode', 'vlan_group', 'untagged_vlan', 'tagged_vlans')), - ('Wireless', ( + (_('Addressing'), ('vrf', 'mac_address', 'wwn')), + (_('Operation'), ('vdcs', 'mtu', 'tx_power', 'enabled', 'mgmt_only', 'mark_connected')), + (_('PoE'), ('poe_mode', 'poe_type')), + (_('Related Interfaces'), ('parent', 'bridge', 'lag')), + (_('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', )), ) @@ -1316,14 +1475,14 @@ class InterfaceBulkEditForm( if not self.cleaned_data['mode']: if self.cleaned_data['untagged_vlan']: - raise forms.ValidationError({'untagged_vlan': "Interface mode must be specified to assign VLANs"}) + raise forms.ValidationError({'untagged_vlan': _("Interface mode must be specified to assign VLANs")}) elif self.cleaned_data['tagged_vlans']: - raise forms.ValidationError({'tagged_vlans': "Interface mode must be specified to assign VLANs"}) + raise forms.ValidationError({'tagged_vlans': _("Interface mode must be specified to assign VLANs")}) # Untagged interfaces cannot be assigned tagged VLANs elif self.cleaned_data['mode'] == InterfaceModeChoices.MODE_ACCESS and self.cleaned_data['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 @@ -1336,6 +1495,7 @@ class FrontPortBulkEditForm( ComponentBulkEditForm ): mark_connected = forms.NullBooleanField( + label=_('Mark connected'), required=False, widget=BulkEditNullBooleanSelect ) @@ -1352,6 +1512,7 @@ class RearPortBulkEditForm( ComponentBulkEditForm ): mark_connected = forms.NullBooleanField( + label=_('Mark connected'), required=False, widget=BulkEditNullBooleanSelect ) @@ -1390,14 +1551,17 @@ class InventoryItemBulkEditForm( NetBoxModelBulkEditForm ): device = DynamicModelChoiceField( + label=_('Device'), queryset=Device.objects.all(), required=False ) role = DynamicModelChoiceField( + label=_('Role'), queryset=InventoryItemRole.objects.all(), required=False ) manufacturer = DynamicModelChoiceField( + label=_('Manufacturer'), queryset=Manufacturer.objects.all(), required=False ) @@ -1415,9 +1579,11 @@ class InventoryItemBulkEditForm( class InventoryItemRoleBulkEditForm(NetBoxModelBulkEditForm): color = ColorField( + label=_('Color'), required=False ) description = forms.CharField( + label=_('Description'), max_length=200, required=False ) @@ -1431,14 +1597,17 @@ class InventoryItemRoleBulkEditForm(NetBoxModelBulkEditForm): class VirtualDeviceContextBulkEditForm(NetBoxModelBulkEditForm): device = DynamicModelChoiceField( + label=_('Device'), queryset=Device.objects.all(), required=False ) status = forms.ChoiceField( + label=_('Status'), required=False, choices=add_blank_choice(VirtualDeviceContextStatusChoices) ) tenant = DynamicModelChoiceField( + label=_('Tenant'), queryset=Tenant.objects.all(), required=False ) diff --git a/netbox/dcim/forms/bulk_import.py b/netbox/dcim/forms/bulk_import.py index cd774fd18..5c8333a01 100644 --- a/netbox/dcim/forms/bulk_import.py +++ b/netbox/dcim/forms/bulk_import.py @@ -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', @@ -149,7 +159,9 @@ class LocationImportForm(NetBoxModelImportForm): class RackRoleImportForm(NetBoxModelImportForm): - slug = SlugField() + slug = SlugField( + label=_('Slug'), + ) class Meta: model = RackRole @@ -161,45 +173,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 +246,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 +308,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 +342,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 +365,7 @@ class ModuleTypeImportForm(NetBoxModelImportForm): class DeviceRoleImportForm(NetBoxModelImportForm): config_template = CSVModelChoiceField( + label=_('Config template'), queryset=ConfigTemplate.objects.all(), to_field_name='name', required=False, @@ -348,14 +382,18 @@ class DeviceRoleImportForm(NetBoxModelImportForm): class PlatformImportForm(NetBoxModelImportForm): - slug = SlugField() + slug = SlugField( + label=_('Slug'), + ) 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 +409,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 +476,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 +577,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 +639,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 +665,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 +691,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 +711,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 +764,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 +876,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 +924,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 +941,7 @@ class RearPortImportForm(NetBoxModelImportForm): class ModuleBayImportForm(NetBoxModelImportForm): device = CSVModelChoiceField( + label=_('Device'), queryset=Device.objects.all(), to_field_name='name' ) @@ -863,10 +953,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 +1001,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') ) @@ -985,7 +1083,9 @@ class InventoryItemImportForm(NetBoxModelImportForm): # class InventoryItemRoleImportForm(NetBoxModelImportForm): - slug = SlugField() + slug = SlugField( + label=_('Slug'), + ) class Meta: model = InventoryItemRole @@ -1002,52 +1102,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 +1220,7 @@ class CableImportForm(NetBoxModelImportForm): class VirtualChassisImportForm(NetBoxModelImportForm): master = CSVModelChoiceField( + label=_('Master'), queryset=Device.objects.all(), to_field_name='name', required=False, @@ -1127,11 +1238,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,40 +1266,48 @@ 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, help_text=_('Rack') ) 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') ) @@ -1222,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', diff --git a/netbox/dcim/forms/common.py b/netbox/dcim/forms/common.py index 064a9a80b..aa9be0ca3 100644 --- a/netbox/dcim/forms/common.py +++ b/netbox/dcim/forms/common.py @@ -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,8 @@ 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 +105,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 +114,12 @@ 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) )