30/01/23 - 22h

master
cherif 2023-01-30 22:29:31 +01:00
parent 1935680648
commit 141c3dd06e
10 changed files with 6066 additions and 108 deletions

View File

@ -3,13 +3,14 @@
<component name="ChangeListManager">
<list default="true" id="1122d9e2-679f-46d6-8c4f-97e9ae4041b5" name="Changes" comment="27/01:23 - 19h">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/GlobalVariable.py" beforeDir="false" afterPath="$PROJECT_DIR$/GlobalVariable.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Emargement/fichier_presence.pdf" beforeDir="false" afterPath="$PROJECT_DIR$/Emargement/fichier_presence.pdf" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Inscription_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/Inscription_mgt.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Log/log_file.log" beforeDir="false" afterPath="$PROJECT_DIR$/Log/log_file.log" afterDir="false" />
<change beforePath="$PROJECT_DIR$/class_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/class_mgt.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Template/Mysy_attestion_modele2_tpl.html" beforeDir="false" afterPath="$PROJECT_DIR$/Template/Mysy_attestion_modele2_tpl.html" afterDir="false" />
<change beforePath="$PROJECT_DIR$/data_indexees.csv" beforeDir="false" afterPath="$PROJECT_DIR$/data_indexees.csv" afterDir="false" />
<change beforePath="$PROJECT_DIR$/ela_output_test_file_pandas_2.txt" beforeDir="false" afterPath="$PROJECT_DIR$/ela_output_test_file_pandas_2.txt" afterDir="false" />
<change beforePath="$PROJECT_DIR$/emargement.py" beforeDir="false" afterPath="$PROJECT_DIR$/emargement.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/email_inscription_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/email_inscription_mgt.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/prj_common.py" beforeDir="false" afterPath="$PROJECT_DIR$/prj_common.py" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />

File diff suppressed because one or more lines are too long

View File

