fix: On ne peut sélectionner que les élèves inscrits [#16]

This commit is contained in:
N3WT DE COMPET
2025-05-20 18:50:19 +02:00
parent 4f40d1f29d
commit 56c223f3cc
3 changed files with 20 additions and 7 deletions

View File

@ -59,11 +59,18 @@ class StudentListView(APIView):
# Récupération de la liste des élèves inscrits ou en cours d'inscriptions
def get(self, request):
establishment_id = request.GET.get('establishment_id', None)
status_filter = request.GET.get('status', None) # Nouveau filtre optionnel
if establishment_id is None:
return JsonResponse({'error': 'establishment_id est requis'}, safe=False, status=status.HTTP_400_BAD_REQUEST)
students = Student.objects.filter(registrationform__establishment_id=establishment_id)
students_serializer = StudentByRFCreationSerializer(students, many=True)
students_qs = Student.objects.filter(registrationform__establishment_id=establishment_id)
if status_filter:
students_qs = students_qs.filter(registrationform__status=status_filter)
students_qs = students_qs.distinct()
students_serializer = StudentByRFCreationSerializer(students_qs, many=True)
return JsonResponse(students_serializer.data, safe=False)