On évite les erreurs si pas la bonne url

This commit is contained in:
Tom Hubrecht 2021-10-26 19:17:06 +02:00
parent d5c1e2225a
commit 93792f5f46

View file

@ -91,7 +91,9 @@ class RemoveUserView(WikiGroupMixin, RedirectView):
return reverse("wiki_groups:admin-group", args=[kwargs["pk"]]) return reverse("wiki_groups:admin-group", args=[kwargs["pk"]])
def get(self, request, *args, **kwargs): 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.users.remove(user)
return super().get(request, *args, **kwargs) return super().get(request, *args, **kwargs)
@ -102,7 +104,11 @@ class RemoveManagerView(WikiGroupMixin, RedirectView):
return reverse("wiki_groups:admin-group", args=[kwargs["pk"]]) return reverse("wiki_groups:admin-group", args=[kwargs["pk"]])
def get(self, request, *args, **kwargs): 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) self.object.managers.remove(user)
return super().get(request, *args, **kwargs) return super().get(request, *args, **kwargs)
@ -113,7 +119,9 @@ class RemoveGroupView(WikiGroupMixin, RedirectView):
return reverse("wiki_groups:admin-group", args=[kwargs["pk"]]) return reverse("wiki_groups:admin-group", args=[kwargs["pk"]])
def get(self, request, *args, **kwargs): def get(self, request, *args, **kwargs):
group = WikiGroup.objects.get(pk=kwargs["group_pk"]) group = WikiGroup.objects.filter(pk=kwargs["group_pk"]).first()
if group is not None:
self.object.includes_groups.remove(group) self.object.includes_groups.remove(group)
return super().get(request, *args, **kwargs) return super().get(request, *args, **kwargs)