mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Added bulk edit/delete views for cables
This commit is contained in:
@@ -1879,6 +1879,54 @@ class CableCSVForm(forms.ModelForm):
|
||||
return termination_object
|
||||
|
||||
|
||||
class CableBulkEditForm(BootstrapMixin, BulkEditForm):
|
||||
pk = forms.ModelMultipleChoiceField(
|
||||
queryset=Cable.objects.all(),
|
||||
widget=forms.MultipleHiddenInput
|
||||
)
|
||||
type = forms.ChoiceField(
|
||||
choices=add_blank_choice(CABLE_TYPE_CHOICES),
|
||||
required=False,
|
||||
initial=''
|
||||
)
|
||||
status = forms.ChoiceField(
|
||||
choices=add_blank_choice(CONNECTION_STATUS_CHOICES),
|
||||
required=False,
|
||||
initial=''
|
||||
)
|
||||
label = forms.CharField(
|
||||
max_length=100,
|
||||
required=False
|
||||
)
|
||||
color = forms.CharField(
|
||||
max_length=6,
|
||||
required=False,
|
||||
widget=ColorSelect()
|
||||
)
|
||||
length = forms.IntegerField(
|
||||
min_value=1,
|
||||
required=False
|
||||
)
|
||||
length_unit = forms.ChoiceField(
|
||||
choices=add_blank_choice(LENGTH_UNIT_CHOICES),
|
||||
required=False,
|
||||
initial=''
|
||||
)
|
||||
|
||||
class Meta:
|
||||
nullable_fields = ['type', 'status', 'label', 'color', 'length']
|
||||
|
||||
def clean(self):
|
||||
|
||||
# Validate length/unit
|
||||
length = self.cleaned_data.get('length')
|
||||
length_unit = self.cleaned_data.get('length_unit')
|
||||
if length and not length_unit:
|
||||
raise forms.ValidationError({
|
||||
'length_unit': "Must specify a unit when setting length"
|
||||
})
|
||||
|
||||
|
||||
class CableFilterForm(BootstrapMixin, forms.Form):
|
||||
model = Cable
|
||||
q = forms.CharField(required=False, label='Search')
|
||||
|
||||
Reference in New Issue
Block a user