mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-25 00:36:11 -06:00
Clean up user bulk edit
This commit is contained in:
parent
937961baa1
commit
30d9798bb3
@ -3,6 +3,7 @@ from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from users.models import *
|
||||
from utilities.forms import BootstrapMixin
|
||||
from utilities.forms.widgets import BulkEditNullBooleanSelect
|
||||
|
||||
__all__ = (
|
||||
'ObjectPermissionBulkEditForm',
|
||||
@ -13,7 +14,7 @@ __all__ = (
|
||||
class UserBulkEditForm(BootstrapMixin, forms.Form):
|
||||
pk = forms.ModelMultipleChoiceField(
|
||||
label=_('Pk'),
|
||||
queryset=None, # Set from self.model on init
|
||||
queryset=NetBoxUser.objects.all(),
|
||||
widget=forms.MultipleHiddenInput
|
||||
)
|
||||
first_name = forms.CharField(
|
||||
@ -26,16 +27,19 @@ class UserBulkEditForm(BootstrapMixin, forms.Form):
|
||||
max_length=150,
|
||||
required=False
|
||||
)
|
||||
is_active = forms.BooleanField(
|
||||
is_active = forms.NullBooleanField(
|
||||
required=False,
|
||||
widget=BulkEditNullBooleanSelect,
|
||||
label=_('Active')
|
||||
)
|
||||
is_staff = forms.BooleanField(
|
||||
is_staff = forms.NullBooleanField(
|
||||
required=False,
|
||||
widget=BulkEditNullBooleanSelect,
|
||||
label=_('Staff status')
|
||||
)
|
||||
is_superuser = forms.BooleanField(
|
||||
is_superuser = forms.NullBooleanField(
|
||||
required=False,
|
||||
widget=BulkEditNullBooleanSelect,
|
||||
label=_('Superuser status')
|
||||
)
|
||||
|
||||
@ -43,11 +47,7 @@ class UserBulkEditForm(BootstrapMixin, forms.Form):
|
||||
fieldsets = (
|
||||
(None, ('first_name', 'last_name', 'is_active', 'is_staff', 'is_superuser')),
|
||||
)
|
||||
nullable_fields = ()
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.fields['pk'].queryset = self.model.objects.all()
|
||||
nullable_fields = ('first_name', 'last_name')
|
||||
|
||||
|
||||
class ObjectPermissionBulkEditForm(BootstrapMixin, forms.Form):
|
||||
|
@ -58,6 +58,9 @@ class TokenTable(NetBoxTable):
|
||||
|
||||
class UserTable(NetBoxTable):
|
||||
username = tables.Column(linkify=True)
|
||||
is_active = columns.BooleanColumn()
|
||||
is_staff = columns.BooleanColumn()
|
||||
is_superuser = columns.BooleanColumn()
|
||||
actions = columns.ActionsColumn(
|
||||
actions=('edit', 'delete'),
|
||||
)
|
||||
@ -65,9 +68,9 @@ class UserTable(NetBoxTable):
|
||||
class Meta(NetBoxTable.Meta):
|
||||
model = NetBoxUser
|
||||
fields = (
|
||||
'pk', 'id', 'username', 'email', 'first_name', 'last_name', 'is_superuser', 'is_staff', 'is_active'
|
||||
'pk', 'id', 'username', 'first_name', 'last_name', 'email', 'is_active', 'is_staff', 'is_superuser',
|
||||
)
|
||||
default_columns = ('pk', 'username', 'email', 'first_name', 'last_name', 'is_superuser')
|
||||
default_columns = ('pk', 'username', 'first_name', 'last_name', 'email', 'is_active')
|
||||
|
||||
|
||||
class GroupTable(NetBoxTable):
|
||||
|
Loading…
Reference in New Issue
Block a user