@ -1529,19 +1529,55 @@ def SendTrainingEvaluationEmail(diction):
my_retrun_dict = {}
print(' ##### local_Insc_retval = ', local_Insc_retval)
my_retrun_dict['token_eval'] = local_Insc_retval['_id']
my_retrun_dict['session_id'] = local_Insc_retval['session_id']
my_retrun_dict['date_du'] = str(local_Insc_retval['date_du'])[1:10]
my_retrun_dict['date_au'] = str(local_Insc_retval['date_au'])[0:10]
my_retrun_dict['ville'] = local_Insc_retval['ville']
my_retrun_dict['code_postal'] = local_Insc_retval['code_postal']
my_retrun_dict['internal_url'] = local_Insc_retval['class_internal_url']
my_retrun_dict['adresse'] = local_Insc_retval['adresse']
my_retrun_dict['nom'] = local_Insc_retval['nom']
my_retrun_dict['prenom'] = local_Insc_retval['prenom']
my_retrun_dict['employeur'] = local_Insc_retval['employeur']
my_retrun_dict['telephone'] = local_Insc_retval['telephone']
ville = ""
if ("ville" in local_Insc_retval.keys() and local_Insc_retval['ville']):
ville = local_Insc_retval['ville']
my_retrun_dict['ville'] = ville
code_postal = ""
if ("code_postal" in local_Insc_retval.keys() and local_Insc_retval['code_postal']):
code_postal = local_Insc_retval['code_postal']
my_retrun_dict['code_postal'] = code_postal
internal_url = ""
if ("class_internal_url" in local_Insc_retval.keys() and local_Insc_retval['class_internal_url']):
internal_url = local_Insc_retval['class_internal_url']
my_retrun_dict['internal_url'] = internal_url
print(" ###### LAAA internal_url = ", internal_url)
adresse = ""
if ("adresse" in local_Insc_retval.keys() and local_Insc_retval['adresse']):
adresse = local_Insc_retval['adresse']
my_retrun_dict['adresse'] = adresse
nom = ""
if ("nom" in local_Insc_retval.keys() and local_Insc_retval['nom']):
nom = local_Insc_retval['nom']
my_retrun_dict['nom'] = nom
prenom = ""
if ("prenom" in local_Insc_retval.keys() and local_Insc_retval['prenom']):
prenom = local_Insc_retval['prenom']
my_retrun_dict['prenom'] = prenom
employeur = ""
if ("employeur" in local_Insc_retval.keys() and local_Insc_retval['employeur']):
employeur = local_Insc_retval['employeur']
my_retrun_dict['employeur'] = employeur
telephone = ""
if ("telephone" in local_Insc_retval.keys() and local_Insc_retval['telephone']):
telephone = local_Insc_retval['telephone']
my_retrun_dict['telephone'] = telephone
my_retrun_dict['email'] = local_Insc_retval['email']
@ -1562,7 +1598,7 @@ def SendTrainingEvaluationEmail(diction):
if ("distantiel" in local_session_info.keys()):
if local_session_info['distantiel']:
my_retrun_dict['distantiel'] = local_session_info['teldistantielephone']
my_retrun_dict['distantiel'] = local_session_info['distantiel']
if ("presentiel" in local_session_info.keys()):
if local_session_info['presentiel']:
@ -1632,16 +1668,29 @@ def SendAttendeeCertification(diction):
return False, " La date de fin de session de formation est incorrecte."
mytoday = datetime.today().strftime("%d/%m/%Y")
"""
if (datetime.strptime(str(date_fin_session).strip(), '%d/%m/%Y') > datetime.strptime(str(mytoday).strip(), '%d/%m/%Y')):
mycommon.myprint(str(inspect.stack()[0][3]) + " Vous ne pouvez pas delivrer de certificat avant la date de fin de la session de formation ")
return False, " Vous ne pouvez pas delivrer de certificat avant la date de fin de la session de formation "
"""
print(" #### attestation_certif = ", str(session_formation['attestation_certif']))
attestation_certificat = MYSY_GV.dbname['attestation_certificat'].find_one({'nom': str(session_formation['attestation_certif']),
'valide': "1"})
if ( attestation_certificat is None or attestation_certificat['template_name'] is None):
mycommon.myprint(str(inspect.stack()[0][3]) + " - Aucun type d'attestation/certificat trouvé 1")
return False, " Aucun type d'attestation/certificat trouvé "
my_retrun_dict = {}
my_template = ""
if ("template_name" in attestation_certificat.keys() and attestation_certificat['template_name']):
my_template = attestation_certificat['template_name']
if( str(my_template).strip() == ""):
mycommon.myprint(str(inspect.stack()[0][3]) + " - Aucun type d'attestation/certificat trouvé 2")
return False, " Aucun type d'attestation/certificat trouvé "
my_retrun_dict['attestation_tmpl'] = attestation_certificat['template_name']
# Recuperation des info de l'inscrit
@ -1654,19 +1703,58 @@ def SendAttendeeCertification(diction):
my_retrun_dict['date_du'] = local_Insc_retval['date_du']
my_retrun_dict['date_au'] = local_Insc_retval['date_au']
my_retrun_dict['ville'] = local_Insc_retval['ville']
my_retrun_dict['code_postal'] = local_Insc_retval['code_postal']
my_retrun_dict['internal_url'] = local_Insc_retval['class_internal_url']
ville = ""
if ("ville" in local_Insc_retval.keys() and local_Insc_retval['ville']):
ville = local_Insc_retval['ville']
my_retrun_dict['ville'] = ville
code_postal = ""
if ("code_postal" in local_Insc_retval.keys() and local_Insc_retval['code_postal']):
code_postal = local_Insc_retval['code_postal']
my_retrun_dict['code_postal'] = code_postal
internal_url = ""
if ("class_internal_url" in local_Insc_retval.keys() and local_Insc_retval['class_internal_url']):
internal_url = local_Insc_retval['class_internal_url']
my_retrun_dict['code_postal'] = internal_url
my_retrun_dict['inscription_id'] = local_Insc_retval['_id']
adresse = ""
if ("adresse" in local_Insc_retval.keys() and local_Insc_retval['adresse']):
adresse = local_Insc_retval['adresse']
my_retrun_dict['adresse'] = adresse
nom = ""
if ("nom" in local_Insc_retval.keys() and local_Insc_retval['nom']):
nom = local_Insc_retval['nom']
my_retrun_dict['nom'] = nom
prenom = ""
if ("prenom" in local_Insc_retval.keys() and local_Insc_retval['prenom']):
prenom = local_Insc_retval['prenom']
my_retrun_dict['prenom'] = prenom
employeur = ""
if ("employeur" in local_Insc_retval.keys() and local_Insc_retval['employeur']):
employeur = local_Insc_retval['employeur']
my_retrun_dict['employeur'] = employeur
telephone = ""
if ("telephone" in local_Insc_retval.keys() and local_Insc_retval['telephone']):
telephone = local_Insc_retval['telephone']
my_retrun_dict['telephone'] = telephone
formateur = ""
if ("formateur" in session_formation.keys() and session_formation['formateur']):
formateur = session_formation['formateur']
my_retrun_dict['formateur'] = formateur
#my_retrun_dict['formateur'] = session_formation['formateur']
my_retrun_dict['adresse'] = local_Insc_retval['adresse']
my_retrun_dict['nom'] = local_Insc_retval['nom']
my_retrun_dict['prenom'] = local_Insc_retval['prenom']
my_retrun_dict['employeur'] = local_Insc_retval['employeur']
my_retrun_dict['telephone'] = local_Insc_retval['telephone']
my_retrun_dict['formateur'] = session_formation['formateur']
my_retrun_dict['email'] = local_Insc_retval['email']
# Recuperation des infotrmations de la formation

