mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-16 12:12:53 -06:00
Fixed platform selection during bulk editing of devices
This commit is contained in:
parent
76efea87ff
commit
1f9e4dc707
@ -533,13 +533,22 @@ class ChildDeviceImportForm(BulkImportForm, BootstrapMixin):
|
|||||||
csv = CSVDataField(csv_form=ChildDeviceFromCSVForm)
|
csv = CSVDataField(csv_form=ChildDeviceFromCSVForm)
|
||||||
|
|
||||||
|
|
||||||
|
def device_edit_platform_choices():
|
||||||
|
choices = [
|
||||||
|
(None, '---------'),
|
||||||
|
(0, 'None'),
|
||||||
|
]
|
||||||
|
choices += [(p.pk, p.name) for p in Platform.objects.all()]
|
||||||
|
return choices
|
||||||
|
|
||||||
|
|
||||||
class DeviceBulkEditForm(forms.Form, BootstrapMixin):
|
class DeviceBulkEditForm(forms.Form, BootstrapMixin):
|
||||||
pk = forms.ModelMultipleChoiceField(queryset=Device.objects.all(), widget=forms.MultipleHiddenInput)
|
pk = forms.ModelMultipleChoiceField(queryset=Device.objects.all(), widget=forms.MultipleHiddenInput)
|
||||||
device_type = forms.ModelChoiceField(queryset=DeviceType.objects.all(), required=False, label='Type')
|
device_type = forms.ModelChoiceField(queryset=DeviceType.objects.all(), required=False, label='Type')
|
||||||
device_role = forms.ModelChoiceField(queryset=DeviceRole.objects.all(), required=False, label='Role')
|
device_role = forms.ModelChoiceField(queryset=DeviceRole.objects.all(), required=False, label='Role')
|
||||||
tenant = forms.ModelChoiceField(queryset=Tenant.objects.all(), required=False, label='Tenant')
|
tenant = forms.ModelChoiceField(queryset=Tenant.objects.all(), required=False, label='Tenant')
|
||||||
platform = forms.ModelChoiceField(queryset=Platform.objects.all(), required=False, label='Platform')
|
platform = forms.TypedChoiceField(choices=device_edit_platform_choices, coerce=int, required=False,
|
||||||
platform_delete = forms.BooleanField(required=False, label='Set platform to "none"')
|
label='Platform')
|
||||||
status = forms.ChoiceField(choices=FORM_STATUS_CHOICES, required=False, initial='', label='Status')
|
status = forms.ChoiceField(choices=FORM_STATUS_CHOICES, required=False, initial='', label='Status')
|
||||||
serial = forms.CharField(max_length=50, required=False, label='Serial Number')
|
serial = forms.CharField(max_length=50, required=False, label='Serial Number')
|
||||||
|
|
||||||
|
@ -626,10 +626,10 @@ class DeviceBulkEditView(PermissionRequiredMixin, BulkEditView):
|
|||||||
def update_objects(self, pk_list, form):
|
def update_objects(self, pk_list, form):
|
||||||
|
|
||||||
fields_to_update = {}
|
fields_to_update = {}
|
||||||
if form.cleaned_data['platform']:
|
if form.cleaned_data['platform'] == 0:
|
||||||
fields_to_update['platform'] = form.cleaned_data['platform']
|
|
||||||
elif form.cleaned_data['platform_delete']:
|
|
||||||
fields_to_update['platform'] = None
|
fields_to_update['platform'] = None
|
||||||
|
elif form.cleaned_data['platform']:
|
||||||
|
fields_to_update['platform'] = form.cleaned_data['platform']
|
||||||
if form.cleaned_data['status']:
|
if form.cleaned_data['status']:
|
||||||
status = form.cleaned_data['status']
|
status = form.cleaned_data['status']
|
||||||
fields_to_update['status'] = True if status == 'True' else False
|
fields_to_update['status'] = True if status == 'True' else False
|
||||||
|
Loading…
Reference in New Issue
Block a user