mirror of
https://git.v0id.ovh/n3wt-innov/n3wt-school.git
synced 2026-01-29 07:53:23 +00:00
74 lines
2.1 KiB
Python
74 lines
2.1 KiB
Python
from django.core.mail import send_mail
|
|
import re
|
|
from N3wtSchool import settings
|
|
|
|
def envoieReinitMotDePasse(recipients, code):
|
|
send_mail(
|
|
settings.EMAIL_REINIT_SUBJECT,
|
|
settings.EMAIL_REINIT_CORPUS%(str(code)),
|
|
settings.EMAIL_HOST_USER,
|
|
[recipients],
|
|
fail_silently=False,
|
|
)
|
|
|
|
def sendRegisterForm(recipients):
|
|
errorMessage = ''
|
|
try:
|
|
print(f'{settings.EMAIL_HOST_USER}')
|
|
send_mail(
|
|
settings.EMAIL_INSCRIPTION_SUBJECT,
|
|
settings.EMAIL_INSCRIPTION_CORPUS%[recipients],
|
|
settings.EMAIL_HOST_USER,
|
|
[recipients],
|
|
fail_silently=False,
|
|
)
|
|
except Exception as e:
|
|
errorMessage = str(e)
|
|
|
|
return errorMessage
|
|
|
|
def envoieRelanceDossierInscription(recipients, code):
|
|
errorMessage = ''
|
|
try:
|
|
send_mail(
|
|
settings.EMAIL_RELANCE_SUBJECT,
|
|
settings.EMAIL_RELANCE_CORPUS%str(code),
|
|
settings.EMAIL_HOST_USER,
|
|
[recipients],
|
|
fail_silently=False,
|
|
)
|
|
except Exception as e:
|
|
errorMessage = str(e)
|
|
|
|
return errorMessage
|
|
|
|
|
|
def envoieSEPA(recipients, ref):
|
|
send_mail(
|
|
settings.EMAIL_SEPA_SUBJECT%str(ref),
|
|
settings.EMAIL_SEPA_CORPUS,
|
|
settings.EMAIL_HOST_USER,
|
|
[recipients],
|
|
fail_silently=False,
|
|
)
|
|
|
|
def isValid(message, fiche_inscription):
|
|
# Est-ce que la référence du dossier est VALIDE
|
|
subject = message.subject
|
|
print ("++++ " + subject)
|
|
responsableMail = message.from_header
|
|
result = re.search('<(.*)>', responsableMail)
|
|
|
|
if result:
|
|
responsableMail = result.group(1)
|
|
|
|
result = re.search(r'.*\[Ref(.*)\].*', subject)
|
|
idMail = -1
|
|
if result:
|
|
idMail = result.group(1).strip()
|
|
|
|
eleve = fiche_inscription.eleve
|
|
responsable = eleve.getMainGuardian()
|
|
mailReponsableAVerifier = responsable.mail
|
|
|
|
return responsableMail == mailReponsableAVerifier and str(idMail) == str(fiche_inscription.eleve.id) |