File diff suppressed because it is too large Load Diff

View File

@ -1,74 +1,78 @@
<!DOCTYPE html>
<html>
<body style=" width:290mm; margin-left: auto; margin-right: auto;border-style: double;margin-top: 2rem; padding:1rem;">
<div style="padding-top:10px;text-align:left;width:30%; border: #454349;float: left;">
<img src="http://88.170.110.220/img/MYSY-LOGO-BLUE.png" alt="Mysy Training Logo" width="80px" />
</div>
<body style=" width:290mm; margin-left: auto; margin-right: auto;border-style: double;margin-top: 2rem; padding:1rem;
border: 2px solid; ">
<div style="border: 2px solid; margin: 5px;">
<div style="padding-top:10px;text-align:left;width:30%; border: 2px; float: left;">
<img src="http://88.170.110.220/img/MYSY-LOGO-BLUE.png" alt="Mysy Training Logo" width="80px" />
</div>
<div style="padding-top:10px;text-align:center;width:70%; border: #454349; float: center;">
<h3> ATTESTION INDIVIDUELLE DE FORMATION </h3>
</div>
<div style="padding-top:10px;text-align:center;width:70%; border: none; float: center;">
<h3> ATTESTION INDIVIDUELLE DE FORMATION </h3>
</div>
<hr />
<div style="padding:0px;text-align:left;font-family:Georgia, 'Times New Roman', Times,
serif;color:#454349;font-size:1.5rem;padding: 0px; border: none;">
<div style="width:100%">
<div style="text-align:center;border: none;">
<nav style="text-align:center;font-weight: bold;border: none;"> Formation </nav>
<div style="padding:12px 0px;text-align:center;font-family:Georgia, 'Times New Roman', Times,
serif;color:#454349;font-size:1.2rem; line-height: 2rem;border: none;">
<p style="border: none;">
Par la presente, l'oganisme de formation {{json_data.partner}} au Numero de declaration
{{json_data.num_declation}} <br />
atteste que {{json_data.nom}} &nbsp; {{json_data.prenom}} a suivi la formation <br />
<b> "{{json_data.class_title}}" </b> <br />
realisé par le formateur {{json_data.formateur}}
</p>
<p style="border: none;">
Cette formation a eu lieu du {{json_data.date_du}} au {{json_data.date_au}} à l'adresse
:{{json_data.adresse}}
</p>
</div>
<div
style="padding:12px 0px;text-align:left;font-family:Georgia, 'Times New Roman', Times, serif;color:#454349;font-size:1.2rem">
<div style="width: 100%; margin-bottom: 5rem;">
Contenus de la formation : <br />
{{json_data.objectif}}
</div>
<div style="width: 30%; float: left;">
Fait à {{json_data.ville}} le {{json_data.date_impression}}
</div>
<div style="width: 70%; float: left;text-align: right;">
Pour l'organisme de formation <br />
{% if json_data.img_url %}
<img src={{ json_data.signature }} width="200px" />
{% endif %}
<hr />
<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;"> Formation </nav>
<div
style="padding:12px 0px;text-align:center;font-family:Georgia, 'Times New Roman', Times, serif;color:#454349;font-size:1.2rem; line-height: 2rem;">
<p>
Par la presente, l'oganisme de formation {{json_data.partner}} au Numero de declaration
{{json_data.num_declation}} <br />
atteste que {{json_data.nom}} &nbsp; {{json_data.prenom}} a suivi la formation <br />
<b> "{{json_data.class_title}}" </b> <br />
realisé par le formateur {{json_data.formateur}}
</p>
<p>
Cette formation a eu lieu du {{json_data.date_du}} au {{json_data.date_au}} à l'adresse
:{{json_data.adresse}}
</p>
</div>
<div
style="padding:12px 0px;text-align:left;font-family:Georgia, 'Times New Roman', Times, serif;color:#454349;font-size:1.2rem">
<div style="width: 100%; margin-bottom: 5rem;">
Contenus de la formation : <br />
{{json_data.objectif}}
</div>
</div>
<div style="width: 30%; float: left;">
Fait à {{json_data.ville}} le {{json_data.date_impression}}
</div>
<div style="width: 70%; float: left;text-align: right;">
Pour l'organisme de formation <br />
{% if json_data.img_url %}
<img src={{ json_data.signature }} width="200px" />
{% endif %}
</div>
</div>
<br />
</div>
<br />
</div>
<hr />
<div style="text-align: right;border: none;"> Date impression : {{json_data.date_impression}} </div>
</div>
<hr />
<div style="text-align: right;"> Date impression : {{json_data.date_impression}} </div>
</body>
</html>

