mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-17 04:32:51 -06:00
Enable bulk editing of device component labels
This commit is contained in:
parent
88e3ac30b6
commit
89ea34015d
@ -23,10 +23,9 @@ from tenancy.forms import TenancyFilterForm, TenancyForm
|
|||||||
from tenancy.models import Tenant, TenantGroup
|
from tenancy.models import Tenant, TenantGroup
|
||||||
from utilities.forms import (
|
from utilities.forms import (
|
||||||
APISelect, APISelectMultiple, add_blank_choice, BootstrapMixin, BulkEditForm, BulkEditNullBooleanSelect,
|
APISelect, APISelectMultiple, add_blank_choice, BootstrapMixin, BulkEditForm, BulkEditNullBooleanSelect,
|
||||||
ColorSelect, CommentField, ConfirmationForm, CSVChoiceField, CSVModelChoiceField, CSVModelForm,
|
ColorSelect, CommentField, CSVChoiceField, CSVModelChoiceField, CSVModelForm, DynamicModelChoiceField,
|
||||||
DynamicModelChoiceField, DynamicModelMultipleChoiceField, ExpandableNameField, form_from_model, JSONField,
|
DynamicModelMultipleChoiceField, ExpandableNameField, form_from_model, JSONField, NumericArrayField, SelectWithPK,
|
||||||
NumericArrayField, SelectWithPK, SmallTextarea, SlugField, StaticSelect2, StaticSelect2Multiple, TagFilterField,
|
SmallTextarea, SlugField, StaticSelect2, StaticSelect2Multiple, TagFilterField, BOOLEAN_WITH_BLANK_CHOICES,
|
||||||
BOOLEAN_WITH_BLANK_CHOICES,
|
|
||||||
)
|
)
|
||||||
from virtualization.models import Cluster, ClusterGroup
|
from virtualization.models import Cluster, ClusterGroup
|
||||||
from .choices import *
|
from .choices import *
|
||||||
@ -1082,6 +1081,10 @@ class ConsolePortTemplateBulkEditForm(BootstrapMixin, BulkEditForm):
|
|||||||
queryset=ConsolePortTemplate.objects.all(),
|
queryset=ConsolePortTemplate.objects.all(),
|
||||||
widget=forms.MultipleHiddenInput()
|
widget=forms.MultipleHiddenInput()
|
||||||
)
|
)
|
||||||
|
label = forms.CharField(
|
||||||
|
max_length=64,
|
||||||
|
required=False
|
||||||
|
)
|
||||||
type = forms.ChoiceField(
|
type = forms.ChoiceField(
|
||||||
choices=add_blank_choice(ConsolePortTypeChoices),
|
choices=add_blank_choice(ConsolePortTypeChoices),
|
||||||
required=False,
|
required=False,
|
||||||
@ -1089,7 +1092,7 @@ class ConsolePortTemplateBulkEditForm(BootstrapMixin, BulkEditForm):
|
|||||||
)
|
)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
nullable_fields = ('type', 'description')
|
nullable_fields = ('label', 'type', 'description')
|
||||||
|
|
||||||
|
|
||||||
class ConsoleServerPortTemplateForm(BootstrapMixin, forms.ModelForm):
|
class ConsoleServerPortTemplateForm(BootstrapMixin, forms.ModelForm):
|
||||||
@ -1116,6 +1119,10 @@ class ConsoleServerPortTemplateBulkEditForm(BootstrapMixin, BulkEditForm):
|
|||||||
queryset=ConsoleServerPortTemplate.objects.all(),
|
queryset=ConsoleServerPortTemplate.objects.all(),
|
||||||
widget=forms.MultipleHiddenInput()
|
widget=forms.MultipleHiddenInput()
|
||||||
)
|
)
|
||||||
|
label = forms.CharField(
|
||||||
|
max_length=64,
|
||||||
|
required=False
|
||||||
|
)
|
||||||
type = forms.ChoiceField(
|
type = forms.ChoiceField(
|
||||||
choices=add_blank_choice(ConsolePortTypeChoices),
|
choices=add_blank_choice(ConsolePortTypeChoices),
|
||||||
required=False,
|
required=False,
|
||||||
@ -1126,7 +1133,7 @@ class ConsoleServerPortTemplateBulkEditForm(BootstrapMixin, BulkEditForm):
|
|||||||
)
|
)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
nullable_fields = ('type', 'description')
|
nullable_fields = ('label', 'type', 'description')
|
||||||
|
|
||||||
|
|
||||||
class PowerPortTemplateForm(BootstrapMixin, forms.ModelForm):
|
class PowerPortTemplateForm(BootstrapMixin, forms.ModelForm):
|
||||||
@ -1163,6 +1170,10 @@ class PowerPortTemplateBulkEditForm(BootstrapMixin, BulkEditForm):
|
|||||||
queryset=PowerPortTemplate.objects.all(),
|
queryset=PowerPortTemplate.objects.all(),
|
||||||
widget=forms.MultipleHiddenInput()
|
widget=forms.MultipleHiddenInput()
|
||||||
)
|
)
|
||||||
|
label = forms.CharField(
|
||||||
|
max_length=64,
|
||||||
|
required=False
|
||||||
|
)
|
||||||
type = forms.ChoiceField(
|
type = forms.ChoiceField(
|
||||||
choices=add_blank_choice(PowerPortTypeChoices),
|
choices=add_blank_choice(PowerPortTypeChoices),
|
||||||
required=False,
|
required=False,
|
||||||
@ -1183,7 +1194,7 @@ class PowerPortTemplateBulkEditForm(BootstrapMixin, BulkEditForm):
|
|||||||
)
|
)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
nullable_fields = ('type', 'maximum_draw', 'allocated_draw', 'description')
|
nullable_fields = ('label', 'type', 'maximum_draw', 'allocated_draw', 'description')
|
||||||
|
|
||||||
|
|
||||||
class PowerOutletTemplateForm(BootstrapMixin, forms.ModelForm):
|
class PowerOutletTemplateForm(BootstrapMixin, forms.ModelForm):
|
||||||
@ -1246,6 +1257,10 @@ class PowerOutletTemplateBulkEditForm(BootstrapMixin, BulkEditForm):
|
|||||||
disabled=True,
|
disabled=True,
|
||||||
widget=forms.HiddenInput()
|
widget=forms.HiddenInput()
|
||||||
)
|
)
|
||||||
|
label = forms.CharField(
|
||||||
|
max_length=64,
|
||||||
|
required=False
|
||||||
|
)
|
||||||
type = forms.ChoiceField(
|
type = forms.ChoiceField(
|
||||||
choices=add_blank_choice(PowerOutletTypeChoices),
|
choices=add_blank_choice(PowerOutletTypeChoices),
|
||||||
required=False,
|
required=False,
|
||||||
@ -1265,7 +1280,7 @@ class PowerOutletTemplateBulkEditForm(BootstrapMixin, BulkEditForm):
|
|||||||
)
|
)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
nullable_fields = ('type', 'power_port', 'feed_leg', 'description')
|
nullable_fields = ('label', 'type', 'power_port', 'feed_leg', 'description')
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
@ -1308,6 +1323,10 @@ class InterfaceTemplateBulkEditForm(BootstrapMixin, BulkEditForm):
|
|||||||
queryset=InterfaceTemplate.objects.all(),
|
queryset=InterfaceTemplate.objects.all(),
|
||||||
widget=forms.MultipleHiddenInput()
|
widget=forms.MultipleHiddenInput()
|
||||||
)
|
)
|
||||||
|
label = forms.CharField(
|
||||||
|
max_length=64,
|
||||||
|
required=False
|
||||||
|
)
|
||||||
type = forms.ChoiceField(
|
type = forms.ChoiceField(
|
||||||
choices=add_blank_choice(InterfaceTypeChoices),
|
choices=add_blank_choice(InterfaceTypeChoices),
|
||||||
required=False,
|
required=False,
|
||||||
@ -1323,7 +1342,7 @@ class InterfaceTemplateBulkEditForm(BootstrapMixin, BulkEditForm):
|
|||||||
)
|
)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
nullable_fields = ('description',)
|
nullable_fields = ('label', 'description')
|
||||||
|
|
||||||
|
|
||||||
class FrontPortTemplateForm(BootstrapMixin, forms.ModelForm):
|
class FrontPortTemplateForm(BootstrapMixin, forms.ModelForm):
|
||||||
@ -1491,12 +1510,16 @@ class DeviceBayTemplateBulkEditForm(BootstrapMixin, BulkEditForm):
|
|||||||
queryset=DeviceBayTemplate.objects.all(),
|
queryset=DeviceBayTemplate.objects.all(),
|
||||||
widget=forms.MultipleHiddenInput()
|
widget=forms.MultipleHiddenInput()
|
||||||
)
|
)
|
||||||
|
label = forms.CharField(
|
||||||
|
max_length=64,
|
||||||
|
required=False
|
||||||
|
)
|
||||||
description = forms.CharField(
|
description = forms.CharField(
|
||||||
required=False
|
required=False
|
||||||
)
|
)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
nullable_fields = ('description',)
|
nullable_fields = ('label', 'description')
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -2295,14 +2318,14 @@ class ConsolePortCreateForm(ComponentCreateForm):
|
|||||||
|
|
||||||
|
|
||||||
class ConsolePortBulkCreateForm(
|
class ConsolePortBulkCreateForm(
|
||||||
form_from_model(ConsolePort, ['type', 'description', 'tags']),
|
form_from_model(ConsolePort, ['label', 'type', 'description', 'tags']),
|
||||||
DeviceBulkAddComponentForm
|
DeviceBulkAddComponentForm
|
||||||
):
|
):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class ConsolePortBulkEditForm(
|
class ConsolePortBulkEditForm(
|
||||||
form_from_model(ConsolePort, ['type', 'description']),
|
form_from_model(ConsolePort, ['label', 'type', 'description']),
|
||||||
BootstrapMixin,
|
BootstrapMixin,
|
||||||
AddRemoveTagsForm,
|
AddRemoveTagsForm,
|
||||||
BulkEditForm
|
BulkEditForm
|
||||||
@ -2313,9 +2336,7 @@ class ConsolePortBulkEditForm(
|
|||||||
)
|
)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
nullable_fields = (
|
nullable_fields = ('label', 'description')
|
||||||
'description',
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class ConsolePortCSVForm(CSVModelForm):
|
class ConsolePortCSVForm(CSVModelForm):
|
||||||
@ -2377,14 +2398,14 @@ class ConsoleServerPortCreateForm(ComponentCreateForm):
|
|||||||
|
|
||||||
|
|
||||||
class ConsoleServerPortBulkCreateForm(
|
class ConsoleServerPortBulkCreateForm(
|
||||||
form_from_model(ConsoleServerPort, ['type', 'description', 'tags']),
|
form_from_model(ConsoleServerPort, ['label', 'type', 'description', 'tags']),
|
||||||
DeviceBulkAddComponentForm
|
DeviceBulkAddComponentForm
|
||||||
):
|
):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class ConsoleServerPortBulkEditForm(
|
class ConsoleServerPortBulkEditForm(
|
||||||
form_from_model(ConsoleServerPort, ['type', 'description']),
|
form_from_model(ConsoleServerPort, ['label', 'type', 'description']),
|
||||||
BootstrapMixin,
|
BootstrapMixin,
|
||||||
AddRemoveTagsForm,
|
AddRemoveTagsForm,
|
||||||
BulkEditForm
|
BulkEditForm
|
||||||
@ -2395,9 +2416,7 @@ class ConsoleServerPortBulkEditForm(
|
|||||||
)
|
)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
nullable_fields = [
|
nullable_fields = ('label', 'description')
|
||||||
'description',
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
class ConsoleServerPortCSVForm(CSVModelForm):
|
class ConsoleServerPortCSVForm(CSVModelForm):
|
||||||
@ -2469,14 +2488,14 @@ class PowerPortCreateForm(ComponentCreateForm):
|
|||||||
|
|
||||||
|
|
||||||
class PowerPortBulkCreateForm(
|
class PowerPortBulkCreateForm(
|
||||||
form_from_model(PowerPort, ['type', 'maximum_draw', 'allocated_draw', 'description', 'tags']),
|
form_from_model(PowerPort, ['label', 'type', 'maximum_draw', 'allocated_draw', 'description', 'tags']),
|
||||||
DeviceBulkAddComponentForm
|
DeviceBulkAddComponentForm
|
||||||
):
|
):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class PowerPortBulkEditForm(
|
class PowerPortBulkEditForm(
|
||||||
form_from_model(PowerPort, ['type', 'maximum_draw', 'allocated_draw', 'description']),
|
form_from_model(PowerPort, ['label', 'type', 'maximum_draw', 'allocated_draw', 'description']),
|
||||||
BootstrapMixin,
|
BootstrapMixin,
|
||||||
AddRemoveTagsForm,
|
AddRemoveTagsForm,
|
||||||
BulkEditForm
|
BulkEditForm
|
||||||
@ -2487,9 +2506,7 @@ class PowerPortBulkEditForm(
|
|||||||
)
|
)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
nullable_fields = (
|
nullable_fields = ('label', 'description')
|
||||||
'description',
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class PowerPortCSVForm(CSVModelForm):
|
class PowerPortCSVForm(CSVModelForm):
|
||||||
@ -2581,14 +2598,14 @@ class PowerOutletCreateForm(ComponentCreateForm):
|
|||||||
|
|
||||||
|
|
||||||
class PowerOutletBulkCreateForm(
|
class PowerOutletBulkCreateForm(
|
||||||
form_from_model(PowerOutlet, ['type', 'feed_leg', 'description', 'tags']),
|
form_from_model(PowerOutlet, ['label', 'type', 'feed_leg', 'description', 'tags']),
|
||||||
DeviceBulkAddComponentForm
|
DeviceBulkAddComponentForm
|
||||||
):
|
):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class PowerOutletBulkEditForm(
|
class PowerOutletBulkEditForm(
|
||||||
form_from_model(PowerOutlet, ['type', 'feed_leg', 'power_port', 'description']),
|
form_from_model(PowerOutlet, ['label', 'type', 'feed_leg', 'power_port', 'description']),
|
||||||
BootstrapMixin,
|
BootstrapMixin,
|
||||||
AddRemoveTagsForm,
|
AddRemoveTagsForm,
|
||||||
BulkEditForm
|
BulkEditForm
|
||||||
@ -2605,9 +2622,7 @@ class PowerOutletBulkEditForm(
|
|||||||
)
|
)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
nullable_fields = [
|
nullable_fields = ('label', 'type', 'feed_leg', 'power_port', 'description')
|
||||||
'type', 'feed_leg', 'power_port', 'description',
|
|
||||||
]
|
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
@ -2838,14 +2853,16 @@ class InterfaceCreateForm(ComponentCreateForm, InterfaceCommonForm):
|
|||||||
|
|
||||||
|
|
||||||
class InterfaceBulkCreateForm(
|
class InterfaceBulkCreateForm(
|
||||||
form_from_model(Interface, ['type', 'enabled', 'mtu', 'mgmt_only', 'description']),
|
form_from_model(Interface, ['label', 'type', 'enabled', 'mtu', 'mgmt_only', 'description']),
|
||||||
DeviceBulkAddComponentForm
|
DeviceBulkAddComponentForm
|
||||||
):
|
):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class InterfaceBulkEditForm(
|
class InterfaceBulkEditForm(
|
||||||
form_from_model(Interface, ['type', 'enabled', 'lag', 'mac_address', 'mtu', 'mgmt_only', 'description', 'mode']),
|
form_from_model(Interface, [
|
||||||
|
'label', 'type', 'enabled', 'lag', 'mac_address', 'mtu', 'mgmt_only', 'description', 'mode'
|
||||||
|
]),
|
||||||
BootstrapMixin,
|
BootstrapMixin,
|
||||||
AddRemoveTagsForm,
|
AddRemoveTagsForm,
|
||||||
BulkEditForm
|
BulkEditForm
|
||||||
@ -2884,9 +2901,9 @@ class InterfaceBulkEditForm(
|
|||||||
)
|
)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
nullable_fields = [
|
nullable_fields = (
|
||||||
'lag', 'mac_address', 'mtu', 'description', 'mode', 'untagged_vlan', 'tagged_vlans'
|
'label', 'lag', 'mac_address', 'mtu', 'description', 'mode', 'untagged_vlan', 'tagged_vlans'
|
||||||
]
|
)
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
@ -3283,7 +3300,7 @@ class PopulateDeviceBayForm(BootstrapMixin, forms.Form):
|
|||||||
|
|
||||||
|
|
||||||
class DeviceBayBulkCreateForm(
|
class DeviceBayBulkCreateForm(
|
||||||
form_from_model(DeviceBay, ['description', 'tags']),
|
form_from_model(DeviceBay, ['label', 'description', 'tags']),
|
||||||
DeviceBulkAddComponentForm
|
DeviceBulkAddComponentForm
|
||||||
):
|
):
|
||||||
tags = DynamicModelMultipleChoiceField(
|
tags = DynamicModelMultipleChoiceField(
|
||||||
@ -3293,7 +3310,7 @@ class DeviceBayBulkCreateForm(
|
|||||||
|
|
||||||
|
|
||||||
class DeviceBayBulkEditForm(
|
class DeviceBayBulkEditForm(
|
||||||
form_from_model(DeviceBay, ['description']),
|
form_from_model(DeviceBay, ['label', 'description']),
|
||||||
BootstrapMixin,
|
BootstrapMixin,
|
||||||
AddRemoveTagsForm,
|
AddRemoveTagsForm,
|
||||||
BulkEditForm
|
BulkEditForm
|
||||||
@ -3304,9 +3321,7 @@ class DeviceBayBulkEditForm(
|
|||||||
)
|
)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
nullable_fields = (
|
nullable_fields = ('label', 'description')
|
||||||
'description',
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class DeviceBayCSVForm(CSVModelForm):
|
class DeviceBayCSVForm(CSVModelForm):
|
||||||
|
Loading…
Reference in New Issue
Block a user