1
0
mirror of https://gitlab.com/animath/si/plateforme.git synced 2024-12-24 03:02:23 +00:00

Admin users can manage juries

Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
This commit is contained in:
Emmy D'Anello 2024-03-24 10:47:35 +01:00
parent 50d8bc2aed
commit 64b7644e5e
Signed by: ynerant
GPG Key ID: 3A75C55819C8CF85

View File

@ -4,7 +4,7 @@
from django.contrib.auth.models import User
from django_filters.rest_framework import DjangoFilterBackend
from rest_framework.filters import SearchFilter
from rest_framework.permissions import BasePermission, IsAuthenticated, SAFE_METHODS
from rest_framework.permissions import BasePermission, IsAdminUser, IsAuthenticated, SAFE_METHODS
from rest_framework.viewsets import ModelViewSet, ReadOnlyModelViewSet
from .serializers import BasicUserSerializer, PaymentSerializer, RegistrationSerializer
@ -34,7 +34,7 @@ class IsTournamentOrganizer(BasePermission):
class VolunteersViewSet(ReadOnlyModelViewSet):
queryset = User.objects.filter(registration__volunteerregistration__isnull=False)
serializer_class = BasicUserSerializer
permission_classes = [IsAuthenticated & IsTournamentOrganizer]
permission_classes = [IsAdminUser | (IsAuthenticated & IsTournamentOrganizer)]
filter_backends = [DjangoFilterBackend, SearchFilter]
filterset_fields = ['first_name', 'last_name', 'email', ]
search_fields = ['$first_name', '$last_name', '$email', ]