diff --git a/passbook/admin/templates/administration/base.html b/passbook/admin/templates/administration/base.html index 60d783f6a..bab43ea32 100644 --- a/passbook/admin/templates/administration/base.html +++ b/passbook/admin/templates/administration/base.html @@ -23,8 +23,8 @@
  • {% trans 'Invitations' %}
  • -
  • - {% trans 'Users' %} +
  • + {% trans 'Users' %}
  • {% trans 'Audit Log' %} diff --git a/passbook/admin/templates/administration/user/list.html b/passbook/admin/templates/administration/user/list.html new file mode 100644 index 000000000..44301e33a --- /dev/null +++ b/passbook/admin/templates/administration/user/list.html @@ -0,0 +1,38 @@ +{% extends "administration/base.html" %} + +{% load i18n %} +{% load utils %} + +{% block content %} +
    +

    {% trans "Users" %}

    +
    + + + + + + + + + + + + + {% for user in object_list %} + + + + + + + + + {% endfor %} + +
    {% trans 'Username' %}{% trans 'First Name' %}{% trans 'Last Name' %}{% trans 'Active' %}{% trans 'Last Login' %}
    {{ user.username }}{{ user.first_name|default:'-' }}{{ user.last_name|default:'-' }}{{ user.is_active }}{{ user.last_login }} + {% trans 'Edit' %} + {% trans 'Delete' %} +
    +
    +{% endblock %} diff --git a/passbook/admin/urls.py b/passbook/admin/urls.py index b34db5b76..0079ab81d 100644 --- a/passbook/admin/urls.py +++ b/passbook/admin/urls.py @@ -2,7 +2,7 @@ from django.urls import path from passbook.admin.views import (applications, audit, invitations, overview, - providers, rules, sources) + providers, rules, sources, users) urlpatterns = [ path('', overview.AdministrationOverviewView.as_view(), name='overview'), @@ -40,6 +40,13 @@ urlpatterns = [ invitations.InvitationCreateView.as_view(), name='invitation-create'), path('invitations//delete/', invitations.InvitationDeleteView.as_view(), name='invitation-delete'), + # Users + path('users/', users.UserListView.as_view(), + name='users'), + path('users//update/', + users.UserUpdateView.as_view(), name='user-update'), + path('users//delete/', + users.UserDeleteView.as_view(), name='user-delete'), # Audit Log path('audit/', audit.AuditEntryListView.as_view(), name='audit-log'), # path('api/v1/', include('passbook.admin.api.v1.urls')) diff --git a/passbook/admin/views/users.py b/passbook/admin/views/users.py new file mode 100644 index 000000000..30f19a3c7 --- /dev/null +++ b/passbook/admin/views/users.py @@ -0,0 +1,38 @@ +"""passbook User administration""" +from django.contrib.messages.views import SuccessMessageMixin +from django.shortcuts import get_object_or_404 +from django.urls import reverse_lazy +from django.utils.translation import ugettext as _ +from django.views.generic import DeleteView, ListView, TemplateView, UpdateView + +from passbook.admin.mixins import AdminRequiredMixin +from passbook.core.forms.user import UserDetailForm +from passbook.core.models import User + + +class UserListView(AdminRequiredMixin, ListView): + """Show list of all users""" + + model = User + template_name = 'administration/user/list.html' + + +class UserUpdateView(SuccessMessageMixin, AdminRequiredMixin, UpdateView): + """Update user""" + + model = User + form_class = UserDetailForm + + template_name = 'generic/update.html' + success_url = reverse_lazy('passbook_admin:users') + success_message = _('Successfully updated User') + + +class UserDeleteView(SuccessMessageMixin, AdminRequiredMixin, DeleteView): + """Delete user""" + + model = User + + success_url = reverse_lazy('passbook_admin:users') + success_message = _('Successfully updated User') +