Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Set is_staff as default for form in creating new staff

Unknowne77e2a80ce05
diff --git a/saleor/dashboard/staff/forms.py b/saleor/dashboard/staff/forms.py
index 7632c2e857..4f1527573a 100644
--- a/saleor/dashboard/staff/forms.py
+++ b/saleor/dashboard/staff/forms.py
@@ -31,7 +31,7 @@ class StaffForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
self.user = kwargs.pop('user', None)
super().__init__(*args, **kwargs)
- self.instance.is_staff = True
+
if self.user == self.instance:
self.fields['is_active'].disabled = True
diff --git a/saleor/dashboard/staff/views.py b/saleor/dashboard/staff/views.py
index 10f78ebf7c..8281b552c6 100644
--- a/saleor/dashboard/staff/views.py
+++ b/saleor/dashboard/staff/views.py
@@ -56,7 +56,8 @@ def staff_create(request):
except User.DoesNotExist:
staff = User()
created = True
- form = StaffForm(request.POST or None, instance=staff)
+ form = StaffForm(
+ request.POST or None, instance=staff, initial={'is_staff': True})
if form.is_valid():
form.save()
msg = pgettext_lazy(