mirror of
https://git.v0id.ovh/n3wt-innov/n3wt-school.git
synced 2026-04-05 20:51:26 +00:00
fix: Emploi du temps pour les classes de l'année scolaire en cours
This commit is contained in:
@ -9,6 +9,7 @@ from .models import Planning, Events, RecursionType
|
||||
from .serializers import PlanningSerializer, EventsSerializer
|
||||
|
||||
from N3wtSchool import bdd
|
||||
from Subscriptions.util import getCurrentSchoolYear
|
||||
|
||||
|
||||
class PlanningView(APIView):
|
||||
@ -17,6 +18,7 @@ class PlanningView(APIView):
|
||||
def get(self, request):
|
||||
establishment_id = request.GET.get('establishment_id', None)
|
||||
planning_mode = request.GET.get('planning_mode', None)
|
||||
current_school_year = getCurrentSchoolYear()
|
||||
|
||||
plannings = bdd.getAllObjects(Planning)
|
||||
|
||||
@ -25,7 +27,10 @@ class PlanningView(APIView):
|
||||
|
||||
# Filtrer en fonction du planning_mode
|
||||
if planning_mode == "classSchedule":
|
||||
plannings = plannings.filter(school_class__isnull=False)
|
||||
plannings = plannings.filter(
|
||||
school_class__isnull=False,
|
||||
school_class__school_year=current_school_year,
|
||||
)
|
||||
elif planning_mode == "planning":
|
||||
plannings = plannings.filter(school_class__isnull=True)
|
||||
|
||||
@ -79,6 +84,7 @@ class EventsView(APIView):
|
||||
def get(self, request):
|
||||
establishment_id = request.GET.get('establishment_id', None)
|
||||
planning_mode = request.GET.get('planning_mode', None)
|
||||
current_school_year = getCurrentSchoolYear()
|
||||
filterParams = {}
|
||||
plannings=[]
|
||||
events = Events.objects.all()
|
||||
@ -86,6 +92,8 @@ class EventsView(APIView):
|
||||
filterParams['establishment'] = establishment_id
|
||||
if planning_mode is not None:
|
||||
filterParams['school_class__isnull'] = (planning_mode!="classSchedule")
|
||||
if planning_mode == "classSchedule":
|
||||
filterParams['school_class__school_year'] = current_school_year
|
||||
if filterParams:
|
||||
plannings = Planning.objects.filter(**filterParams)
|
||||
events = Events.objects.filter(planning__in=plannings)
|
||||
|
||||
Reference in New Issue
Block a user