diff --git a/Back-End/Establishment/views.py b/Back-End/Establishment/views.py index 2e0b23c..ab5eedf 100644 --- a/Back-End/Establishment/views.py +++ b/Back-End/Establishment/views.py @@ -6,11 +6,12 @@ from rest_framework.views import APIView from rest_framework import status from .models import Establishment from .serializers import EstablishmentSerializer -from N3wtSchool.bdd import delete_object, getAllObjects +from N3wtSchool.bdd import delete_object, getAllObjects, getObject from School.models import EstablishmentCompetency, Competency from django.db.models import Q from Auth.models import Profile, ProfileRole, Directeur from Settings.models import SMTPSettings +import N3wtSchool.mailManager as mailer @method_decorator(csrf_protect, name='dispatch') @method_decorator(ensure_csrf_cookie, name='dispatch') @@ -97,7 +98,7 @@ def create_establishment_with_directeur(establishment_data): profile=profile, establishment=establishment, role_type=ProfileRole.RoleType.PROFIL_ADMIN, - defaults={"is_active": True} + defaults={"is_active": False} ) # Création ou mise à jour du Directeur lié à ce ProfileRole @@ -114,4 +115,6 @@ def create_establishment_with_directeur(establishment_data): smtp_settings_data["establishment"] = establishment SMTPSettings.objects.create(**smtp_settings_data) + # Envoi du mail + mailer.sendRegistrationDirector(directeur_email, establishment.pk) return establishment, establishment_serializer.data \ No newline at end of file diff --git a/Back-End/N3wtSchool/mailManager.py b/Back-End/N3wtSchool/mailManager.py index 6e36695..a94c83a 100644 --- a/Back-End/N3wtSchool/mailManager.py +++ b/Back-End/N3wtSchool/mailManager.py @@ -101,6 +101,26 @@ def envoieReinitMotDePasse(recipients, code): return errorMessage +def sendRegistrationDirector(recipients, establishment_id): + errorMessage = '' + try: + # Préparation du contexte pour le template + EMAIL_INSCRIPTION_SUBJECT = '[N3WT-SCHOOL] Bienvenue dans la communauté !' + context = { + 'BASE_URL': settings.BASE_URL, + 'email': recipients, + 'establishment': establishment_id + } + subject = EMAIL_INSCRIPTION_SUBJECT + html_message = render_to_string('emails/subscribeDirector.html', context) + sendMail(subject=subject, message=html_message, recipients=recipients) + + + except Exception as e: + errorMessage = str(e) + + return errorMessage + def sendRegisterForm(recipients, establishment_id): errorMessage = '' diff --git a/Back-End/Subscriptions/templates/emails/subscribeDirector.html b/Back-End/Subscriptions/templates/emails/subscribeDirector.html new file mode 100644 index 0000000..f04d71f --- /dev/null +++ b/Back-End/Subscriptions/templates/emails/subscribeDirector.html @@ -0,0 +1,54 @@ + + + + + Confirmation de souscription + + + +
+
+

Confirmation de souscription

+
+
+

Bonjour,

+

Nous sommes ravis de vous compter parmi les utilisateurs de N3wt School et vous remercions pour votre confiance

+

Vous trouverez ci-joint le lien vers la page d'authentification : {{BASE_URL}}/users/login

+

S'il s'agit de votre première connexion, veuillez procéder à l'activation de votre compte à cette url : {{BASE_URL}}/users/subscribe

+

votre identifiant est : {{ email }}

+

Notre équipe est à votre disposition pour vous aider à tirer pleinement parti des fonctionnalités offertes par Newt School.

+

N'hésitez pas à nous contacter pour toute question ou besoin d'assistance.

+

Cordialement,

+

L'équipe N3wt School

+
+ +
+ + \ No newline at end of file