mirror of
https://git.v0id.ovh/n3wt-innov/n3wt-school.git
synced 2026-04-03 16:51:26 +00:00
feat: Envoi mail d'inscription au second responsable [N3WTS-1]
This commit is contained in:
@ -21,6 +21,7 @@ from N3wtSchool import settings
|
|||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
import pytz
|
import pytz
|
||||||
import Subscriptions.util as util
|
import Subscriptions.util as util
|
||||||
|
from N3wtSchool.mailManager import sendRegisterForm
|
||||||
|
|
||||||
class AbsenceManagementSerializer(serializers.ModelSerializer):
|
class AbsenceManagementSerializer(serializers.ModelSerializer):
|
||||||
student_name = serializers.SerializerMethodField()
|
student_name = serializers.SerializerMethodField()
|
||||||
@ -215,6 +216,14 @@ class StudentSerializer(serializers.ModelSerializer):
|
|||||||
profile_role_serializer = ProfileRoleSerializer(data=profile_role_data)
|
profile_role_serializer = ProfileRoleSerializer(data=profile_role_data)
|
||||||
profile_role_serializer.is_valid(raise_exception=True)
|
profile_role_serializer.is_valid(raise_exception=True)
|
||||||
profile_role = profile_role_serializer.save()
|
profile_role = profile_role_serializer.save()
|
||||||
|
# Envoi du mail d'inscription si un nouveau profil vient d'être créé
|
||||||
|
email = None
|
||||||
|
if profile_data and 'email' in profile_data:
|
||||||
|
email = profile_data['email']
|
||||||
|
elif profile_role and profile_role.profile:
|
||||||
|
email = profile_role.profile.email
|
||||||
|
if email:
|
||||||
|
sendRegisterForm(email, establishment_id)
|
||||||
elif profile_role:
|
elif profile_role:
|
||||||
# Récupérer un ProfileRole existant par son ID
|
# Récupérer un ProfileRole existant par son ID
|
||||||
profile_role = ProfileRole.objects.get(id=profile_role.id)
|
profile_role = ProfileRole.objects.get(id=profile_role.id)
|
||||||
|
|||||||
@ -323,6 +323,27 @@ class RegisterFormWithIdView(APIView):
|
|||||||
registerForm.registration_file = util.rfToPDF(registerForm, initial_pdf)
|
registerForm.registration_file = util.rfToPDF(registerForm, initial_pdf)
|
||||||
registerForm.save()
|
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
|
# Mise à jour de l'automate
|
||||||
# Vérification de la présence du fichier SEPA
|
# Vérification de la présence du fichier SEPA
|
||||||
if registerForm.sepa_file:
|
if registerForm.sepa_file:
|
||||||
@ -332,6 +353,9 @@ class RegisterFormWithIdView(APIView):
|
|||||||
# Mise à jour de l'automate pour une signature classique
|
# Mise à jour de l'automate pour une signature classique
|
||||||
updateStateMachine(registerForm, 'EVENT_SIGNATURE')
|
updateStateMachine(registerForm, 'EVENT_SIGNATURE')
|
||||||
except Exception as e:
|
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)
|
return JsonResponse({'error': str(e)}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
|
||||||
elif _status == RegistrationForm.RegistrationFormStatus.RF_SENT:
|
elif _status == RegistrationForm.RegistrationFormStatus.RF_SENT:
|
||||||
if registerForm.status == RegistrationForm.RegistrationFormStatus.RF_UNDER_REVIEW:
|
if registerForm.status == RegistrationForm.RegistrationFormStatus.RF_UNDER_REVIEW:
|
||||||
|
|||||||
@ -77,7 +77,7 @@ export default function InscriptionFormShared({
|
|||||||
const [parentFileTemplates, setParentFileTemplates] = useState([]);
|
const [parentFileTemplates, setParentFileTemplates] = useState([]);
|
||||||
const [schoolFileMasters, setSchoolFileMasters] = useState([]);
|
const [schoolFileMasters, setSchoolFileMasters] = useState([]);
|
||||||
const [formResponses, setFormResponses] = useState({});
|
const [formResponses, setFormResponses] = useState({});
|
||||||
const [currentPage, setCurrentPage] = useState(5);
|
const [currentPage, setCurrentPage] = useState(1);
|
||||||
|
|
||||||
const [isPage1Valid, setIsPage1Valid] = useState(false);
|
const [isPage1Valid, setIsPage1Valid] = useState(false);
|
||||||
const [isPage2Valid, setIsPage2Valid] = useState(false);
|
const [isPage2Valid, setIsPage2Valid] = useState(false);
|
||||||
|
|||||||
@ -100,7 +100,7 @@ export default function ResponsableInputFields({
|
|||||||
profile_role_data: {
|
profile_role_data: {
|
||||||
establishment: selectedEstablishmentId,
|
establishment: selectedEstablishmentId,
|
||||||
role_type: 2,
|
role_type: 2,
|
||||||
is_active: true,
|
is_active: false,
|
||||||
profile_data: {
|
profile_data: {
|
||||||
email: '',
|
email: '',
|
||||||
password: 'Provisoire01!',
|
password: 'Provisoire01!',
|
||||||
|
|||||||
Reference in New Issue
Block a user