diff --git a/src/membership/permissions.py b/src/membership/permissions.py index 4582149..02a5388 100644 --- a/src/membership/permissions.py +++ b/src/membership/permissions.py @@ -38,9 +38,9 @@ class Permission: ) -ADMINISTRATE_MEMBERSHIPS = Permission( - name=_("Can administrate memberships"), - codename="administrate_memberships", +ADMINISTRATE_MEMBERS = Permission( + name=_("Can administrate members"), + codename="administrate_members", app_label="membership", model="membership", ) diff --git a/src/membership/selectors.py b/src/membership/selectors.py index 944fa99..d1eb97d 100644 --- a/src/membership/selectors.py +++ b/src/membership/selectors.py @@ -24,3 +24,7 @@ def get_memberships( memberships = memberships.filter(period=period) return memberships + + +def get_users(): + return User.objects.all() diff --git a/src/membership/templates/membership/membership_admin.html b/src/membership/templates/membership/membership_admin.html deleted file mode 100644 index 2a67013..0000000 --- a/src/membership/templates/membership/membership_admin.html +++ /dev/null @@ -1,13 +0,0 @@ -{% extends "base.html" %} -{% load i18n %} - -{% block content %} - - {% for period in subscription_periods %} -
{{ membership.user.username }}
- {% endfor %} - {% endfor %} - -{% endblock %} diff --git a/src/membership/views.py b/src/membership/views.py index 7bcc74a..83a193b 100644 --- a/src/membership/views.py +++ b/src/membership/views.py @@ -1,11 +1,13 @@ from django.contrib.auth.decorators import login_required from django.contrib.auth.decorators import permission_required +from django.utils.translation import gettext_lazy as _ from zen_queries import render -from .permissions import ADMINISTRATE_MEMBERSHIPS +from .permissions import ADMINISTRATE_MEMBERS from .selectors import get_memberships -from .selectors import get_subscription_periods +from .selectors import get_users from utils.view_utils import base_view_context +from utils.view_utils import render_list @login_required @@ -30,16 +32,17 @@ def membership_overview(request): @login_required -@permission_required(ADMINISTRATE_MEMBERSHIPS.path) -def membership_admin(request): - subscription_periods = get_subscription_periods() +@permission_required(ADMINISTRATE_MEMBERS.path) +def members_admin(request): + users = get_users() - context = base_view_context(request) | { - "subscription_periods": subscription_periods, - } - - return render( + return render_list( request=request, - template_name="membership/membership_admin.html", - context=context, + objects=users, + columns=[ + ("username", _("Username")), + ("first_name", _("First name")), + ("last_name", _("Last name")), + ("email", _("Email")), + ], ) diff --git a/src/project/templates/base.html b/src/project/templates/base.html index 88eb3ae..5c478ee 100644 --- a/src/project/templates/base.html +++ b/src/project/templates/base.html @@ -192,8 +192,8 @@ {% trans "Admin" %}