mirror of
https://github.com/netbox-community/netbox.git
synced 2026-03-24 02:11:50 +01:00
* Closes #16137: Remove is_staff boolean from User model * Remove default is_staff value from UserManager.create_user() * Restore staff_only on MenuItem * Introduce IsSuperuser API permission to replace IsAdminUser * Update and improve RQ task API view tests * Remove is_staff attribute assignment from RemoteUserBackend
46 lines
1.0 KiB
Python
46 lines
1.0 KiB
Python
from django import forms
|
|
from django.utils.translation import gettext as _
|
|
from users.models import *
|
|
from utilities.forms import CSVModelForm
|
|
|
|
|
|
__all__ = (
|
|
'GroupImportForm',
|
|
'UserImportForm',
|
|
'TokenImportForm',
|
|
)
|
|
|
|
|
|
class GroupImportForm(CSVModelForm):
|
|
|
|
class Meta:
|
|
model = Group
|
|
fields = ('name', 'description')
|
|
|
|
|
|
class UserImportForm(CSVModelForm):
|
|
|
|
class Meta:
|
|
model = User
|
|
fields = (
|
|
'username', 'first_name', 'last_name', 'email', 'password', 'is_active', 'is_superuser'
|
|
)
|
|
|
|
def save(self, *args, **kwargs):
|
|
# Set the hashed password
|
|
self.instance.set_password(self.cleaned_data.get('password'))
|
|
|
|
return super().save(*args, **kwargs)
|
|
|
|
|
|
class TokenImportForm(CSVModelForm):
|
|
key = forms.CharField(
|
|
label=_('Key'),
|
|
required=False,
|
|
help_text=_("If no key is provided, one will be generated automatically.")
|
|
)
|
|
|
|
class Meta:
|
|
model = Token
|
|
fields = ('user', 'key', 'write_enabled', 'expires', 'description',)
|