From 93792f5f460f2ec87e30d126ba9e29ac1cea1693 Mon Sep 17 00:00:00 2001 From: Tom Hubrecht Date: Tue, 26 Oct 2021 19:17:06 +0200 Subject: [PATCH] =?UTF-8?q?On=20=C3=A9vite=20les=20erreurs=20si=20pas=20la?= =?UTF-8?q?=20bonne=20url?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- wiki_groups/views.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/wiki_groups/views.py b/wiki_groups/views.py index afda14f..e2055f1 100644 --- a/wiki_groups/views.py +++ b/wiki_groups/views.py @@ -91,8 +91,10 @@ class RemoveUserView(WikiGroupMixin, RedirectView): return reverse("wiki_groups:admin-group", args=[kwargs["pk"]]) def get(self, request, *args, **kwargs): - user = User.objects.get(pk=kwargs["user_pk"]) - self.object.users.remove(user) + user = User.objects.filter(pk=kwargs["user_pk"]).first() + + if user is not None: + self.object.users.remove(user) return super().get(request, *args, **kwargs) @@ -102,7 +104,11 @@ class RemoveManagerView(WikiGroupMixin, RedirectView): return reverse("wiki_groups:admin-group", args=[kwargs["pk"]]) def get(self, request, *args, **kwargs): - user = User.objects.get(pk=kwargs["user_pk"]) + user = User.objects.filter(pk=kwargs["user_pk"]).first() + + if user is not None: + self.object.users.remove(user) + self.object.managers.remove(user) return super().get(request, *args, **kwargs) @@ -113,8 +119,10 @@ class RemoveGroupView(WikiGroupMixin, RedirectView): return reverse("wiki_groups:admin-group", args=[kwargs["pk"]]) def get(self, request, *args, **kwargs): - group = WikiGroup.objects.get(pk=kwargs["group_pk"]) - self.object.includes_groups.remove(group) + group = WikiGroup.objects.filter(pk=kwargs["group_pk"]).first() + + if group is not None: + self.object.includes_groups.remove(group) return super().get(request, *args, **kwargs)