mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-23 17:08:41 -06:00
Add background_job toggle to BulkEditForm
This commit is contained in:
parent
5f8a4f6c43
commit
ecdd4bf076
@ -8,7 +8,7 @@ from django.utils.translation import gettext_lazy as _
|
||||
from core.models import ObjectType
|
||||
from extras.choices import *
|
||||
from extras.models import CustomField, Tag
|
||||
from utilities.forms import CSVModelForm
|
||||
from utilities.forms import BulkEditForm, CSVModelForm
|
||||
from utilities.forms.fields import CSVModelMultipleChoiceField, DynamicModelMultipleChoiceField
|
||||
from utilities.forms.mixins import CheckLastUpdatedMixin
|
||||
from .mixins import CustomFieldsMixin, SavedFiltersMixin, TagsMixin
|
||||
@ -100,7 +100,7 @@ class NetBoxModelImportForm(CSVModelForm, NetBoxModelForm):
|
||||
return customfield.to_form_field(for_csv_import=True)
|
||||
|
||||
|
||||
class NetBoxModelBulkEditForm(CustomFieldsMixin, forms.Form):
|
||||
class NetBoxModelBulkEditForm(CustomFieldsMixin, BulkEditForm):
|
||||
"""
|
||||
Base form for modifying multiple NetBox objects (of the same type) in bulk via the UI. Adds support for custom
|
||||
fields and adding/removing tags.
|
||||
@ -108,9 +108,8 @@ class NetBoxModelBulkEditForm(CustomFieldsMixin, forms.Form):
|
||||
Attributes:
|
||||
fieldsets: An iterable of two-tuples which define a heading and field set to display per section of
|
||||
the rendered form (optional). If not defined, the all fields will be rendered as a single section.
|
||||
nullable_fields: A list of field names indicating which fields support being set to null/empty
|
||||
"""
|
||||
nullable_fields = ()
|
||||
fieldsets = None
|
||||
|
||||
pk = forms.ModelMultipleChoiceField(
|
||||
queryset=None, # Set from self.model on init
|
||||
|
@ -17,7 +17,7 @@ __all__ = (
|
||||
)
|
||||
|
||||
|
||||
class UserBulkEditForm(forms.Form):
|
||||
class UserBulkEditForm(BulkEditForm):
|
||||
pk = forms.ModelMultipleChoiceField(
|
||||
queryset=User.objects.all(),
|
||||
widget=forms.MultipleHiddenInput
|
||||
@ -55,7 +55,7 @@ class UserBulkEditForm(forms.Form):
|
||||
nullable_fields = ('first_name', 'last_name')
|
||||
|
||||
|
||||
class GroupBulkEditForm(forms.Form):
|
||||
class GroupBulkEditForm(BulkEditForm):
|
||||
pk = forms.ModelMultipleChoiceField(
|
||||
queryset=Group.objects.all(),
|
||||
widget=forms.MultipleHiddenInput
|
||||
@ -73,7 +73,7 @@ class GroupBulkEditForm(forms.Form):
|
||||
nullable_fields = ('description',)
|
||||
|
||||
|
||||
class ObjectPermissionBulkEditForm(forms.Form):
|
||||
class ObjectPermissionBulkEditForm(BulkEditForm):
|
||||
pk = forms.ModelMultipleChoiceField(
|
||||
queryset=ObjectPermission.objects.all(),
|
||||
widget=forms.MultipleHiddenInput
|
||||
|
@ -31,9 +31,18 @@ class ConfirmationForm(forms.Form):
|
||||
class BulkEditForm(forms.Form):
|
||||
"""
|
||||
Provides bulk edit support for objects.
|
||||
|
||||
Attributes:
|
||||
nullable_fields: A list of field names indicating which fields support being set to null/empty
|
||||
"""
|
||||
nullable_fields = ()
|
||||
|
||||
background_job = forms.BooleanField(
|
||||
label=_('Background job'),
|
||||
help_text=_("Process as a job to edit objects in the background"),
|
||||
required=False,
|
||||
)
|
||||
|
||||
|
||||
class BulkRenameForm(forms.Form):
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user