1
0
mirror of https://gitlab.com/animath/si/plateforme.git synced 2025-06-21 01:58:23 +02:00

Upload all authorizations

This commit is contained in:
Yohann D'ANELLO
2020-12-29 16:14:56 +01:00
parent 72753edf64
commit e3a32a41f9
10 changed files with 252 additions and 68 deletions

View File

@ -8,7 +8,15 @@ from haystack.generic_views import SearchView
class AdminMixin(LoginRequiredMixin):
def dispatch(self, request, *args, **kwargs):
if not request.user.registration.is_admin:
if request.user.is_authenticated and not request.user.registration.is_admin:
raise PermissionDenied
return super().dispatch(request, *args, **kwargs)
class UserMixin(LoginRequiredMixin):
def dispatch(self, request, *args, **kwargs):
user = request.user
if user.is_authenticated and not user.registration.is_admin and user.registration.pk != kwargs["pk"]:
raise PermissionDenied
return super().dispatch(request, *args, **kwargs)