From cb7f3c9f18ff8b8076498b1aef3c5cc229be7b18 Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Fri, 23 Oct 2020 16:42:06 +0200 Subject: [PATCH] Note account can manage BDE memberships --- apps/member/templates/member/user_list.html | 2 +- apps/member/views.py | 7 ++++ apps/permission/fixtures/initial.json | 38 ++++++++++++++++++++- 3 files changed, 45 insertions(+), 2 deletions(-) diff --git a/apps/member/templates/member/user_list.html b/apps/member/templates/member/user_list.html index a41d7e69..023aca16 100644 --- a/apps/member/templates/member/user_list.html +++ b/apps/member/templates/member/user_list.html @@ -5,7 +5,7 @@ SPDX-License-Identifier: GPL-3.0-or-later {% load i18n perms %} {% block content %} -{% if "member.change_profile_registration_valid"|has_perm:user %} +{% if can_manage_registrations %} {% trans "Registrations" %} diff --git a/apps/member/views.py b/apps/member/views.py index f736f47e..ed52e2a3 100644 --- a/apps/member/views.py +++ b/apps/member/views.py @@ -234,6 +234,13 @@ class UserListView(ProtectQuerysetMixin, LoginRequiredMixin, SingleTableView): return qs + def get_context_data(self, **kwargs): + context = super().get_context_data(**kwargs) + pre_registered_users = User.objects.filter(PermissionBackend.filter_queryset(self.request.user, User, "view"))\ + .filter(profile__registration_valid=False) + context["can_manage_registrations"] = pre_registered_users.exists() + return context + class ProfileAliasView(ProtectQuerysetMixin, LoginRequiredMixin, DetailView): """ diff --git a/apps/permission/fixtures/initial.json b/apps/permission/fixtures/initial.json index ffd6d148..8c7ec9bc 100644 --- a/apps/permission/fixtures/initial.json +++ b/apps/permission/fixtures/initial.json @@ -2807,6 +2807,38 @@ "description": "Voir ses propres alias, pour toujours" } }, + { + "model": "permission.permission", + "pk": 180, + "fields": { + "model": [ + "auth", + "user" + ], + "query": "{\"profile__registration_valid\": false}", + "type": "view", + "mask": 2, + "field": "", + "permanent": false, + "description": "Voir n'importe quel utilisateur non encore inscrit" + } + }, + { + "model": "permission.permission", + "pk": 181, + "fields": { + "model": [ + "member", + "profile" + ], + "query": "{\"registration_valid\": false}", + "type": "view", + "mask": 2, + "field": "", + "permanent": false, + "description": "Voir n'importe quel profil non encore inscrit" + } + }, { "model": "permission.role", "pk": 1, @@ -3422,11 +3454,13 @@ "name": "PC Kfet", "permissions": [ 6, + 22, 24, 25, 26, 27, 30, + 49, 50, 55, 56, @@ -3438,7 +3472,9 @@ 167, 168, 176, - 177 + 177, + 180, + 181 ] } },