26/10/22 - 18h
parent
3e34531a14
commit
95381744bc
|
@ -193,4 +193,10 @@ LIMIT_ASSOCIATED_TRAINING = 3
|
|||
"""
|
||||
Valeur MAX du display ranking accordé aux compte de type demo
|
||||
"""
|
||||
DEMO_RANKING_VALUE = "50"
|
||||
DEMO_RANKING_VALUE = "50"
|
||||
|
||||
|
||||
"""
|
||||
Sendinblu compte support
|
||||
"""
|
||||
SENDINBLUE_API_KEY_SUPPORT = "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"
|
|
@ -18,6 +18,7 @@ import GlobalVariable as MYSY_GV
|
|||
from math import isnan
|
||||
import GlobalVariable as MYSY_GV
|
||||
from datetime import timedelta
|
||||
import email_inscription_mgt as email_session
|
||||
|
||||
|
||||
"""
|
||||
|
@ -213,18 +214,22 @@ def UpdateStagiairetoClass(diction):
|
|||
|
||||
|
||||
mydata = {}
|
||||
user_nom = ""
|
||||
|
||||
if ("nom" in diction.keys()):
|
||||
if diction['nom']:
|
||||
mydata['nom'] = diction['nom']
|
||||
user_nom = diction['nom']
|
||||
|
||||
if ("price" in diction.keys()):
|
||||
if diction['price']:
|
||||
mydata['price'] = diction['price']
|
||||
|
||||
user_prenom = ""
|
||||
if ("prenom" in diction.keys()):
|
||||
if diction['prenom']:
|
||||
mydata['prenom'] = diction['prenom']
|
||||
user_prenom = diction['prenom']
|
||||
|
||||
if ("telephone" in diction.keys()):
|
||||
if diction['telephone']:
|
||||
|
@ -257,8 +262,54 @@ def UpdateStagiairetoClass(diction):
|
|||
)
|
||||
|
||||
if (ret_val2 and ret_val2['_id']):
|
||||
mycommon.myprint(" Les données du stagiaire ont été correctement mise à jour")
|
||||
return True, "Les données du stagiaire ont été correctement mise à jour"
|
||||
|
||||
"""
|
||||
Si le status == 1; alors il s'agit d'une validation d'une inscription.
|
||||
Du coup, il faut envoyer le mail de confirmation de l'inscription:
|
||||
1 - recuperation des infos de la session
|
||||
1 BIS - recuperation du title
|
||||
2 - Envoie de l'email
|
||||
"""
|
||||
email_data = {}
|
||||
email_data['nom'] = user_nom
|
||||
email_data['prenom'] = user_prenom
|
||||
email_data['email'] = myemail
|
||||
|
||||
# ici recup du titre
|
||||
for local_tmp_myclass in MYSY_GV.dbname['myclass'].find(
|
||||
{'internal_url': str(myinternal_url)}):
|
||||
|
||||
local_title = ""
|
||||
if ("title" in local_tmp_myclass.keys() and local_tmp_myclass['title']):
|
||||
local_title = local_tmp_myclass['title']
|
||||
email_data['title'] = local_title
|
||||
|
||||
# ici recup des infos de la session
|
||||
local_query = {'formation_session_id':str(mysession_id)}
|
||||
print("### local_query = "+str(local_query))
|
||||
|
||||
for local_tmp_session in MYSY_GV.dbname['session_formation'].find(local_query):
|
||||
local_date_du = ""
|
||||
if ("date_debut" in local_tmp_session.keys() and local_tmp_session['date_debut']):
|
||||
local_date_du = local_tmp_session['date_debut']
|
||||
email_data['date_du'] = local_date_du
|
||||
|
||||
local_date_au = ""
|
||||
if ("date_fin" in local_tmp_session.keys() and local_tmp_session['date_fin']):
|
||||
local_date_au = local_tmp_session['date_fin']
|
||||
email_data['date_au'] = local_date_au
|
||||
|
||||
adresse = ""
|
||||
if ("adresse" in local_tmp_session.keys() and local_tmp_session['adresse']):
|
||||
local_adresse = local_tmp_session['adresse']
|
||||
email_data['adresse'] = local_adresse
|
||||
|
||||
|
||||
local_status, local_message = email_session.incription_training_confirmation_mail(email_data)
|
||||
|
||||
|
||||
mycommon.myprint(" Les données du stagiaire ont été correctement mise à jour")
|
||||
return True, "Les données du stagiaire ont été correctement mise à jour"
|
||||
else:
|
||||
mycommon.myprint(" Impossible de mettre à jour les données du stagiaire 1")
|
||||
return False, "Impossible de mettre à jour les données du stagiaire "
|
||||
|
@ -387,3 +438,27 @@ def GetAllClassStagiaire(diction):
|
|||
return False, "Impossible de recuperer la liste des stagiaires de la formation"
|
||||
|
||||
|
||||
"""
|
||||
Cette fonction envoie l'email de confirmation d'une inscription a une formation.
|
||||
|
||||
Ceci est mis en "mode function" pour permettre aux utilisateur de renvoyer
|
||||
autant de fois que soihaité la confirmation d'inscription
|
||||
"""
|
||||
def SendInscriptionConfirmation(diction):
|
||||
try:
|
||||
"""
|
||||
Verification de la liste des champs obligatoires
|
||||
"""
|
||||
field_list_obligatoire = ['token', 'email', 'class_internal_url', 'session_id']
|
||||
for val in field_list_obligatoire:
|
||||
if val not in diction:
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " - : La valeur '" + val + "' n'est pas presente dans liste ")
|
||||
return False, "Impossible d'envoyer la confirmation d'inscription"
|
||||
|
||||
return True, "La confirmation d'inscription a bien ete envoyée"
|
||||
|
||||
except Exception as e:
|
||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
|
||||
return False, "Impossible d'envoyer la confirmation d'inscription"
|
||||
|
|
|
@ -0,0 +1,118 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body style="padding:20px 20px;padding-top:0px">
|
||||
<div style="padding:0px;text-align:left;width:30%">
|
||||
<img src="http://88.170.110.220/img/MYSY-LOGO-BLUE.png" alt="Mysy Training Logo" width="100px" /> </h2>
|
||||
</div>
|
||||
<div style="padding:0px;text-align:left;font-family:Georgia, 'Times New Roman', Times, serif;color:#454349;font-size:1.5rem;padding: 0px">
|
||||
<div style="width:100%">
|
||||
<div style="text-align:center;">
|
||||
<nav style="text-align:center;font-weight: bold;"> Facture </nav>
|
||||
<hr />
|
||||
<div style="padding:12px 0px;text-align:right;font-family:Georgia, 'Times New Roman', Times, serif;color#454349;font-size:0.9rem;">
|
||||
{{json_data.client_name}}<br/>
|
||||
{{json_data.client_address}}<br/>
|
||||
{{json_data.client_zip_ville}}<br/>
|
||||
{{json_data.client_pays}}<br/>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div style="padding:12px 0px;text-align:center;font-family:Georgia, 'Times New Roman', Times, serif;color#454349;font-size:0.9rem;font-weight: bold;">
|
||||
|
||||
Facture n° {{json_data.invoice_id}}
|
||||
|
||||
|
||||
</div>
|
||||
<br/>
|
||||
|
||||
|
||||
<table style="width:100%;padding: 5px;">
|
||||
|
||||
<tr style="padding: 0px; padding-top:5px;font-size:0.9rem;">
|
||||
<td style="text-align:left;">Date de facture: {{json_data.invoice_date}} </td>
|
||||
<td style="text-align:right;">Date échéance : {{json_data.due_date}}</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
||||
<div style="padding:12px 0px;text-align:left;font-family:Georgia, 'Times New Roman', Times, serif;color:#454349;font-size:0.9rem;width:100%;float:right;text-align:left;">Origine : {{json_data.orign_order}}
|
||||
</div>
|
||||
|
||||
<div> </div>
|
||||
<div style="padding:12px 0px;text-align:left;font-family:Georgia, 'Times New Roman', Times, serif;color:#454349;font-size:0.9rem;width:100%;float:right;text-align:left;">
|
||||
<table style="width:100%;border: 1px solid black;padding: 0px;">
|
||||
<tr style="border: 1px solid black;padding: 0px; padding-top:5px;">
|
||||
<th style="text-align:center;border: 1px solid black;">Description</th>
|
||||
<th style="text-align:center;border: 1px solid black;">Quantité</th>
|
||||
<th style="text-align:center;border: 1px solid black;">Prix unitaire</th>
|
||||
<th style="text-align:center;border: 1px solid black;">Montant</th>
|
||||
</tr>
|
||||
<tr style="border: 1px solid black;padding: 0px;padding: 0px; padding-top:5px;">
|
||||
<td style="text-align:center;border: 1px solid black;">{{json_data.packs}}</td>
|
||||
<td style="text-align:center;border: 1px solid black;">{{json_data.qty}}</td>
|
||||
<td style="text-align:center;border: 1px solid black;">{{json_data.unit_price}}</td>
|
||||
<td style="text-align:center;border: 1px solid black;">{{json_data.montant}}</td>
|
||||
</tr>
|
||||
<tr style="border: 1px solid black;">
|
||||
<td style="text-align:center;border: 1px solid black;">{{json_data.packs1}}</td>
|
||||
<td style="text-align:center;border: 1px solid black;">{{json_data.qty1}}</td>
|
||||
<td style="text-align:center;border: 1px solid black;">{{json_data.unit_price1}}</td>
|
||||
<td style="text-align:center;border: 1px solid black;">{{json_data.montant1}}</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div> </div>
|
||||
|
||||
</div>
|
||||
|
||||
<table style="width:100%;padding: 5px;float:right;padding:0px;">
|
||||
<tr style="padding: 0px; padding-top:5px;font-size:0.9rem;">
|
||||
<td style="text-align:left;"> </td>
|
||||
<td style="text-align:left;"> </td>
|
||||
<td style="text-align:center;">Montant HT: </td>
|
||||
<td style="text-align:center;">{{json_data.total_ht}}</td>
|
||||
</tr>
|
||||
|
||||
<tr style="padding:0px; padding-top:5px;font-size:0.9rem;">
|
||||
<td style="text-align:left;"> </td>
|
||||
<td style="text-align:left;"> </td>
|
||||
<td style="text-align:center;">TVA 20% : </td>
|
||||
<td style="text-align:center;">{{json_data.tva}}</td>
|
||||
</tr>
|
||||
|
||||
<tr style="padding:0px; padding-top:5px;font-size:0.9rem;">
|
||||
<td style="text-align:left;"> </td>
|
||||
<td style="text-align:left;"> </td>
|
||||
<td style="text-align:center;">Montant TTC : </td>
|
||||
<td style="text-align:center;">{{json_data.total_ttc}}</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
||||
<br/>
|
||||
<div> </div>
|
||||
<div> </div>
|
||||
<div style="height:15rem;"> </div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<hr />
|
||||
<footer>
|
||||
<div style="padding:20px 0px;text-align:center;font-family:Georgia, 'Times New Roman', Times, serif;color#454349;font-size:0.8rem;font-style: italic;">
|
||||
|
||||
<p>MySy Training<br/>
|
||||
|
||||
Cour du Havre 1, 75008, Paris<br/>
|
||||
|
||||
MySy Training Technology (MTT), société par actions simplifiée au capital de 1000 euros, dont le siège social est
|
||||
situé 2, place des magnolias, 77680, Roissy en Brie, immatriculée au Registre du Commerce et des Sociétés sous le numéro 917 500 860 R.C.S. Melun
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,76 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body style="padding:20px 20px;padding-top:0px">
|
||||
<div style="padding:0px;text-align:left;width:30%">
|
||||
<img src="http://88.170.110.220/img/MYSY-LOGO-BLUE.png" alt="Mysy Training Logo" width="100px" /> </h2>
|
||||
</div>
|
||||
<div style="padding:0px;text-align:left;font-family:Georgia, 'Times New Roman', Times, serif;color:#454349;font-size:1.5rem;padding: 0px">
|
||||
<div style="width:100%">
|
||||
<div style="text-align:center;">
|
||||
<nav style="text-align:center;font-weight: bold;"> Liste d'emargement </nav>
|
||||
<hr />
|
||||
|
||||
|
||||
<div style="padding:12px 0px;text-align:center;font-family:Georgia, 'Times New Roman', Times, serif;color#454349;font-size:0.9rem;font-weight: bold;">
|
||||
|
||||
Formation : {{json_data.title}} <br />
|
||||
Date : {{json_data.date}}
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div style="padding:12px 0px;text-align:left;font-family:Georgia, 'Times New Roman', Times, serif;color:#454349;font-size:0.9rem;width:100%;float:right;text-align:left;">
|
||||
<table style="width:100%;border: 1px solid black;padding: 0px; text-align:left;">
|
||||
<tr style="border: 1px solid black;padding: 0px; padding-top:5px; text-align: left;padding-left: 1px;">
|
||||
<th style="text-align:center;border: 1px solid black;text-align:left;">Date</th>
|
||||
<th style="text-align:center;border: 1px solid black;text-align:left;">Nom</th>
|
||||
<th style="text-align:center;border: 1px solid black;text-align:left;">Prénom</th>
|
||||
<th style="text-align:center;border: 1px solid black;width: 10%;">Matin</th>
|
||||
<th style="text-align:center;border: 1px solid black;width: 10%;">Apres Midi</th>
|
||||
<th style="text-align:center;border: 1px solid black; width: 10%;">Signature</th>
|
||||
</tr>
|
||||
|
||||
{% if users %}
|
||||
{% for user in users %}
|
||||
<tr style="border: 1px solid black; padding-top: 3px; padding-bottom: 1px;text-align:left;padding-left: 1px;">
|
||||
<td style="text-align:center;border: 1px solid black;text-align:left;">{{user.date}}</td>
|
||||
<td style="text-align:center;border: 1px solid black;text-align:left;">{{user.nom}}</td>
|
||||
<td style="text-align:center;border: 1px solid black;text-align:left;">{{user.prenom}}</td>
|
||||
|
||||
|
||||
{% if user.matin %}
|
||||
<td style="text-align:center;border: 1px solid black;width: 10%;"> X </td>
|
||||
{% else %}
|
||||
<td style="text-align:center;border: 1px solid black;width: 10%;"> </td>
|
||||
{% endif %}
|
||||
|
||||
{% if user.apresmidi %}
|
||||
<td style="text-align:center;border: 1px solid black;width: 10%;"> X </td>
|
||||
{% else %}
|
||||
<td style="text-align:center;border: 1px solid black;width: 10%;"> </td>
|
||||
{% endif %}
|
||||
|
||||
<td style="text-align:center;border: 1px solid black;width: 10%;"> </td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
</table>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<br/>
|
||||
|
||||
<div style="height:15rem;"> </div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<hr />
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,2 @@
|
|||
,index,mots,occurence,moyenne,id_article_avis,source_field
|
||||
0,0,formation4,0,0.0,formation4,default
|
|
|
@ -0,0 +1,2 @@
|
|||
mots occurence moyenne id_article_avis source_field
|
||||
0 formation4 0 0.0 formation4 default
|
|
@ -0,0 +1,89 @@
|
|||
from __future__ import print_function
|
||||
import smtplib
|
||||
from email.mime.multipart import MIMEMultipart
|
||||
from email.mime.text import MIMEText
|
||||
from email.mime.base import MIMEBase
|
||||
from email import encoders
|
||||
import locale
|
||||
import datetime
|
||||
import inspect
|
||||
import sys, os
|
||||
import prj_common as mycommon
|
||||
import GlobalVariable as MYSY_GV
|
||||
from dateutil import tz
|
||||
import pytz
|
||||
import sib_api_v3_sdk
|
||||
from sib_api_v3_sdk.rest import ApiException
|
||||
|
||||
configuration = sib_api_v3_sdk.Configuration()
|
||||
configuration.api_key['api-key'] = MYSY_GV.SENDINBLUE_API_KEY_SUPPORT
|
||||
|
||||
api_instance = sib_api_v3_sdk.TransactionalEmailsApi(sib_api_v3_sdk.ApiClient(configuration))
|
||||
|
||||
locale.setlocale(category=locale.LC_ALL, locale='fr_FR.utf8')
|
||||
|
||||
|
||||
|
||||
smtp_address = 'smtp-relay.sendinblue.com'
|
||||
port = 587
|
||||
sender = 'support@mysy-training.com'
|
||||
receiver = ["cbalde3@mysy-training.com","billardman1@gmail.com"]
|
||||
|
||||
|
||||
user = 'support@mysy-training.com'
|
||||
password = 'Tut29488!+'
|
||||
|
||||
|
||||
"""
|
||||
Envoi de l'email de confirmation d'inscription à une formation
|
||||
"""
|
||||
def incription_training_confirmation_mail(diction):
|
||||
try:
|
||||
|
||||
print(" ### incription_training_confirmation_mail = "+str(diction))
|
||||
"""
|
||||
Verification de la liste des champs obligatoires
|
||||
"""
|
||||
field_list_obligatoire = ['nom', 'prenom', 'email', 'date_du', 'date_au', 'adresse', 'title']
|
||||
for val in field_list_obligatoire:
|
||||
if val not in diction:
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " - : La valeur '" + val + "' n'est pas presente dans liste ")
|
||||
return False, "Impossible d'envoyer l'email de confirmation de l'inscritpion"
|
||||
|
||||
|
||||
|
||||
tomorrow = datetime.date.today() + datetime.timedelta(days=1)
|
||||
tomorrow_day = tomorrow.strftime("%A")
|
||||
|
||||
print("debut envoi mail de test ")
|
||||
# on rentre les renseignements pris sur le site du fournisseur
|
||||
|
||||
msg = MIMEMultipart("alternative")
|
||||
|
||||
msg['Subject'] = 'MySy Training : Confirmation inscription formation'
|
||||
msg['From'] = 'contact@mysy-training.com'
|
||||
msg['To'] = str(diction['email'])
|
||||
|
||||
to = [{"email": str(diction['email'])}]
|
||||
bcc = [{"email": "contact@mysy-training.com"}]
|
||||
|
||||
print(" ### Adresse = "+str(diction['adresse']) )
|
||||
send_smtp_email = sib_api_v3_sdk.SendSmtpEmail(template_id=1, params={ "nom": str(diction['nom']),
|
||||
"prenom":str(diction['prenom']),
|
||||
"date_du": str(diction['date_du']),
|
||||
"date_fin": str(diction['date_au']),
|
||||
"adresse": str(diction['adresse']),
|
||||
"title":str(diction['title'])},
|
||||
to=to, bcc=bcc )
|
||||
|
||||
api_response = api_instance.send_transac_email(send_smtp_email)
|
||||
print(api_response)
|
||||
|
||||
return True, " Email bien envoyé"
|
||||
|
||||
except Exception as e:
|
||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
|
||||
return False, " Impossible d'envoyer l'email de notification "
|
||||
|
18
main.py
18
main.py
|
@ -32,6 +32,8 @@ import strype_payement as Stripe
|
|||
import Inscription_mgt as inscription
|
||||
import emargement as emargement
|
||||
import Session_Formation as SF
|
||||
import email_mgt as emails
|
||||
import email_inscription_mgt as emails_support
|
||||
|
||||
|
||||
app = Flask(__name__)
|
||||
|
@ -1841,6 +1843,22 @@ def GerneratePDFEmargementList(token, session_id, internal_url):
|
|||
else:
|
||||
return False
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Envoie email d'inscription
|
||||
"""
|
||||
@app.route('/myclass/api/incription_training_confirmation_mail/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def incription_training_confirmation_mail():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = request.form.to_dict()
|
||||
print(" ### incription_training_confirmation_mail : payload = ",str(payload))
|
||||
localStatus, message= emails_support.incription_training_confirmation_mail()
|
||||
return jsonify(status=localStatus, message=message )
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
print(" debut api")
|
||||
context = SSL.Context(SSL.SSLv23_METHOD)
|
||||
|
|
Loading…
Reference in New Issue