mirror of
https://git.v0id.ovh/n3wt-innov/n3wt-school.git
synced 2026-04-05 12:41:27 +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 .serializers import PlanningSerializer, EventsSerializer
|
||||||
|
|
||||||
from N3wtSchool import bdd
|
from N3wtSchool import bdd
|
||||||
|
from Subscriptions.util import getCurrentSchoolYear
|
||||||
|
|
||||||
|
|
||||||
class PlanningView(APIView):
|
class PlanningView(APIView):
|
||||||
@ -17,6 +18,7 @@ class PlanningView(APIView):
|
|||||||
def get(self, request):
|
def get(self, request):
|
||||||
establishment_id = request.GET.get('establishment_id', None)
|
establishment_id = request.GET.get('establishment_id', None)
|
||||||
planning_mode = request.GET.get('planning_mode', None)
|
planning_mode = request.GET.get('planning_mode', None)
|
||||||
|
current_school_year = getCurrentSchoolYear()
|
||||||
|
|
||||||
plannings = bdd.getAllObjects(Planning)
|
plannings = bdd.getAllObjects(Planning)
|
||||||
|
|
||||||
@ -25,7 +27,10 @@ class PlanningView(APIView):
|
|||||||
|
|
||||||
# Filtrer en fonction du planning_mode
|
# Filtrer en fonction du planning_mode
|
||||||
if planning_mode == "classSchedule":
|
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":
|
elif planning_mode == "planning":
|
||||||
plannings = plannings.filter(school_class__isnull=True)
|
plannings = plannings.filter(school_class__isnull=True)
|
||||||
|
|
||||||
@ -79,6 +84,7 @@ class EventsView(APIView):
|
|||||||
def get(self, request):
|
def get(self, request):
|
||||||
establishment_id = request.GET.get('establishment_id', None)
|
establishment_id = request.GET.get('establishment_id', None)
|
||||||
planning_mode = request.GET.get('planning_mode', None)
|
planning_mode = request.GET.get('planning_mode', None)
|
||||||
|
current_school_year = getCurrentSchoolYear()
|
||||||
filterParams = {}
|
filterParams = {}
|
||||||
plannings=[]
|
plannings=[]
|
||||||
events = Events.objects.all()
|
events = Events.objects.all()
|
||||||
@ -86,6 +92,8 @@ class EventsView(APIView):
|
|||||||
filterParams['establishment'] = establishment_id
|
filterParams['establishment'] = establishment_id
|
||||||
if planning_mode is not None:
|
if planning_mode is not None:
|
||||||
filterParams['school_class__isnull'] = (planning_mode!="classSchedule")
|
filterParams['school_class__isnull'] = (planning_mode!="classSchedule")
|
||||||
|
if planning_mode == "classSchedule":
|
||||||
|
filterParams['school_class__school_year'] = current_school_year
|
||||||
if filterParams:
|
if filterParams:
|
||||||
plannings = Planning.objects.filter(**filterParams)
|
plannings = Planning.objects.filter(**filterParams)
|
||||||
events = Events.objects.filter(planning__in=plannings)
|
events = Events.objects.filter(planning__in=plannings)
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
'use client';
|
'use client';
|
||||||
import React, { useState, useEffect } from 'react';
|
import React, { useState, useEffect } from 'react';
|
||||||
|
import { getCurrentSchoolYear } from '@/utils/Date';
|
||||||
|
|
||||||
import StructureManagement from '@/components/Structure/Configuration/StructureManagement';
|
import StructureManagement from '@/components/Structure/Configuration/StructureManagement';
|
||||||
import ScheduleManagement from '@/components/Structure/Planning/ScheduleManagement';
|
import ScheduleManagement from '@/components/Structure/Planning/ScheduleManagement';
|
||||||
@ -54,6 +55,17 @@ export default function Page() {
|
|||||||
|
|
||||||
const csrfToken = useCsrfToken();
|
const csrfToken = useCsrfToken();
|
||||||
const { selectedEstablishmentId, profileRole } = useEstablishment();
|
const { selectedEstablishmentId, profileRole } = useEstablishment();
|
||||||
|
const currentSchoolYear = getCurrentSchoolYear();
|
||||||
|
|
||||||
|
const scheduleClasses = classes.filter(
|
||||||
|
(classe) => classe?.school_year === currentSchoolYear
|
||||||
|
);
|
||||||
|
const scheduleSpecialities = specialities.filter(
|
||||||
|
(speciality) => speciality?.school_year === currentSchoolYear
|
||||||
|
);
|
||||||
|
const scheduleTeachers = teachers.filter(
|
||||||
|
(teacher) => teacher?.school_year === currentSchoolYear
|
||||||
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (selectedEstablishmentId) {
|
if (selectedEstablishmentId) {
|
||||||
@ -299,9 +311,9 @@ export default function Page() {
|
|||||||
<ClassesProvider>
|
<ClassesProvider>
|
||||||
<ScheduleManagement
|
<ScheduleManagement
|
||||||
handleUpdatePlanning={handleUpdatePlanning}
|
handleUpdatePlanning={handleUpdatePlanning}
|
||||||
classes={classes}
|
classes={scheduleClasses}
|
||||||
specialities={specialities}
|
specialities={scheduleSpecialities}
|
||||||
teachers={teachers}
|
teachers={scheduleTeachers}
|
||||||
/>
|
/>
|
||||||
</ClassesProvider>
|
</ClassesProvider>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user