From e88a82553d52c458bb837233f58edd2f541caea7 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Sat, 2 Mar 2019 22:41:14 +0100 Subject: [PATCH] use separate Form for Admin user editing (allow is_staff and is_active) --- passbook/admin/forms/users.py | 17 +++++++++++++++++ passbook/admin/views/users.py | 4 ++-- 2 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 passbook/admin/forms/users.py diff --git a/passbook/admin/forms/users.py b/passbook/admin/forms/users.py new file mode 100644 index 000000000..d6ef9a084 --- /dev/null +++ b/passbook/admin/forms/users.py @@ -0,0 +1,17 @@ +"""passbook administrative user forms""" + +from django import forms + +from passbook.core.models import User + + +class UserForm(forms.ModelForm): + """Update User Details""" + + class Meta: + + model = User + fields = ['username', 'name', 'email', 'is_staff', 'is_active'] + widgets = { + 'name': forms.TextInput + } diff --git a/passbook/admin/views/users.py b/passbook/admin/views/users.py index 0140078c6..4f1532cea 100644 --- a/passbook/admin/views/users.py +++ b/passbook/admin/views/users.py @@ -7,8 +7,8 @@ from django.utils.translation import ugettext as _ from django.views import View from django.views.generic import DeleteView, ListView, UpdateView +from passbook.admin.forms.users import UserForm from passbook.admin.mixins import AdminRequiredMixin -from passbook.core.forms.users import UserDetailForm from passbook.core.models import Nonce, User @@ -23,7 +23,7 @@ class UserUpdateView(SuccessMessageMixin, AdminRequiredMixin, UpdateView): """Update user""" model = User - form_class = UserDetailForm + form_class = UserForm template_name = 'generic/update.html' success_url = reverse_lazy('passbook_admin:users')