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)