mirror of
https://git.v0id.ovh/n3wt-innov/n3wt-school.git
synced 2026-01-29 07:53:23 +00:00
fix: On ne peut sélectionner que les élèves inscrits [#16]
This commit is contained in:
@ -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)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user