[damned-lies] fix: return 403 response instead of raising exception



commit 6af7a246da58c6b6680ced29aba85beb75a54626
Author: Guillaume Bernard <associations guillaume-bernard fr>
Date:   Mon May 3 20:24:26 2021 +0200

    fix: return 403 response instead of raising exception

 api/views.py | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
---
diff --git a/api/views.py b/api/views.py
index fe5b279e..5ebec3da 100644
--- a/api/views.py
+++ b/api/views.py
@@ -2,7 +2,6 @@ import traceback
 from threading import Thread
 
 from django.contrib.auth.mixins import LoginRequiredMixin
-from django.core.exceptions import PermissionDenied
 from django.core.mail import mail_admins
 from django.http import Http404, HttpResponseForbidden, JsonResponse
 from django.shortcuts import get_object_or_404
@@ -233,7 +232,7 @@ class UploadTranslationView(LoginRequiredMixin, VertimusPageMixin, View):
         stats, state = self.get_state_from_kwargs()
         actions = [x.name for x in state.get_available_actions(request.user.person)]
         if 'UT' not in actions:
-            raise PermissionDenied('You cannot upload a translation to this module')
+            return HttpResponseForbidden('You cannot upload a translation to this module')
 
         action = ActionUT(person=request.user.person, file=request.FILES.get('file'))
         action.apply_on(state, {'comment': '', 'send_to_ml': True})


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]