From 54dbb35724a7d46b0ecbf51fc9f167c081a9cb1d Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sun, 10 Oct 2021 17:01:37 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Return=20responses=20instead=20o?= =?UTF-8?q?f=20raising=20exceptions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/sophon/core/views.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/sophon/core/views.py b/backend/sophon/core/views.py index da36a86..a21a741 100644 --- a/backend/sophon/core/views.py +++ b/backend/sophon/core/views.py @@ -234,11 +234,11 @@ class ResearchGroupViewSet(WriteSophonViewSet): # Raise an error if the user is not in the group if self.request.user not in group.members.all(): - raise HTTPException(s.HTTP_409_CONFLICT) + return Response(status=s.HTTP_409_CONFLICT) # Raise an error if the user is the owner of the group if self.request.user == group.owner: - raise HTTPException(s.HTTP_403_FORBIDDEN) + return Response(status=s.HTTP_403_FORBIDDEN) # Add the user to the group group.members.remove(self.request.user)