View File

@ -1,3 +1,5 @@
,index,mots,occurence,moyenne,id_formation,source_field
0,0,management,1,0.5,MYSY_1000forma2,title
1,1,fondamentau,1,0.5,MYSY_1000forma2,title
0,0,certif,1,0.25,QPR_F2,keyword
1,1,pratiqu,1,0.25,QPR_F2,keyword
2,2,p,1,0.25,QPR_F2,keyword
3,3,agile,1,0.25,QPR_F2,keyword

1 index mots occurence moyenne id_formation source_field
2 0 0 management certif 1 0.5 0.25 MYSY_1000forma2 QPR_F2 title keyword
3 1 1 fondamentau pratiqu 1 0.5 0.25 MYSY_1000forma2 QPR_F2 title keyword
4 2 2 p 1 0.25 QPR_F2 keyword
5 3 3 agile 1 0.25 QPR_F2 keyword

View File

@ -1,3 +1,5 @@
Empty DataFrame
Columns: [mots, occurence, moyenne, id_formation, source_field]
Index: []
mots occurence moyenne id_formation source_field
0 certif 1 0.25 QPR_F2 keyword
1 pratiqu 1 0.25 QPR_F2 keyword
2 p 1 0.25 QPR_F2 keyword
3 agile 1 0.25 QPR_F2 keyword

View File

