mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-24 16:26:09 -06:00
13149 add gettext_lazy to forms
This commit is contained in:
parent
230d80a31d
commit
ef0f98c2c2
@ -1,5 +1,5 @@
|
||||
from django import forms
|
||||
from django.utils.translation import gettext as _
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from utilities.forms import BootstrapMixin, form_from_model
|
||||
from utilities.forms.fields import ExpandableNameField
|
||||
@ -12,6 +12,7 @@ __all__ = (
|
||||
|
||||
class VirtualMachineBulkAddComponentForm(BootstrapMixin, forms.Form):
|
||||
pk = forms.ModelMultipleChoiceField(
|
||||
label=_('Pk'),
|
||||
queryset=VirtualMachine.objects.all(),
|
||||
widget=forms.MultipleHiddenInput()
|
||||
)
|
||||
|
@ -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 InterfaceModeChoices
|
||||
from dcim.constants import INTERFACE_MTU_MAX, INTERFACE_MTU_MIN
|
||||
@ -25,6 +25,7 @@ __all__ = (
|
||||
|
||||
class ClusterTypeBulkEditForm(NetBoxModelBulkEditForm):
|
||||
description = forms.CharField(
|
||||
label=_('Description'),
|
||||
max_length=200,
|
||||
required=False
|
||||
)
|
||||
@ -38,6 +39,7 @@ class ClusterTypeBulkEditForm(NetBoxModelBulkEditForm):
|
||||
|
||||
class ClusterGroupBulkEditForm(NetBoxModelBulkEditForm):
|
||||
description = forms.CharField(
|
||||
label=_('Description'),
|
||||
max_length=200,
|
||||
required=False
|
||||
)
|
||||
@ -51,31 +53,38 @@ class ClusterGroupBulkEditForm(NetBoxModelBulkEditForm):
|
||||
|
||||
class ClusterBulkEditForm(NetBoxModelBulkEditForm):
|
||||
type = DynamicModelChoiceField(
|
||||
label=_('Type'),
|
||||
queryset=ClusterType.objects.all(),
|
||||
required=False
|
||||
)
|
||||
group = DynamicModelChoiceField(
|
||||
label=_('Group'),
|
||||
queryset=ClusterGroup.objects.all(),
|
||||
required=False
|
||||
)
|
||||
status = forms.ChoiceField(
|
||||
label=_('Status'),
|
||||
choices=add_blank_choice(ClusterStatusChoices),
|
||||
required=False,
|
||||
initial=''
|
||||
)
|
||||
tenant = DynamicModelChoiceField(
|
||||
label=_('Tenant'),
|
||||
queryset=Tenant.objects.all(),
|
||||
required=False
|
||||
)
|
||||
region = DynamicModelChoiceField(
|
||||
label=_('Region'),
|
||||
queryset=Region.objects.all(),
|
||||
required=False,
|
||||
)
|
||||
site_group = DynamicModelChoiceField(
|
||||
label=_('Site group'),
|
||||
queryset=SiteGroup.objects.all(),
|
||||
required=False,
|
||||
)
|
||||
site = DynamicModelChoiceField(
|
||||
label=_('Site'),
|
||||
queryset=Site.objects.all(),
|
||||
required=False,
|
||||
query_params={
|
||||
@ -84,6 +93,7 @@ class ClusterBulkEditForm(NetBoxModelBulkEditForm):
|
||||
}
|
||||
)
|
||||
description = forms.CharField(
|
||||
label=_('Site'),
|
||||
max_length=200,
|
||||
required=False
|
||||
)
|
||||
@ -94,7 +104,7 @@ class ClusterBulkEditForm(NetBoxModelBulkEditForm):
|
||||
model = Cluster
|
||||
fieldsets = (
|
||||
(None, ('type', 'group', 'status', 'tenant', 'description')),
|
||||
('Site', ('region', 'site_group', 'site')),
|
||||
(_('Site'), ('region', 'site_group', 'site')),
|
||||
)
|
||||
nullable_fields = (
|
||||
'group', 'site', 'tenant', 'description', 'comments',
|
||||
@ -103,15 +113,18 @@ class ClusterBulkEditForm(NetBoxModelBulkEditForm):
|
||||
|
||||
class VirtualMachineBulkEditForm(NetBoxModelBulkEditForm):
|
||||
status = forms.ChoiceField(
|
||||
label=_('Status'),
|
||||
choices=add_blank_choice(VirtualMachineStatusChoices),
|
||||
required=False,
|
||||
initial='',
|
||||
)
|
||||
site = DynamicModelChoiceField(
|
||||
label=_('Site'),
|
||||
queryset=Site.objects.all(),
|
||||
required=False
|
||||
)
|
||||
cluster = DynamicModelChoiceField(
|
||||
label=_('Cluster'),
|
||||
queryset=Cluster.objects.all(),
|
||||
required=False,
|
||||
query_params={
|
||||
@ -119,6 +132,7 @@ class VirtualMachineBulkEditForm(NetBoxModelBulkEditForm):
|
||||
}
|
||||
)
|
||||
device = DynamicModelChoiceField(
|
||||
label=_('Device'),
|
||||
queryset=Device.objects.all(),
|
||||
required=False,
|
||||
query_params={
|
||||
@ -126,6 +140,7 @@ class VirtualMachineBulkEditForm(NetBoxModelBulkEditForm):
|
||||
}
|
||||
)
|
||||
role = DynamicModelChoiceField(
|
||||
label=_('Role'),
|
||||
queryset=DeviceRole.objects.filter(
|
||||
vm_role=True
|
||||
),
|
||||
@ -135,10 +150,12 @@ class VirtualMachineBulkEditForm(NetBoxModelBulkEditForm):
|
||||
}
|
||||
)
|
||||
tenant = DynamicModelChoiceField(
|
||||
label=_('Tenant'),
|
||||
queryset=Tenant.objects.all(),
|
||||
required=False
|
||||
)
|
||||
platform = DynamicModelChoiceField(
|
||||
label=_('Platform'),
|
||||
queryset=Platform.objects.all(),
|
||||
required=False
|
||||
)
|
||||
@ -155,6 +172,7 @@ class VirtualMachineBulkEditForm(NetBoxModelBulkEditForm):
|
||||
label=_('Disk (GB)')
|
||||
)
|
||||
description = forms.CharField(
|
||||
label=_('Description'),
|
||||
max_length=200,
|
||||
required=False
|
||||
)
|
||||
@ -165,7 +183,7 @@ class VirtualMachineBulkEditForm(NetBoxModelBulkEditForm):
|
||||
model = VirtualMachine
|
||||
fieldsets = (
|
||||
(None, ('site', 'cluster', 'device', 'status', 'role', 'tenant', 'platform', 'description')),
|
||||
('Resources', ('vcpus', 'memory', 'disk'))
|
||||
(_('Resources'), ('vcpus', 'memory', 'disk'))
|
||||
)
|
||||
nullable_fields = (
|
||||
'site', 'cluster', 'device', 'role', 'tenant', 'platform', 'vcpus', 'memory', 'disk', 'description', 'comments',
|
||||
@ -174,20 +192,24 @@ class VirtualMachineBulkEditForm(NetBoxModelBulkEditForm):
|
||||
|
||||
class VMInterfaceBulkEditForm(NetBoxModelBulkEditForm):
|
||||
virtual_machine = forms.ModelChoiceField(
|
||||
label=_('Virtual machine'),
|
||||
queryset=VirtualMachine.objects.all(),
|
||||
required=False,
|
||||
disabled=True,
|
||||
widget=forms.HiddenInput()
|
||||
)
|
||||
parent = DynamicModelChoiceField(
|
||||
label=_('Parent'),
|
||||
queryset=VMInterface.objects.all(),
|
||||
required=False
|
||||
)
|
||||
bridge = DynamicModelChoiceField(
|
||||
label=_('Bridge'),
|
||||
queryset=VMInterface.objects.all(),
|
||||
required=False
|
||||
)
|
||||
enabled = forms.NullBooleanField(
|
||||
label=_('Enabled'),
|
||||
required=False,
|
||||
widget=BulkEditNullBooleanSelect()
|
||||
)
|
||||
@ -198,10 +220,12 @@ class VMInterfaceBulkEditForm(NetBoxModelBulkEditForm):
|
||||
label=_('MTU')
|
||||
)
|
||||
description = forms.CharField(
|
||||
label=_('Description'),
|
||||
max_length=100,
|
||||
required=False
|
||||
)
|
||||
mode = forms.ChoiceField(
|
||||
label=_('Mode'),
|
||||
choices=add_blank_choice(InterfaceModeChoices),
|
||||
required=False
|
||||
)
|
||||
@ -235,8 +259,8 @@ class VMInterfaceBulkEditForm(NetBoxModelBulkEditForm):
|
||||
model = VMInterface
|
||||
fieldsets = (
|
||||
(None, ('mtu', 'enabled', 'vrf', 'description')),
|
||||
('Related Interfaces', ('parent', 'bridge')),
|
||||
('802.1Q Switching', ('mode', 'vlan_group', 'untagged_vlan', 'tagged_vlans')),
|
||||
(_('Related Interfaces'), ('parent', 'bridge')),
|
||||
(_('802.1Q Switching'), ('mode', 'vlan_group', 'untagged_vlan', 'tagged_vlans')),
|
||||
)
|
||||
nullable_fields = (
|
||||
'parent', 'bridge', 'mtu', 'vrf', 'description',
|
||||
@ -286,6 +310,7 @@ class VMInterfaceBulkEditForm(NetBoxModelBulkEditForm):
|
||||
|
||||
class VMInterfaceBulkRenameForm(BulkRenameForm):
|
||||
pk = forms.ModelMultipleChoiceField(
|
||||
label=_('Pk'),
|
||||
queryset=VMInterface.objects.all(),
|
||||
widget=forms.MultipleHiddenInput()
|
||||
)
|
||||
|
@ -1,4 +1,4 @@
|
||||
from django.utils.translation import gettext as _
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from dcim.choices import InterfaceModeChoices
|
||||
from dcim.models import Device, DeviceRole, Platform, Site
|
||||
@ -19,7 +19,9 @@ __all__ = (
|
||||
|
||||
|
||||
class ClusterTypeImportForm(NetBoxModelImportForm):
|
||||
slug = SlugField()
|
||||
slug = SlugField(
|
||||
label=_('Slug'),
|
||||
)
|
||||
|
||||
class Meta:
|
||||
model = ClusterType
|
||||
@ -27,7 +29,9 @@ class ClusterTypeImportForm(NetBoxModelImportForm):
|
||||
|
||||
|
||||
class ClusterGroupImportForm(NetBoxModelImportForm):
|
||||
slug = SlugField()
|
||||
slug = SlugField(
|
||||
label=_('Slug'),
|
||||
)
|
||||
|
||||
class Meta:
|
||||
model = ClusterGroup
|
||||
@ -36,27 +40,32 @@ class ClusterGroupImportForm(NetBoxModelImportForm):
|
||||
|
||||
class ClusterImportForm(NetBoxModelImportForm):
|
||||
type = CSVModelChoiceField(
|
||||
label=_('Type'),
|
||||
queryset=ClusterType.objects.all(),
|
||||
to_field_name='name',
|
||||
help_text=_('Type of cluster')
|
||||
)
|
||||
group = CSVModelChoiceField(
|
||||
label=_('Group'),
|
||||
queryset=ClusterGroup.objects.all(),
|
||||
to_field_name='name',
|
||||
required=False,
|
||||
help_text=_('Assigned cluster group')
|
||||
)
|
||||
status = CSVChoiceField(
|
||||
label=_('Status'),
|
||||
choices=ClusterStatusChoices,
|
||||
help_text=_('Operational status')
|
||||
)
|
||||
site = CSVModelChoiceField(
|
||||
label=_('Site'),
|
||||
queryset=Site.objects.all(),
|
||||
to_field_name='name',
|
||||
required=False,
|
||||
help_text=_('Assigned site')
|
||||
)
|
||||
tenant = CSVModelChoiceField(
|
||||
label=_('Tenant'),
|
||||
queryset=Tenant.objects.all(),
|
||||
to_field_name='name',
|
||||
required=False,
|
||||
@ -70,28 +79,33 @@ class ClusterImportForm(NetBoxModelImportForm):
|
||||
|
||||
class VirtualMachineImportForm(NetBoxModelImportForm):
|
||||
status = CSVChoiceField(
|
||||
label=_('Status'),
|
||||
choices=VirtualMachineStatusChoices,
|
||||
help_text=_('Operational status')
|
||||
)
|
||||
site = CSVModelChoiceField(
|
||||
label=_('Site'),
|
||||
queryset=Site.objects.all(),
|
||||
to_field_name='name',
|
||||
required=False,
|
||||
help_text=_('Assigned site')
|
||||
)
|
||||
cluster = CSVModelChoiceField(
|
||||
label=_('Cluster'),
|
||||
queryset=Cluster.objects.all(),
|
||||
to_field_name='name',
|
||||
required=False,
|
||||
help_text=_('Assigned cluster')
|
||||
)
|
||||
device = CSVModelChoiceField(
|
||||
label=_('Device'),
|
||||
queryset=Device.objects.all(),
|
||||
to_field_name='name',
|
||||
required=False,
|
||||
help_text=_('Assigned device within cluster')
|
||||
)
|
||||
role = CSVModelChoiceField(
|
||||
label=_('Role'),
|
||||
queryset=DeviceRole.objects.filter(
|
||||
vm_role=True
|
||||
),
|
||||
@ -100,12 +114,14 @@ class VirtualMachineImportForm(NetBoxModelImportForm):
|
||||
help_text=_('Functional role')
|
||||
)
|
||||
tenant = CSVModelChoiceField(
|
||||
label=_('Tenant'),
|
||||
queryset=Tenant.objects.all(),
|
||||
required=False,
|
||||
to_field_name='name',
|
||||
help_text=_('Assigned tenant')
|
||||
)
|
||||
platform = CSVModelChoiceField(
|
||||
label=_('Platform'),
|
||||
queryset=Platform.objects.all(),
|
||||
required=False,
|
||||
to_field_name='name',
|
||||
@ -122,27 +138,32 @@ class VirtualMachineImportForm(NetBoxModelImportForm):
|
||||
|
||||
class VMInterfaceImportForm(NetBoxModelImportForm):
|
||||
virtual_machine = CSVModelChoiceField(
|
||||
label=_('Virtual machine'),
|
||||
queryset=VirtualMachine.objects.all(),
|
||||
to_field_name='name'
|
||||
)
|
||||
parent = CSVModelChoiceField(
|
||||
label=_('Parent'),
|
||||
queryset=VMInterface.objects.all(),
|
||||
required=False,
|
||||
to_field_name='name',
|
||||
help_text=_('Parent interface')
|
||||
)
|
||||
bridge = CSVModelChoiceField(
|
||||
label=_('Bridge'),
|
||||
queryset=VMInterface.objects.all(),
|
||||
required=False,
|
||||
to_field_name='name',
|
||||
help_text=_('Bridged interface')
|
||||
)
|
||||
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',
|
||||
|
@ -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 Device, DeviceRole, Platform, Region, Site, SiteGroup
|
||||
from extras.forms import LocalConfigContextFilterForm
|
||||
@ -30,7 +30,7 @@ class ClusterGroupFilterForm(ContactModelFilterForm, NetBoxModelFilterSetForm):
|
||||
tag = TagFilterField(model)
|
||||
fieldsets = (
|
||||
(None, ('q', 'filter_id', 'tag')),
|
||||
('Contacts', ('contact', 'contact_role', 'contact_group')),
|
||||
(_('Contacts'), ('contact', 'contact_role', 'contact_group')),
|
||||
)
|
||||
|
||||
|
||||
@ -38,10 +38,10 @@ class ClusterFilterForm(TenancyFilterForm, ContactModelFilterForm, NetBoxModelFi
|
||||
model = Cluster
|
||||
fieldsets = (
|
||||
(None, ('q', 'filter_id', 'tag')),
|
||||
('Attributes', ('group_id', 'type_id', 'status')),
|
||||
('Location', ('region_id', 'site_group_id', 'site_id')),
|
||||
('Tenant', ('tenant_group_id', 'tenant_id')),
|
||||
('Contacts', ('contact', 'contact_role', 'contact_group')),
|
||||
(_('Attributes'), ('group_id', 'type_id', 'status')),
|
||||
(_('Location'), ('region_id', 'site_group_id', 'site_id')),
|
||||
(_('Tenant'), ('tenant_group_id', 'tenant_id')),
|
||||
(_('Contacts'), ('contact', 'contact_role', 'contact_group')),
|
||||
)
|
||||
type_id = DynamicModelMultipleChoiceField(
|
||||
queryset=ClusterType.objects.all(),
|
||||
@ -54,6 +54,7 @@ class ClusterFilterForm(TenancyFilterForm, ContactModelFilterForm, NetBoxModelFi
|
||||
label=_('Region')
|
||||
)
|
||||
status = forms.MultipleChoiceField(
|
||||
label=_('Status'),
|
||||
choices=ClusterStatusChoices,
|
||||
required=False
|
||||
)
|
||||
@ -90,11 +91,11 @@ class VirtualMachineFilterForm(
|
||||
model = VirtualMachine
|
||||
fieldsets = (
|
||||
(None, ('q', 'filter_id', 'tag')),
|
||||
('Cluster', ('cluster_group_id', 'cluster_type_id', 'cluster_id', 'device_id')),
|
||||
('Location', ('region_id', 'site_group_id', 'site_id')),
|
||||
('Attributes', ('status', 'role_id', 'platform_id', 'mac_address', 'has_primary_ip', 'local_context_data')),
|
||||
('Tenant', ('tenant_group_id', 'tenant_id')),
|
||||
('Contacts', ('contact', 'contact_role', 'contact_group')),
|
||||
(_('Cluster'), ('cluster_group_id', 'cluster_type_id', 'cluster_id', 'device_id')),
|
||||
(_('Location'), ('region_id', 'site_group_id', 'site_id')),
|
||||
(_('Attributes'), ('status', 'role_id', 'platform_id', 'mac_address', 'has_primary_ip', 'local_context_data')),
|
||||
(_('Tenant'), ('tenant_group_id', 'tenant_id')),
|
||||
(_('Contacts'), ('contact', 'contact_role', 'contact_group')),
|
||||
)
|
||||
cluster_group_id = DynamicModelMultipleChoiceField(
|
||||
queryset=ClusterGroup.objects.all(),
|
||||
@ -148,6 +149,7 @@ class VirtualMachineFilterForm(
|
||||
label=_('Role')
|
||||
)
|
||||
status = forms.MultipleChoiceField(
|
||||
label=_('Status'),
|
||||
choices=VirtualMachineStatusChoices,
|
||||
required=False
|
||||
)
|
||||
@ -175,8 +177,8 @@ class VMInterfaceFilterForm(NetBoxModelFilterSetForm):
|
||||
model = VMInterface
|
||||
fieldsets = (
|
||||
(None, ('q', 'filter_id', 'tag')),
|
||||
('Virtual Machine', ('cluster_id', 'virtual_machine_id')),
|
||||
('Attributes', ('enabled', 'mac_address', 'vrf_id', 'l2vpn_id')),
|
||||
(_('Virtual Machine'), ('cluster_id', 'virtual_machine_id')),
|
||||
(_('Attributes'), ('enabled', 'mac_address', 'vrf_id', 'l2vpn_id')),
|
||||
)
|
||||
cluster_id = DynamicModelMultipleChoiceField(
|
||||
queryset=Cluster.objects.all(),
|
||||
@ -192,6 +194,7 @@ class VMInterfaceFilterForm(NetBoxModelFilterSetForm):
|
||||
label=_('Virtual machine')
|
||||
)
|
||||
enabled = forms.NullBooleanField(
|
||||
label=_('Enabled'),
|
||||
required=False,
|
||||
widget=forms.Select(
|
||||
choices=BOOLEAN_WITH_BLANK_CHOICES
|
||||
@ -199,12 +202,12 @@ class VMInterfaceFilterForm(NetBoxModelFilterSetForm):
|
||||
)
|
||||
mac_address = forms.CharField(
|
||||
required=False,
|
||||
label='MAC address'
|
||||
label=_('MAC address')
|
||||
)
|
||||
vrf_id = DynamicModelMultipleChoiceField(
|
||||
queryset=VRF.objects.all(),
|
||||
required=False,
|
||||
label='VRF'
|
||||
label=_('VRF')
|
||||
)
|
||||
l2vpn_id = DynamicModelMultipleChoiceField(
|
||||
queryset=L2VPN.objects.all(),
|
||||
|
@ -1,7 +1,7 @@
|
||||
from django import forms
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.utils.translation import gettext as _
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from dcim.forms.common import InterfaceCommonForm
|
||||
from dcim.models import Device, DeviceRole, Platform, Rack, Region, Site, SiteGroup
|
||||
@ -27,10 +27,12 @@ __all__ = (
|
||||
|
||||
|
||||
class ClusterTypeForm(NetBoxModelForm):
|
||||
slug = SlugField()
|
||||
slug = SlugField(
|
||||
label=_('Slug'),
|
||||
)
|
||||
|
||||
fieldsets = (
|
||||
('Cluster Type', (
|
||||
(_('Cluster Type'), (
|
||||
'name', 'slug', 'description', 'tags',
|
||||
)),
|
||||
)
|
||||
@ -43,10 +45,12 @@ class ClusterTypeForm(NetBoxModelForm):
|
||||
|
||||
|
||||
class ClusterGroupForm(NetBoxModelForm):
|
||||
slug = SlugField()
|
||||
slug = SlugField(
|
||||
label=_('Slug'),
|
||||
)
|
||||
|
||||
fieldsets = (
|
||||
('Cluster Group', (
|
||||
(_('Cluster Group'), (
|
||||
'name', 'slug', 'description', 'tags',
|
||||
)),
|
||||
)
|
||||
@ -60,22 +64,27 @@ class ClusterGroupForm(NetBoxModelForm):
|
||||
|
||||
class ClusterForm(TenancyForm, NetBoxModelForm):
|
||||
type = DynamicModelChoiceField(
|
||||
label=_('Type'),
|
||||
queryset=ClusterType.objects.all()
|
||||
)
|
||||
group = DynamicModelChoiceField(
|
||||
label=_('Group'),
|
||||
queryset=ClusterGroup.objects.all(),
|
||||
required=False
|
||||
)
|
||||
site = DynamicModelChoiceField(
|
||||
label=_('Site'),
|
||||
queryset=Site.objects.all(),
|
||||
required=False,
|
||||
selector=True
|
||||
)
|
||||
comments = CommentField()
|
||||
comments = CommentField(
|
||||
label=_('Comments'),
|
||||
)
|
||||
|
||||
fieldsets = (
|
||||
('Cluster', ('name', 'type', 'group', 'site', 'status', 'description', 'tags')),
|
||||
('Tenancy', ('tenant_group', 'tenant')),
|
||||
(_('Cluster'), ('name', 'type', 'group', 'site', 'status', 'description', 'tags')),
|
||||
(_('Tenancy'), ('tenant_group', 'tenant')),
|
||||
)
|
||||
|
||||
class Meta:
|
||||
@ -87,16 +96,19 @@ class ClusterForm(TenancyForm, NetBoxModelForm):
|
||||
|
||||
class ClusterAddDevicesForm(BootstrapMixin, forms.Form):
|
||||
region = DynamicModelChoiceField(
|
||||
label=_('Region'),
|
||||
queryset=Region.objects.all(),
|
||||
required=False,
|
||||
null_option='None'
|
||||
)
|
||||
site_group = DynamicModelChoiceField(
|
||||
label=_('Site group'),
|
||||
queryset=SiteGroup.objects.all(),
|
||||
required=False,
|
||||
null_option='None'
|
||||
)
|
||||
site = DynamicModelChoiceField(
|
||||
label=_('Site'),
|
||||
queryset=Site.objects.all(),
|
||||
required=False,
|
||||
query_params={
|
||||
@ -105,6 +117,7 @@ class ClusterAddDevicesForm(BootstrapMixin, forms.Form):
|
||||
}
|
||||
)
|
||||
rack = DynamicModelChoiceField(
|
||||
label=_('Rack'),
|
||||
queryset=Rack.objects.all(),
|
||||
required=False,
|
||||
null_option='None',
|
||||
@ -113,6 +126,7 @@ class ClusterAddDevicesForm(BootstrapMixin, forms.Form):
|
||||
}
|
||||
)
|
||||
devices = DynamicModelMultipleChoiceField(
|
||||
label=_('Devices'),
|
||||
queryset=Device.objects.all(),
|
||||
query_params={
|
||||
'site_id': '$site',
|
||||
@ -142,7 +156,7 @@ class ClusterAddDevicesForm(BootstrapMixin, forms.Form):
|
||||
for device in self.cleaned_data.get('devices', []):
|
||||
if device.site != self.cluster.site:
|
||||
raise ValidationError({
|
||||
'devices': "{} belongs to a different site ({}) than the cluster ({})".format(
|
||||
'devices': _("{} belongs to a different site ({}) than the cluster ({})").format(
|
||||
device, device.site, self.cluster.site
|
||||
)
|
||||
})
|
||||
@ -150,6 +164,7 @@ class ClusterAddDevicesForm(BootstrapMixin, forms.Form):
|
||||
|
||||
class ClusterRemoveDevicesForm(ConfirmationForm):
|
||||
pk = forms.ModelMultipleChoiceField(
|
||||
label=_('Pk'),
|
||||
queryset=Device.objects.all(),
|
||||
widget=forms.MultipleHiddenInput()
|
||||
)
|
||||
@ -157,10 +172,12 @@ class ClusterRemoveDevicesForm(ConfirmationForm):
|
||||
|
||||
class VirtualMachineForm(TenancyForm, NetBoxModelForm):
|
||||
site = DynamicModelChoiceField(
|
||||
label=_('Site'),
|
||||
queryset=Site.objects.all(),
|
||||
required=False
|
||||
)
|
||||
cluster = DynamicModelChoiceField(
|
||||
label=_('Cluster'),
|
||||
queryset=Cluster.objects.all(),
|
||||
required=False,
|
||||
selector=True,
|
||||
@ -169,6 +186,7 @@ class VirtualMachineForm(TenancyForm, NetBoxModelForm):
|
||||
}
|
||||
)
|
||||
device = DynamicModelChoiceField(
|
||||
label=_('Device'),
|
||||
queryset=Device.objects.all(),
|
||||
required=False,
|
||||
query_params={
|
||||
@ -178,6 +196,7 @@ class VirtualMachineForm(TenancyForm, NetBoxModelForm):
|
||||
help_text=_("Optionally pin this VM to a specific host device within the cluster")
|
||||
)
|
||||
role = DynamicModelChoiceField(
|
||||
label=_('Role'),
|
||||
queryset=DeviceRole.objects.all(),
|
||||
required=False,
|
||||
query_params={
|
||||
@ -185,6 +204,7 @@ class VirtualMachineForm(TenancyForm, NetBoxModelForm):
|
||||
}
|
||||
)
|
||||
platform = DynamicModelChoiceField(
|
||||
label=_('Platform'),
|
||||
queryset=Platform.objects.all(),
|
||||
required=False
|
||||
)
|
||||
@ -195,12 +215,12 @@ class VirtualMachineForm(TenancyForm, NetBoxModelForm):
|
||||
comments = CommentField()
|
||||
|
||||
fieldsets = (
|
||||
('Virtual Machine', ('name', 'role', 'status', 'description', 'tags')),
|
||||
('Site/Cluster', ('site', 'cluster', 'device')),
|
||||
('Tenancy', ('tenant_group', 'tenant')),
|
||||
('Management', ('platform', 'primary_ip4', 'primary_ip6')),
|
||||
('Resources', ('vcpus', 'memory', 'disk')),
|
||||
('Config Context', ('local_context_data',)),
|
||||
(_('Virtual Machine'), ('name', 'role', 'status', 'description', 'tags')),
|
||||
(_('Site/Cluster'), ('site', 'cluster', 'device')),
|
||||
(_('Tenancy'), ('tenant_group', 'tenant')),
|
||||
(_('Management'), ('platform', 'primary_ip4', 'primary_ip6')),
|
||||
(_('Resources'), ('vcpus', 'memory', 'disk')),
|
||||
(_('Config Context'), ('local_context_data',)),
|
||||
)
|
||||
|
||||
class Meta:
|
||||
@ -253,6 +273,7 @@ class VirtualMachineForm(TenancyForm, NetBoxModelForm):
|
||||
|
||||
class VMInterfaceForm(InterfaceCommonForm, NetBoxModelForm):
|
||||
virtual_machine = DynamicModelChoiceField(
|
||||
label=_('Virtual machine'),
|
||||
queryset=VirtualMachine.objects.all(),
|
||||
selector=True
|
||||
)
|
||||
@ -302,11 +323,11 @@ class VMInterfaceForm(InterfaceCommonForm, NetBoxModelForm):
|
||||
)
|
||||
|
||||
fieldsets = (
|
||||
('Interface', ('virtual_machine', 'name', 'description', 'tags')),
|
||||
('Addressing', ('vrf', 'mac_address')),
|
||||
('Operation', ('mtu', 'enabled')),
|
||||
('Related Interfaces', ('parent', 'bridge')),
|
||||
('802.1Q Switching', ('mode', 'vlan_group', 'untagged_vlan', 'tagged_vlans')),
|
||||
(_('Interface'), ('virtual_machine', 'name', 'description', 'tags')),
|
||||
(_('Addressing'), ('vrf', 'mac_address')),
|
||||
(_('Operation'), ('mtu', 'enabled')),
|
||||
(_('Related Interfaces'), ('parent', 'bridge')),
|
||||
(_('802.1Q Switching'), ('mode', 'vlan_group', 'untagged_vlan', 'tagged_vlans')),
|
||||
)
|
||||
|
||||
class Meta:
|
||||
|
@ -1,3 +1,4 @@
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from utilities.forms.fields import ExpandableNameField
|
||||
from .model_forms import VMInterfaceForm
|
||||
|
||||
@ -7,7 +8,9 @@ __all__ = (
|
||||
|
||||
|
||||
class VMInterfaceCreateForm(VMInterfaceForm):
|
||||
name = ExpandableNameField()
|
||||
name = ExpandableNameField(
|
||||
label=_('Name'),
|
||||
)
|
||||
replication_fields = ('name',)
|
||||
|
||||
class Meta(VMInterfaceForm.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.choices import LinkStatusChoices
|
||||
from ipam.models import VLAN
|
||||
@ -20,10 +20,12 @@ __all__ = (
|
||||
|
||||
class WirelessLANGroupBulkEditForm(NetBoxModelBulkEditForm):
|
||||
parent = DynamicModelChoiceField(
|
||||
label=_('Parent'),
|
||||
queryset=WirelessLANGroup.objects.all(),
|
||||
required=False
|
||||
)
|
||||
description = forms.CharField(
|
||||
label=_('Description'),
|
||||
max_length=200,
|
||||
required=False
|
||||
)
|
||||
@ -37,10 +39,12 @@ class WirelessLANGroupBulkEditForm(NetBoxModelBulkEditForm):
|
||||
|
||||
class WirelessLANBulkEditForm(NetBoxModelBulkEditForm):
|
||||
status = forms.ChoiceField(
|
||||
label=_('Status'),
|
||||
choices=add_blank_choice(WirelessLANStatusChoices),
|
||||
required=False
|
||||
)
|
||||
group = DynamicModelChoiceField(
|
||||
label=_('Group'),
|
||||
queryset=WirelessLANGroup.objects.all(),
|
||||
required=False
|
||||
)
|
||||
@ -55,14 +59,17 @@ class WirelessLANBulkEditForm(NetBoxModelBulkEditForm):
|
||||
label=_('SSID')
|
||||
)
|
||||
tenant = DynamicModelChoiceField(
|
||||
label=_('Tenant'),
|
||||
queryset=Tenant.objects.all(),
|
||||
required=False
|
||||
)
|
||||
auth_type = forms.ChoiceField(
|
||||
label=_('Auth type'),
|
||||
choices=add_blank_choice(WirelessAuthTypeChoices),
|
||||
required=False
|
||||
)
|
||||
auth_cipher = forms.ChoiceField(
|
||||
label=_('Auth cipher'),
|
||||
choices=add_blank_choice(WirelessAuthCipherChoices),
|
||||
required=False
|
||||
)
|
||||
@ -71,17 +78,18 @@ class WirelessLANBulkEditForm(NetBoxModelBulkEditForm):
|
||||
label=_('Pre-shared key')
|
||||
)
|
||||
description = forms.CharField(
|
||||
label=_('Description'),
|
||||
max_length=200,
|
||||
required=False
|
||||
)
|
||||
comments = CommentField(
|
||||
label='Comments'
|
||||
label=_('Comments')
|
||||
)
|
||||
|
||||
model = WirelessLAN
|
||||
fieldsets = (
|
||||
(None, ('group', 'ssid', 'status', 'vlan', 'tenant', 'description')),
|
||||
('Authentication', ('auth_type', 'auth_cipher', 'auth_psk')),
|
||||
(_('Authentication'), ('auth_type', 'auth_cipher', 'auth_psk')),
|
||||
)
|
||||
nullable_fields = (
|
||||
'ssid', 'group', 'vlan', 'tenant', 'description', 'auth_type', 'auth_cipher', 'auth_psk', 'comments',
|
||||
@ -95,18 +103,22 @@ class WirelessLinkBulkEditForm(NetBoxModelBulkEditForm):
|
||||
label=_('SSID')
|
||||
)
|
||||
status = forms.ChoiceField(
|
||||
label=_('Status'),
|
||||
choices=add_blank_choice(LinkStatusChoices),
|
||||
required=False
|
||||
)
|
||||
tenant = DynamicModelChoiceField(
|
||||
label=_('Tenant'),
|
||||
queryset=Tenant.objects.all(),
|
||||
required=False
|
||||
)
|
||||
auth_type = forms.ChoiceField(
|
||||
label=_('Auth type'),
|
||||
choices=add_blank_choice(WirelessAuthTypeChoices),
|
||||
required=False
|
||||
)
|
||||
auth_cipher = forms.ChoiceField(
|
||||
label=_('Auth cipher'),
|
||||
choices=add_blank_choice(WirelessAuthCipherChoices),
|
||||
required=False
|
||||
)
|
||||
@ -115,17 +127,18 @@ class WirelessLinkBulkEditForm(NetBoxModelBulkEditForm):
|
||||
label=_('Pre-shared key')
|
||||
)
|
||||
description = forms.CharField(
|
||||
label=_('Description'),
|
||||
max_length=200,
|
||||
required=False
|
||||
)
|
||||
comments = CommentField(
|
||||
label='Comments'
|
||||
label=_('Comments')
|
||||
)
|
||||
|
||||
model = WirelessLink
|
||||
fieldsets = (
|
||||
(None, ('ssid', 'status', 'tenant', 'description')),
|
||||
('Authentication', ('auth_type', 'auth_cipher', 'auth_psk'))
|
||||
(_('Authentication'), ('auth_type', 'auth_cipher', 'auth_psk'))
|
||||
)
|
||||
nullable_fields = (
|
||||
'ssid', 'tenant', 'description', 'auth_type', 'auth_cipher', 'auth_psk', 'comments',
|
||||
|
@ -1,4 +1,4 @@
|
||||
from django.utils.translation import gettext as _
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from dcim.choices import LinkStatusChoices
|
||||
from dcim.models import Interface
|
||||
@ -18,12 +18,15 @@ __all__ = (
|
||||
|
||||
class WirelessLANGroupImportForm(NetBoxModelImportForm):
|
||||
parent = CSVModelChoiceField(
|
||||
label=_('Parent'),
|
||||
queryset=WirelessLANGroup.objects.all(),
|
||||
required=False,
|
||||
to_field_name='name',
|
||||
help_text=_('Parent group')
|
||||
)
|
||||
slug = SlugField()
|
||||
slug = SlugField(
|
||||
label=_('Slug'),
|
||||
)
|
||||
|
||||
class Meta:
|
||||
model = WirelessLANGroup
|
||||
@ -32,33 +35,39 @@ class WirelessLANGroupImportForm(NetBoxModelImportForm):
|
||||
|
||||
class WirelessLANImportForm(NetBoxModelImportForm):
|
||||
group = CSVModelChoiceField(
|
||||
label=_('Group'),
|
||||
queryset=WirelessLANGroup.objects.all(),
|
||||
required=False,
|
||||
to_field_name='name',
|
||||
help_text=_('Assigned group')
|
||||
)
|
||||
status = CSVChoiceField(
|
||||
label=_('Status'),
|
||||
choices=WirelessLANStatusChoices,
|
||||
help_text='Operational status'
|
||||
)
|
||||
vlan = CSVModelChoiceField(
|
||||
label=_('VLAN'),
|
||||
queryset=VLAN.objects.all(),
|
||||
required=False,
|
||||
to_field_name='name',
|
||||
help_text=_('Bridged VLAN')
|
||||
)
|
||||
tenant = CSVModelChoiceField(
|
||||
label=_('Tenant'),
|
||||
queryset=Tenant.objects.all(),
|
||||
required=False,
|
||||
to_field_name='name',
|
||||
help_text=_('Assigned tenant')
|
||||
)
|
||||
auth_type = CSVChoiceField(
|
||||
label=_('Auth type'),
|
||||
choices=WirelessAuthTypeChoices,
|
||||
required=False,
|
||||
help_text=_('Authentication type')
|
||||
)
|
||||
auth_cipher = CSVChoiceField(
|
||||
label=_('Auth cipher'),
|
||||
choices=WirelessAuthCipherChoices,
|
||||
required=False,
|
||||
help_text=_('Authentication cipher')
|
||||
@ -74,27 +83,33 @@ class WirelessLANImportForm(NetBoxModelImportForm):
|
||||
|
||||
class WirelessLinkImportForm(NetBoxModelImportForm):
|
||||
status = CSVChoiceField(
|
||||
label=_('Status'),
|
||||
choices=LinkStatusChoices,
|
||||
help_text=_('Connection status')
|
||||
)
|
||||
interface_a = CSVModelChoiceField(
|
||||
label=_('Interface a'),
|
||||
queryset=Interface.objects.all()
|
||||
)
|
||||
interface_b = CSVModelChoiceField(
|
||||
label=_('Interface b'),
|
||||
queryset=Interface.objects.all()
|
||||
)
|
||||
tenant = CSVModelChoiceField(
|
||||
label=_('Tenant'),
|
||||
queryset=Tenant.objects.all(),
|
||||
required=False,
|
||||
to_field_name='name',
|
||||
help_text=_('Assigned tenant')
|
||||
)
|
||||
auth_type = CSVChoiceField(
|
||||
label=_('Auth type'),
|
||||
choices=WirelessAuthTypeChoices,
|
||||
required=False,
|
||||
help_text=_('Authentication type')
|
||||
)
|
||||
auth_cipher = CSVChoiceField(
|
||||
label=_('Auth cipher'),
|
||||
choices=WirelessAuthCipherChoices,
|
||||
required=False,
|
||||
help_text=_('Authentication cipher')
|
||||
|
@ -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 LinkStatusChoices
|
||||
from netbox.forms import NetBoxModelFilterSetForm
|
||||
@ -30,9 +30,9 @@ class WirelessLANFilterForm(TenancyFilterForm, NetBoxModelFilterSetForm):
|
||||
model = WirelessLAN
|
||||
fieldsets = (
|
||||
(None, ('q', 'filter_id', 'tag')),
|
||||
('Attributes', ('ssid', 'group_id', 'status')),
|
||||
('Tenant', ('tenant_group_id', 'tenant_id')),
|
||||
('Authentication', ('auth_type', 'auth_cipher', 'auth_psk')),
|
||||
(_('Attributes'), ('ssid', 'group_id', 'status')),
|
||||
(_('Tenant'), ('tenant_group_id', 'tenant_id')),
|
||||
(_('Authentication'), ('auth_type', 'auth_cipher', 'auth_psk')),
|
||||
)
|
||||
ssid = forms.CharField(
|
||||
required=False,
|
||||
@ -45,18 +45,22 @@ class WirelessLANFilterForm(TenancyFilterForm, NetBoxModelFilterSetForm):
|
||||
label=_('Group')
|
||||
)
|
||||
status = forms.ChoiceField(
|
||||
label=_('Status'),
|
||||
required=False,
|
||||
choices=add_blank_choice(WirelessLANStatusChoices)
|
||||
)
|
||||
auth_type = forms.ChoiceField(
|
||||
label=_('Auth type'),
|
||||
required=False,
|
||||
choices=add_blank_choice(WirelessAuthTypeChoices)
|
||||
)
|
||||
auth_cipher = forms.ChoiceField(
|
||||
label=_('Auth cipher'),
|
||||
required=False,
|
||||
choices=add_blank_choice(WirelessAuthCipherChoices)
|
||||
)
|
||||
auth_psk = forms.CharField(
|
||||
label=_('Auth psk'),
|
||||
required=False
|
||||
)
|
||||
tag = TagFilterField(model)
|
||||
@ -66,27 +70,31 @@ class WirelessLinkFilterForm(TenancyFilterForm, NetBoxModelFilterSetForm):
|
||||
model = WirelessLink
|
||||
fieldsets = (
|
||||
(None, ('q', 'filter_id', 'tag')),
|
||||
('Attributes', ('ssid', 'status',)),
|
||||
('Tenant', ('tenant_group_id', 'tenant_id')),
|
||||
('Authentication', ('auth_type', 'auth_cipher', 'auth_psk')),
|
||||
(_('Attributes'), ('ssid', 'status',)),
|
||||
(_('Tenant'), ('tenant_group_id', 'tenant_id')),
|
||||
(_('Authentication'), ('auth_type', 'auth_cipher', 'auth_psk')),
|
||||
)
|
||||
ssid = forms.CharField(
|
||||
required=False,
|
||||
label=_('SSID')
|
||||
)
|
||||
status = forms.ChoiceField(
|
||||
label=_('Status'),
|
||||
required=False,
|
||||
choices=add_blank_choice(LinkStatusChoices)
|
||||
)
|
||||
auth_type = forms.ChoiceField(
|
||||
label=_('Auth type'),
|
||||
required=False,
|
||||
choices=add_blank_choice(WirelessAuthTypeChoices)
|
||||
)
|
||||
auth_cipher = forms.ChoiceField(
|
||||
label=_('Auth cipher'),
|
||||
required=False,
|
||||
choices=add_blank_choice(WirelessAuthCipherChoices)
|
||||
)
|
||||
auth_psk = forms.CharField(
|
||||
label=_('Auth psk'),
|
||||
required=False
|
||||
)
|
||||
tag = TagFilterField(model)
|
||||
|
@ -1,5 +1,5 @@
|
||||
from django.forms import PasswordInput
|
||||
from django.utils.translation import gettext as _
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from dcim.models import Device, Interface, Location, Site
|
||||
from ipam.models import VLAN
|
||||
@ -17,13 +17,16 @@ __all__ = (
|
||||
|
||||
class WirelessLANGroupForm(NetBoxModelForm):
|
||||
parent = DynamicModelChoiceField(
|
||||
label=_('Parent'),
|
||||
queryset=WirelessLANGroup.objects.all(),
|
||||
required=False
|
||||
)
|
||||
slug = SlugField()
|
||||
slug = SlugField(
|
||||
label=_('Slug'),
|
||||
)
|
||||
|
||||
fieldsets = (
|
||||
('Wireless LAN Group', (
|
||||
(_('Wireless LAN Group'), (
|
||||
'parent', 'name', 'slug', 'description', 'tags',
|
||||
)),
|
||||
)
|
||||
@ -37,6 +40,7 @@ class WirelessLANGroupForm(NetBoxModelForm):
|
||||
|
||||
class WirelessLANForm(TenancyForm, NetBoxModelForm):
|
||||
group = DynamicModelChoiceField(
|
||||
label=_('Group'),
|
||||
queryset=WirelessLANGroup.objects.all(),
|
||||
required=False
|
||||
)
|
||||
@ -46,12 +50,14 @@ class WirelessLANForm(TenancyForm, NetBoxModelForm):
|
||||
selector=True,
|
||||
label=_('VLAN')
|
||||
)
|
||||
comments = CommentField()
|
||||
comments = CommentField(
|
||||
label=_('Comments'),
|
||||
)
|
||||
|
||||
fieldsets = (
|
||||
('Wireless LAN', ('ssid', 'group', 'vlan', 'status', 'description', 'tags')),
|
||||
('Tenancy', ('tenant_group', 'tenant')),
|
||||
('Authentication', ('auth_type', 'auth_cipher', 'auth_psk')),
|
||||
(_('Wireless LAN'), ('ssid', 'group', 'vlan', 'status', 'description', 'tags')),
|
||||
(_('Tenancy'), ('tenant_group', 'tenant')),
|
||||
(_('Authentication'), ('auth_type', 'auth_cipher', 'auth_psk')),
|
||||
)
|
||||
|
||||
class Meta:
|
||||
@ -152,11 +158,11 @@ class WirelessLinkForm(TenancyForm, NetBoxModelForm):
|
||||
comments = CommentField()
|
||||
|
||||
fieldsets = (
|
||||
('Side A', ('site_a', 'location_a', 'device_a', 'interface_a')),
|
||||
('Side B', ('site_b', 'location_b', 'device_b', 'interface_b')),
|
||||
('Link', ('status', 'ssid', 'description', 'tags')),
|
||||
('Tenancy', ('tenant_group', 'tenant')),
|
||||
('Authentication', ('auth_type', 'auth_cipher', 'auth_psk')),
|
||||
(_('Side A'), ('site_a', 'location_a', 'device_a', 'interface_a')),
|
||||
(_('Side B'), ('site_b', 'location_b', 'device_b', 'interface_b')),
|
||||
(_('Link'), ('status', 'ssid', 'description', 'tags')),
|
||||
(_('Tenancy'), ('tenant_group', 'tenant')),
|
||||
(_('Authentication'), ('auth_type', 'auth_cipher', 'auth_psk')),
|
||||
)
|
||||
|
||||
class Meta:
|
||||
|
Loading…
Reference in New Issue
Block a user