mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-25 08:46:10 -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 users.models import *
|
||||||
from utilities.forms import BootstrapMixin
|
from utilities.forms import BootstrapMixin
|
||||||
|
from utilities.forms.widgets import BulkEditNullBooleanSelect
|
||||||
|
|
||||||
__all__ = (
|
__all__ = (
|
||||||
'ObjectPermissionBulkEditForm',
|
'ObjectPermissionBulkEditForm',
|
||||||
@ -13,7 +14,7 @@ __all__ = (
|
|||||||
class UserBulkEditForm(BootstrapMixin, forms.Form):
|
class UserBulkEditForm(BootstrapMixin, forms.Form):
|
||||||
pk = forms.ModelMultipleChoiceField(
|
pk = forms.ModelMultipleChoiceField(
|
||||||
label=_('Pk'),
|
label=_('Pk'),
|
||||||
queryset=None, # Set from self.model on init
|
queryset=NetBoxUser.objects.all(),
|
||||||
widget=forms.MultipleHiddenInput
|
widget=forms.MultipleHiddenInput
|
||||||
)
|
)
|
||||||
first_name = forms.CharField(
|
first_name = forms.CharField(
|
||||||
@ -26,16 +27,19 @@ class UserBulkEditForm(BootstrapMixin, forms.Form):
|
|||||||
max_length=150,
|
max_length=150,
|
||||||
required=False
|
required=False
|
||||||
)
|
)
|
||||||
is_active = forms.BooleanField(
|
is_active = forms.NullBooleanField(
|
||||||
required=False,
|
required=False,
|
||||||
|
widget=BulkEditNullBooleanSelect,
|
||||||
label=_('Active')
|
label=_('Active')
|
||||||
)
|
)
|
||||||
is_staff = forms.BooleanField(
|
is_staff = forms.NullBooleanField(
|
||||||
required=False,
|
required=False,
|
||||||
|
widget=BulkEditNullBooleanSelect,
|
||||||
label=_('Staff status')
|
label=_('Staff status')
|
||||||
)
|
)
|
||||||
is_superuser = forms.BooleanField(
|
is_superuser = forms.NullBooleanField(
|
||||||
required=False,
|
required=False,
|
||||||
|
widget=BulkEditNullBooleanSelect,
|
||||||
label=_('Superuser status')
|
label=_('Superuser status')
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -43,11 +47,7 @@ class UserBulkEditForm(BootstrapMixin, forms.Form):
|
|||||||
fieldsets = (
|
fieldsets = (
|
||||||
(None, ('first_name', 'last_name', 'is_active', 'is_staff', 'is_superuser')),
|
(None, ('first_name', 'last_name', 'is_active', 'is_staff', 'is_superuser')),
|
||||||
)
|
)
|
||||||
nullable_fields = ()
|
nullable_fields = ('first_name', 'last_name')
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
|
||||||
super().__init__(*args, **kwargs)
|
|
||||||
self.fields['pk'].queryset = self.model.objects.all()
|
|
||||||
|
|
||||||
|
|
||||||
class ObjectPermissionBulkEditForm(BootstrapMixin, forms.Form):
|
class ObjectPermissionBulkEditForm(BootstrapMixin, forms.Form):
|
||||||
|
@ -58,6 +58,9 @@ class TokenTable(NetBoxTable):
|
|||||||
|
|
||||||
class UserTable(NetBoxTable):
|
class UserTable(NetBoxTable):
|
||||||
username = tables.Column(linkify=True)
|
username = tables.Column(linkify=True)
|
||||||
|
is_active = columns.BooleanColumn()
|
||||||
|
is_staff = columns.BooleanColumn()
|
||||||
|
is_superuser = columns.BooleanColumn()
|
||||||
actions = columns.ActionsColumn(
|
actions = columns.ActionsColumn(
|
||||||
actions=('edit', 'delete'),
|
actions=('edit', 'delete'),
|
||||||
)
|
)
|
||||||
@ -65,9 +68,9 @@ class UserTable(NetBoxTable):
|
|||||||
class Meta(NetBoxTable.Meta):
|
class Meta(NetBoxTable.Meta):
|
||||||
model = NetBoxUser
|
model = NetBoxUser
|
||||||
fields = (
|
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):
|
class GroupTable(NetBoxTable):
|
||||||
|
Loading…
Reference in New Issue
Block a user