admin(minor): add view to create user
This commit is contained in:
parent
72769b8a0a
commit
64290b2a37
|
@ -7,6 +7,10 @@
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<h1><span class="pficon-users"></span> {% trans "Users" %}</h1>
|
<h1><span class="pficon-users"></span> {% trans "Users" %}</h1>
|
||||||
<hr>
|
<hr>
|
||||||
|
<a href="{% url 'passbook_admin:user-create' %}?back={{ request.get_full_path }}" class="btn btn-primary">
|
||||||
|
{% trans 'Create...' %}
|
||||||
|
</a>
|
||||||
|
<hr>
|
||||||
<table class="table table-striped table-bordered">
|
<table class="table table-striped table-bordered">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
|
|
@ -61,6 +61,7 @@ urlpatterns = [
|
||||||
# Users
|
# Users
|
||||||
path('users/', users.UserListView.as_view(),
|
path('users/', users.UserListView.as_view(),
|
||||||
name='users'),
|
name='users'),
|
||||||
|
path('users/create/', users.UserCreateView.as_view(), name='user-create'),
|
||||||
path('users/<int:pk>/update/',
|
path('users/<int:pk>/update/',
|
||||||
users.UserUpdateView.as_view(), name='user-update'),
|
users.UserUpdateView.as_view(), name='user-update'),
|
||||||
path('users/<int:pk>/delete/',
|
path('users/<int:pk>/delete/',
|
||||||
|
|
|
@ -5,7 +5,7 @@ from django.shortcuts import get_object_or_404, redirect
|
||||||
from django.urls import reverse, reverse_lazy
|
from django.urls import reverse, reverse_lazy
|
||||||
from django.utils.translation import ugettext as _
|
from django.utils.translation import ugettext as _
|
||||||
from django.views import View
|
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.forms.users import UserForm
|
||||||
from passbook.admin.mixins import AdminRequiredMixin
|
from passbook.admin.mixins import AdminRequiredMixin
|
||||||
|
@ -19,6 +19,17 @@ class UserListView(AdminRequiredMixin, ListView):
|
||||||
template_name = 'administration/user/list.html'
|
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):
|
class UserUpdateView(SuccessMessageMixin, AdminRequiredMixin, UpdateView):
|
||||||
"""Update user"""
|
"""Update user"""
|
||||||
|
|
||||||
|
|
Reference in a new issue