mirror of
https://github.com/netbox-community/netbox.git
synced 2026-01-10 05:42:16 -06:00
Closes #1110: Expand bulk edit forms to include boolean fields (e.g. toggle is_pool for prefixes)
This commit is contained in:
@@ -138,6 +138,19 @@ class ColorSelect(forms.Select):
|
||||
option_value, selected_html, option_value, force_text(option_label))
|
||||
|
||||
|
||||
class BulkEditNullBooleanSelect(forms.NullBooleanSelect):
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(BulkEditNullBooleanSelect, self).__init__(*args, **kwargs)
|
||||
|
||||
# Override the built-in choice labels
|
||||
self.choices = (
|
||||
('1', '---------'),
|
||||
('2', 'Yes'),
|
||||
('3', 'No'),
|
||||
)
|
||||
|
||||
|
||||
class SelectWithDisabled(forms.Select):
|
||||
"""
|
||||
Modified the stock Select widget to accept choices using a dict() for a label. The dict for each option must include
|
||||
|
||||
@@ -423,7 +423,7 @@ class BulkEditView(View):
|
||||
filter: FilterSet to apply when deleting by QuerySet
|
||||
form: The form class used to edit objects in bulk
|
||||
template_name: The name of the template
|
||||
default_return_url: Name of the URL to which the user is redirected after editing the objects (can be overriden by
|
||||
default_return_url: Name of the URL to which the user is redirected after editing the objects (can be overridden by
|
||||
POSTing return_url)
|
||||
"""
|
||||
cls = None
|
||||
@@ -475,7 +475,7 @@ class BulkEditView(View):
|
||||
fields_to_update[field] = ''
|
||||
else:
|
||||
fields_to_update[field] = None
|
||||
elif form.cleaned_data[field]:
|
||||
elif form.cleaned_data[field] not in (None, ''):
|
||||
fields_to_update[field] = form.cleaned_data[field]
|
||||
updated_count = self.cls.objects.filter(pk__in=pk_list).update(**fields_to_update)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user