mirror of
https://git.v0id.ovh/n3wt-innov/n3wt-school.git
synced 2026-01-28 23:43:22 +00:00
feat: Gestion de la sauvegarde du fichier d'inscription / affichage du
fichier avec le bon nom / possibilité de refuser un DI
This commit is contained in:
@ -4,10 +4,12 @@ from rest_framework.views import APIView
|
||||
from drf_yasg.utils import swagger_auto_schema
|
||||
from drf_yasg import openapi
|
||||
|
||||
from Subscriptions.models import Guardian, Student
|
||||
from Subscriptions.models import Guardian, Student, RegistrationForm
|
||||
from Auth.models import ProfileRole
|
||||
from N3wtSchool import bdd
|
||||
|
||||
import Subscriptions.util as util
|
||||
|
||||
class GuardianView(APIView):
|
||||
"""
|
||||
Gestion des responsables légaux.
|
||||
@ -74,6 +76,16 @@ class DissociateGuardianView(APIView):
|
||||
# Supprimer le guardian
|
||||
guardian.delete()
|
||||
|
||||
# Récupérer le RegistrationForm associé au Student
|
||||
registerForm = bdd.getObject(RegistrationForm, "student__id", student_id)
|
||||
if registerForm:
|
||||
# Réinitialiser le statut en "Créé"
|
||||
registerForm.status = RegistrationForm.RegistrationFormStatus.RF_CREATED
|
||||
registerForm.save()
|
||||
|
||||
# Supprimer le fichier et le dossier associés
|
||||
util.delete_registration_files(registerForm)
|
||||
|
||||
return JsonResponse(
|
||||
{
|
||||
"message": f"Le guardian {guardian.last_name} {guardian.first_name} a été dissocié de l'étudiant {student.last_name} {student.first_name}.",
|
||||
|
||||
@ -238,7 +238,7 @@ class RegisterFormWithIdView(APIView):
|
||||
if _status == RegistrationForm.RegistrationFormStatus.RF_UNDER_REVIEW:
|
||||
try:
|
||||
# Génération de la fiche d'inscription au format PDF
|
||||
base_dir = f"data/registration_files/dossier_rf_{registerForm.pk}"
|
||||
base_dir = f"registration_files/dossier_rf_{registerForm.pk}"
|
||||
os.makedirs(base_dir, exist_ok=True)
|
||||
|
||||
# Fichier PDF initial
|
||||
@ -248,11 +248,13 @@ class RegisterFormWithIdView(APIView):
|
||||
|
||||
# Récupération des fichiers d'inscription
|
||||
fileNames = RegistrationTemplate.get_files_from_rf(registerForm.pk)
|
||||
|
||||
if registerForm.registration_file:
|
||||
fileNames.insert(0, registerForm.registration_file.path)
|
||||
|
||||
# Création du fichier PDF Fusionné
|
||||
merged_pdf = f"{base_dir}/dossier_complet_{registerForm.pk}.pdf"
|
||||
|
||||
util.merge_files_pdf(fileNames, merged_pdf)
|
||||
|
||||
# Mise à jour du champ registration_file avec le fichier fusionné
|
||||
@ -271,6 +273,14 @@ class RegisterFormWithIdView(APIView):
|
||||
# L'école a validé le dossier d'inscription
|
||||
# Mise à jour de l'automate
|
||||
updateStateMachine(registerForm, 'valideDI')
|
||||
elif _status == RegistrationForm.RegistrationFormStatus.RF_SENT:
|
||||
# Vérifier si l'étape précédente était RF_UNDER_REVIEW
|
||||
if registerForm.status == RegistrationForm.RegistrationFormStatus.RF_UNDER_REVIEW:
|
||||
# Mise à jour de l'automate
|
||||
updateStateMachine(registerForm, 'refuseDI')
|
||||
|
||||
# Supprimer le fichier et le dossier associés
|
||||
util.delete_registration_files(registerForm)
|
||||
|
||||
studentForm_serializer = RegistrationFormSerializer(registerForm, data=studentForm_data)
|
||||
if studentForm_serializer.is_valid():
|
||||
|
||||
Reference in New Issue
Block a user