From 71c616129183d78d53f4ffa324fb2ec213ee758d Mon Sep 17 00:00:00 2001 From: Jan Krcmar Date: Tue, 9 Feb 2016 11:16:36 +0100 Subject: [PATCH] accounts/edit added is_staff and is_superuser checkboxes list all users (previously staff and admins were not displayed) --- accounts/forms.py | 2 ++ accounts/templates/accounts.html | 14 +++++++++++++- accounts/views.py | 6 +++++- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/accounts/forms.py b/accounts/forms.py index 55d5c29..ac29f81 100644 --- a/accounts/forms.py +++ b/accounts/forms.py @@ -9,6 +9,8 @@ class UserAddForm(forms.Form): error_messages={'required': _('No User name has been entered')}, max_length=20) password = forms.CharField(required=True, error_messages={'required': _('No password has been entered')},) + is_staff = forms.BooleanField(required=True) + is_superuser = forms.BooleanField(required=True) def clean_name(self): name = self.cleaned_data['name'] diff --git a/accounts/templates/accounts.html b/accounts/templates/accounts.html index 9ebff0b..cc03668 100644 --- a/accounts/templates/accounts.html +++ b/accounts/templates/accounts.html @@ -71,6 +71,18 @@ +
+ +
+ +
+
+
+ +
+ +
+
-{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/accounts/views.py b/accounts/views.py index a364865..30f6904 100644 --- a/accounts/views.py +++ b/accounts/views.py @@ -75,7 +75,7 @@ def accounts(request): return HttpResponseRedirect(reverse('index')) error_messages = [] - users = User.objects.filter(is_staff=False, is_superuser=False) + users = User.objects.all() if request.method == 'POST': if 'create' in request.POST: @@ -92,8 +92,12 @@ def accounts(request): if 'edit' in request.POST: user_id = request.POST.get('user_id', '') user_pass = request.POST.get('user_pass', '') + user_is_staff = request.POST.get('user_is_staff', False) + user_is_superuser = request.POST.get('user_is_superuser', False) user_edit = User.objects.get(id=user_id) user_edit.set_password(user_pass) + user_edit.is_staff = user_is_staff + user_edit.is_superuser = user_is_superuser user_edit.save() return HttpResponseRedirect(request.get_full_path()) if 'block' in request.POST: