mirror of
https://git.v0id.ovh/n3wt-innov/n3wt-school.git
synced 2026-01-28 15:33:22 +00:00
feat: Envoie d'un mail de bienvue au directeur
This commit is contained in:
@ -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
|
||||
@ -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 = ''
|
||||
|
||||
@ -0,0 +1,54 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Confirmation de souscription</title>
|
||||
<style>
|
||||
body {
|
||||
font-family: Arial, sans-serif;
|
||||
line-height: 1.6;
|
||||
color: #333;
|
||||
}
|
||||
.container {
|
||||
max-width: 600px;
|
||||
margin: 0 auto;
|
||||
padding: 20px;
|
||||
}
|
||||
.header {
|
||||
background-color: #f4f4f4;
|
||||
padding: 10px;
|
||||
text-align: center;
|
||||
}
|
||||
.content {
|
||||
padding: 20px;
|
||||
}
|
||||
.footer {
|
||||
font-size: 12px;
|
||||
text-align: center;
|
||||
margin-top: 30px;
|
||||
color: #777;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="header">
|
||||
<h1>Confirmation de souscription</h1>
|
||||
</div>
|
||||
<div class="content">
|
||||
<p>Bonjour,</p>
|
||||
<p>Nous sommes ravis de vous compter parmi les utilisateurs de N3wt School et vous remercions pour votre confiance</p>
|
||||
<p>Vous trouverez ci-joint le lien vers la page d'authentification : <a href="{{BASE_URL}}/users/login">{{BASE_URL}}/users/login</a></p>
|
||||
<p>S'il s'agit de votre première connexion, veuillez procéder à l'activation de votre compte à cette url : <a href="{{BASE_URL}}/users/subscribe?establishment_id={{establishment}}">{{BASE_URL}}/users/subscribe</a></p>
|
||||
<p>votre identifiant est : {{ email }}</p>
|
||||
<p>Notre équipe est à votre disposition pour vous aider à tirer pleinement parti des fonctionnalités offertes par Newt School.</p>
|
||||
<p>N'hésitez pas à nous contacter pour toute question ou besoin d'assistance.</p>
|
||||
<p>Cordialement,</p>
|
||||
<p>L'équipe N3wt School</p>
|
||||
</div>
|
||||
<div class="footer">
|
||||
<p>Ce message est généré automatiquement, merci de ne pas y répondre.</p>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user