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 aux enseignants [N3WTS-1]
This commit is contained in:
@ -35,6 +35,7 @@ from collections import defaultdict
|
||||
from Subscriptions.models import Student, StudentCompetency
|
||||
from Subscriptions.util import getCurrentSchoolYear
|
||||
import logging
|
||||
from N3wtSchool.mailManager import sendRegisterForm, sendRegisterTeacher
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@ -102,8 +103,17 @@ class TeacherListCreateView(APIView):
|
||||
teacher_serializer = TeacherSerializer(data=teacher_data)
|
||||
|
||||
if teacher_serializer.is_valid():
|
||||
teacher_serializer.save()
|
||||
|
||||
teacher_instance = teacher_serializer.save()
|
||||
# Envoi du mail d'inscription enseignant uniquement à la création
|
||||
email = None
|
||||
establishment_id = None
|
||||
if hasattr(teacher_instance, "profile_role") and teacher_instance.profile_role:
|
||||
if hasattr(teacher_instance.profile_role, "profile") and teacher_instance.profile_role.profile:
|
||||
email = teacher_instance.profile_role.profile.email
|
||||
if hasattr(teacher_instance.profile_role, "establishment") and teacher_instance.profile_role.establishment:
|
||||
establishment_id = teacher_instance.profile_role.establishment.id
|
||||
if email and establishment_id:
|
||||
sendRegisterTeacher(email, establishment_id)
|
||||
return JsonResponse(teacher_serializer.data, safe=False)
|
||||
|
||||
return JsonResponse(teacher_serializer.errors, safe=False)
|
||||
|
||||
Reference in New Issue
Block a user