mirror of
https://git.v0id.ovh/n3wt-innov/n3wt-school.git
synced 2026-04-04 04:01:27 +00:00
feat: Envoi mail d'inscription au second responsable [N3WTS-1]
This commit is contained in:
@ -323,6 +323,27 @@ class RegisterFormWithIdView(APIView):
|
||||
registerForm.registration_file = util.rfToPDF(registerForm, initial_pdf)
|
||||
registerForm.save()
|
||||
|
||||
# Envoi du mail d'inscription au second guardian si besoin
|
||||
guardians = registerForm.student.guardians.all()
|
||||
from Auth.models import Profile
|
||||
from N3wtSchool.mailManager import sendRegisterForm
|
||||
|
||||
for guardian in guardians:
|
||||
# Recherche de l'email dans le profil lié au guardian (si existant)
|
||||
email = None
|
||||
if hasattr(guardian, "profile_role") and guardian.profile_role and hasattr(guardian.profile_role, "profile") and guardian.profile_role.profile:
|
||||
email = guardian.profile_role.profile.email
|
||||
# Fallback sur le champ email direct (si jamais il existe)
|
||||
if not email:
|
||||
email = getattr(guardian, "email", None)
|
||||
logger.error(f"[RF_UNDER_REVIEW] Guardian id={guardian.id}, email={email}")
|
||||
if email:
|
||||
profile_exists = Profile.objects.filter(email=email).exists()
|
||||
logger.error(f"[RF_UNDER_REVIEW] Profile existe pour {email} ? {profile_exists}")
|
||||
if not profile_exists:
|
||||
logger.error(f"[RF_UNDER_REVIEW] Envoi du mail d'inscription à {email} pour l'établissement {registerForm.establishment.pk}")
|
||||
sendRegisterForm(email, registerForm.establishment.pk)
|
||||
|
||||
# Mise à jour de l'automate
|
||||
# Vérification de la présence du fichier SEPA
|
||||
if registerForm.sepa_file:
|
||||
@ -332,6 +353,9 @@ class RegisterFormWithIdView(APIView):
|
||||
# Mise à jour de l'automate pour une signature classique
|
||||
updateStateMachine(registerForm, 'EVENT_SIGNATURE')
|
||||
except Exception as e:
|
||||
logger.error(f"[RF_UNDER_REVIEW] Exception: {e}")
|
||||
import traceback
|
||||
logger.error(traceback.format_exc())
|
||||
return JsonResponse({'error': str(e)}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
|
||||
elif _status == RegistrationForm.RegistrationFormStatus.RF_SENT:
|
||||
if registerForm.status == RegistrationForm.RegistrationFormStatus.RF_UNDER_REVIEW:
|
||||
|
||||
Reference in New Issue
Block a user