@ -11,6 +11,7 @@ import sys, os
from bson import ObjectId
from pymongo import ReturnDocument
from xhtml2pdf import pisa
import prj_common as mycommon
import GlobalVariable as MYSY_GV
@ -481,7 +482,7 @@ def Evaluation_training_confirmation_mail(diction):
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"
return False, "Impossible d'envoyer l'email de demande d'evaluation"
@ -506,6 +507,7 @@ def Evaluation_training_confirmation_mail(diction):
my_url = "https://dev.mysy-training.com/Display-Detail-formation/" + str(diction['internal_url'])+"/"+str(diction['token_eval'])
print(" ### Adresse = "+str(diction['adresse']) )
print(" #### my_url = ", my_url)
# msg = MIMEMultipart("alternative")
msg = EmailMessage()
@ -634,3 +636,101 @@ def SendAttestion_to_attendee_by_email(diction):
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'attestation par email "
"""
Cette fonction crée une attestation et converti en PDF en mode standalone (c'est un test)
"""
def SendAttestion_to_attendee_by_email_standalone(diction):
try:
"""
Verification de la liste des champs obligatoires
"""
field_list_obligatoire = ['nom', 'prenom', 'email', 'date_du', 'date_au', 'adresse', 'title',
'attestation_tmpl', 'inscription_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 l'attestation par email "
print(' ### diction = ',str(diction))
msg = MIMEMultipart("alternative")
msg['From'] = MYSY_GV.O365_SMTP_COUNT_From_User
msg['To'] = str(diction['email'])
# msg = MIMEMultipart("alternative")
msg = EmailMessage()
smtpserver = smtplib.SMTP(MYSY_GV.O365_SMTP_COUNT_smtpsrv, MYSY_GV.O365_SMTP_COUNT_port)
# JINJA2
templateLoader = jinja2.FileSystemLoader(searchpath="./")
templateEnv = jinja2.Environment(loader=templateLoader)
TEMPLATE_FILE = "Template/"+ str(diction['attestation_tmpl']) +".html"
template = templateEnv.get_template(TEMPLATE_FILE)
# This data can come from database query
body = {
"params": {"nom": str(diction['nom']),
"prenom": str(diction['prenom']),
"date_du": str(diction['date_du'])[0:10],
"date_fin": str(diction['date_au'])[0:10],
"adresse": str(diction['adresse']),
"title": str(diction['title']),
"email": str(diction['email']),
}}
ct = datetime.datetime.now()
ts = ct.timestamp()
sourceHtml = template.render(json_data=body["params"])
orig_file_name = "Attestation_" + str(ts) + ".pdf"
outputFilename = str(MYSY_GV.INVOICE_DIRECTORY) + str(orig_file_name)
# open output file for writing (truncated binary)
resultFile = open(outputFilename, "w+b")
# convert HTML to PDF
pisaStatus = pisa.CreatePDF(
src=sourceHtml, # the HTML to convert
dest=resultFile) # file handle to receive result
# close output file
resultFile.close()
msg.set_content(sourceHtml, subtype='html')
msg['From'] = MYSY_GV.O365_SMTP_COUNT_From_User
msg['Bcc'] = 'contact@mysy-training.com'
msg['Subject'] = 'MySy Training : Votre attestation de formation : ' + str(diction['title'])
msg['To'] = str(diction['email'])
smtpserver.ehlo()
smtpserver.starttls()
smtpserver.login(MYSY_GV.O365_SMTP_COUNT_user, MYSY_GV.O365_SMTP_COUNT_password)
val = smtpserver.send_message(msg)
smtpserver.close()
print(" Email envoyé " + str(val))
mytoday = datetime.date.today().strftime("%d/%m/%Y")
my_local_mydata = {'certification_send_date':str(mytoday)}
print(" ### str(diction['inscription_id']) = ",str(diction['inscription_id']) )
## Mise à jour de la date d'envoi du certificat
MYSY_GV.dbname['inscription'].find_one_and_update({'_id':ObjectId(str(diction['inscription_id']))},
{"$set":my_local_mydata},
return_document=ReturnDocument.AFTER,)
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'attestation par email "

14
main.py
View File

@ -2344,6 +2344,20 @@ def payment_retrieve_status():
localStatus, message = Stripe.payment_retrieve_status(payload)
return jsonify(status=localStatus, message=message )
"""
Cette API envoyer une attestation de formation
"""
@app.route('/myclass/api/SendAttestion_to_attendee_by_email_standalone/', methods=['POST','GET'])
@crossdomain(origin='*')
def SendAttestion_to_attendee_by_email_standalone():
# On recupere le corps (payload) de la requete
payload = request.form.to_dict()
print(" ### emails_support : payload = ",payload)
localStatus, message = emails_support.SendAttestion_to_attendee_by_email_standalone(payload)
return jsonify(status=localStatus, message=message )
"""

View File

@ -2596,8 +2596,15 @@ def GetAttendeeDetail_perSession(diction):
v = local_Insc_retval['_id'].generation_time
my_retrun_dict['created_date'] = str(v.strftime("%d/%m/%Y"))
# Recuperation des infotrmations de la formation
# Recuperation des informations de la formation
local_formation = MYSY_GV.dbname['myclass'].find_one({'internal_url':str(local_Insc_retval['class_internal_url'])})
if local_formation is None or local_formation['_id'] is None:
myprint(str(inspect.stack()[0][3]) + " - Impossible de recuperer les informations de la formation ")
return False, " Impossible de recuperer les informations de la formation"
my_retrun_dict['class_title'] = local_formation['title']
RetObject.append(JSONEncoder().encode(my_retrun_dict))