mirror of
https://git.v0id.ovh/n3wt-innov/n3wt-school.git
synced 2026-01-29 07:53:23 +00:00
refactor: Utilisation d'une application "Common" pour tous les modèles
de référence
This commit is contained in:
@ -16,10 +16,22 @@ import Subscriptions.util as util
|
||||
|
||||
from Subscriptions.serializers import RegistrationFormSerializer, RegistrationSchoolFileTemplateSerializer, RegistrationParentFileTemplateSerializer
|
||||
from Subscriptions.pagination import CustomSubscriptionPagination
|
||||
from Subscriptions.models import Student, Guardian, RegistrationForm, RegistrationSchoolFileTemplate, RegistrationFileGroup, RegistrationParentFileTemplate
|
||||
from Subscriptions.models import (
|
||||
Student,
|
||||
Guardian,
|
||||
RegistrationForm,
|
||||
RegistrationSchoolFileTemplate,
|
||||
RegistrationFileGroup,
|
||||
RegistrationParentFileTemplate,
|
||||
StudentCompetency
|
||||
)
|
||||
from Subscriptions.automate import updateStateMachine
|
||||
from Common.models import Competency
|
||||
|
||||
from N3wtSchool import settings, bdd
|
||||
from django.db.models import Q
|
||||
|
||||
|
||||
|
||||
import logging
|
||||
logger = logging.getLogger(__name__)
|
||||
@ -236,7 +248,6 @@ class RegisterFormWithIdView(APIView):
|
||||
studentForm_data = request.data.get('data', '{}')
|
||||
try:
|
||||
data = json.loads(studentForm_data)
|
||||
print(f'data : {data}')
|
||||
except json.JSONDecodeError:
|
||||
return JsonResponse({"error": "Invalid JSON format in 'data'"}, status=status.HTTP_400_BAD_REQUEST)
|
||||
|
||||
@ -366,6 +377,26 @@ class RegisterFormWithIdView(APIView):
|
||||
save=True
|
||||
)
|
||||
|
||||
# Valorisation des StudentCompetency pour l'élève
|
||||
try:
|
||||
student = registerForm.student
|
||||
cycle = None
|
||||
if student.level:
|
||||
cycle = student.level.cycle.number
|
||||
if cycle:
|
||||
competencies = Competency.objects.filter(
|
||||
category__domain__cycle=cycle
|
||||
).filter(
|
||||
Q(end_of_cycle=True) | Q(level=student.level.name)
|
||||
)
|
||||
for comp in competencies:
|
||||
StudentCompetency.objects.get_or_create(
|
||||
student=student,
|
||||
competency=comp
|
||||
)
|
||||
except Exception as e:
|
||||
logger.error(f"Erreur lors de la valorisation des StudentCompetency: {e}")
|
||||
|
||||
updateStateMachine(registerForm, 'EVENT_VALIDATE')
|
||||
|
||||
# Retourner les données mises à jour
|
||||
|
||||
Reference in New Issue
Block a user