From 64290b2a37bf605e62ecc2069f71032a854d5e80 Mon Sep 17 00:00:00 2001 From: "Langhammer, Jens" Date: Tue, 8 Oct 2019 11:27:19 +0200 Subject: [PATCH] admin(minor): add view to create user --- .../admin/templates/administration/user/list.html | 4 ++++ passbook/admin/urls.py | 1 + passbook/admin/views/users.py | 13 ++++++++++++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/passbook/admin/templates/administration/user/list.html b/passbook/admin/templates/administration/user/list.html index 726936b1e..9a154f0f4 100644 --- a/passbook/admin/templates/administration/user/list.html +++ b/passbook/admin/templates/administration/user/list.html @@ -7,6 +7,10 @@

{% trans "Users" %}


+ + {% trans 'Create...' %} + +
diff --git a/passbook/admin/urls.py b/passbook/admin/urls.py index 64cc15022..030881366 100644 --- a/passbook/admin/urls.py +++ b/passbook/admin/urls.py @@ -61,6 +61,7 @@ urlpatterns = [ # Users path('users/', users.UserListView.as_view(), name='users'), + path('users/create/', users.UserCreateView.as_view(), name='user-create'), path('users//update/', users.UserUpdateView.as_view(), name='user-update'), path('users//delete/', diff --git a/passbook/admin/views/users.py b/passbook/admin/views/users.py index 4f1532cea..cc99fb7a7 100644 --- a/passbook/admin/views/users.py +++ b/passbook/admin/views/users.py @@ -5,7 +5,7 @@ from django.shortcuts import get_object_or_404, redirect from django.urls import reverse, reverse_lazy from django.utils.translation import ugettext as _ from django.views import View -from django.views.generic import DeleteView, ListView, UpdateView +from django.views.generic import CreateView, DeleteView, ListView, UpdateView from passbook.admin.forms.users import UserForm from passbook.admin.mixins import AdminRequiredMixin @@ -19,6 +19,17 @@ class UserListView(AdminRequiredMixin, ListView): template_name = 'administration/user/list.html' +class UserCreateView(SuccessMessageMixin, AdminRequiredMixin, CreateView): + """Create user""" + + model = User + form_class = UserForm + + template_name = 'generic/create.html' + success_url = reverse_lazy('passbook_admin:users') + success_message = _('Successfully created User') + + class UserUpdateView(SuccessMessageMixin, AdminRequiredMixin, UpdateView): """Update user"""