Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Add is_staff and is_superuser to staff form
Unknown1e8676f33a04
diff --git a/saleor/dashboard/staff/forms.py b/saleor/dashboard/staff/forms.pyindex 4f1527573a..01a0878753 100644--- a/saleor/dashboard/staff/forms.py+++ b/saleor/dashboard/staff/forms.py@@ -17,7 +17,7 @@ class StaffForm(forms.ModelForm):class Meta:model = Userfields = ['first_name', 'last_name', 'email',- 'user_permissions', 'is_active']+ 'user_permissions', 'is_active', 'is_staff', 'is_superuser']labels = {'first_name': pgettext_lazy('Customer form: Given name field', 'Given name'),@@ -26,14 +26,28 @@ class StaffForm(forms.ModelForm):'email': pgettext_lazy('Email', 'Email'),'is_active': pgettext_lazy(- 'User active toggle', 'User is active')}+ 'User active toggle', 'User is active'),+ 'is_staff': pgettext_lazy(+ 'User staff toggle', 'User is staff'),+ 'is_superuser': pgettext_lazy(+ 'User superuser toggle', 'User is superuser')}def __init__(self, *args, **kwargs):self.user = kwargs.pop('user', None)super().__init__(*args, **kwargs)- if self.user == self.instance:+ # Only superuser can assign other user as superuser+ self.fields['is_superuser'].disabled = True+ if self.user and self.user.is_superuser:+ self.fields['is_superuser'].disabled = False++ if (self.user == self.instance+ or (self.instance and self.instance.is_superuser)):+ self.fields['email'].disabled = True+ self.fields['user_permissions'].disabled = Trueself.fields['is_active'].disabled = True+ self.fields['is_staff'].disabled = True+ self.fields['is_superuser'].disabled = Trueaddress = self.instance.default_billing_addressif not address: