12/02/23 - 16h
parent
8bc7567884
commit
6b6a520998
|
@ -3,14 +3,10 @@
|
|||
<component name="ChangeListManager">
|
||||
<list default="true" id="1122d9e2-679f-46d6-8c4f-97e9ae4041b5" name="Changes" comment="10/02/23 - 12h">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" 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$/Session_Formation.py" beforeDir="false" afterPath="$PROJECT_DIR$/Session_Formation.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$/class_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/class_mgt.py" 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$/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" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
|
|
2128
Log/log_file.log
2128
Log/log_file.log
File diff suppressed because one or more lines are too long
|
@ -1,7 +1,5 @@
|
|||
,index,mots,occurence,moyenne,id_formation,source_field
|
||||
0,0,belt,1,0.17,MYSY_0001,title
|
||||
1,1,ecam,1,0.17,MYSY_0001,title
|
||||
2,2,yellow,1,0.17,MYSY_0001,title
|
||||
3,3,deploiement,1,0.17,MYSY_0001,title
|
||||
4,4,expert,1,0.17,MYSY_0001,title
|
||||
5,5,lean,1,0.17,MYSY_0001,title
|
||||
0,0,maitriser,1,0.25,LPP_0002,title
|
||||
1,1,grammaire,1,0.25,LPP_0002,title
|
||||
2,2,base,1,0.25,LPP_0002,title
|
||||
3,3,orthographe,1,0.25,LPP_0002,title
|
||||
|
|
|
|
@ -21,6 +21,8 @@ import sib_api_v3_sdk
|
|||
from sib_api_v3_sdk.rest import ApiException
|
||||
import jinja2
|
||||
from email.message import EmailMessage
|
||||
from email.mime.text import MIMEText
|
||||
from email import encoders
|
||||
|
||||
configuration = sib_api_v3_sdk.Configuration()
|
||||
configuration.api_key['api-key'] = MYSY_GV.SENDINBLUE_API_KEY_SUPPORT
|
||||
|
@ -686,7 +688,7 @@ def SendAttestion_to_attendee_by_email(diction):
|
|||
date_jour = ct.strftime("%d/%m/%Y")
|
||||
|
||||
# msg = MIMEMultipart("alternative")
|
||||
msg = EmailMessage()
|
||||
msg = MIMEMultipart("alternative")
|
||||
smtpserver = smtplib.SMTP(MYSY_GV.O365_SMTP_COUNT_smtpsrv, MYSY_GV.O365_SMTP_COUNT_port)
|
||||
|
||||
# JINJA2
|
||||
|
@ -701,7 +703,6 @@ def SendAttestion_to_attendee_by_email(diction):
|
|||
"prenom": str(prenom),
|
||||
"date_du": str(date_du),
|
||||
"date_au": str(date_au),
|
||||
"adresse": str(adresse),
|
||||
"class_title": str(diction['class_title']),
|
||||
"email": str(diction['email_participant']),
|
||||
"adresse": str(adresse),
|
||||
|
@ -738,39 +739,40 @@ def SendAttestion_to_attendee_by_email(diction):
|
|||
# close output file
|
||||
resultFile.close()
|
||||
|
||||
body = '''Hello,
|
||||
This is the body of the email
|
||||
sicerely yours
|
||||
G.G.
|
||||
'''
|
||||
msg.attach(MIMEText(body, 'plain'))
|
||||
html = '''
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
|
||||
# open the file in bynary
|
||||
binary_pdf = open(outputFilename, 'rb')
|
||||
<h1> Attestation de {nom} {prenom} </h1>
|
||||
Bonjour, <br/>
|
||||
Merci de trouver votre attestation de la formation {maformation} en pièce jointe
|
||||
<br/>
|
||||
|
||||
payload = MIMEBase('application', 'octate-stream', Name=outputFilename)
|
||||
payload.set_payload((binary_pdf).read())
|
||||
</body>
|
||||
</html>'''.format(nom=nom, prenom = prenom, maformation=str(diction['class_title']))
|
||||
|
||||
# enconding the binary into base64
|
||||
encoders.encode_base64(payload)
|
||||
html_mime = MIMEText(html, 'html')
|
||||
|
||||
# add header with pdf name
|
||||
payload.add_header('Content-Decomposition', 'attachment', filename=outputFilename)
|
||||
msg.attach(payload)
|
||||
# msg.attach(texte_mime)
|
||||
msg.attach(html_mime)
|
||||
|
||||
#print("html_mime =" + str(html))
|
||||
|
||||
|
||||
"""with open(outputFilename, 'rb') as content_file:
|
||||
content = content_file.read()
|
||||
msg.add_attachment(content, maintype='application', subtype='pdf', filename='Attestation.pdf')
|
||||
|
||||
"""
|
||||
f = outputFilename
|
||||
part = MIMEBase('application', "octet-stream")
|
||||
part.set_payload(open(f, "rb").read())
|
||||
encoders.encode_base64(part)
|
||||
part.add_header('Content-Disposition', 'attachment; filename="{0}"'
|
||||
.format(os.path.basename(f)))
|
||||
msg.attach(part)
|
||||
|
||||
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['class_title'])
|
||||
msg['To'] = str(diction['email_participant'])
|
||||
|
||||
msg.attach(MIMEText(open(outputFilename).read()))
|
||||
|
||||
smtpserver.ehlo()
|
||||
smtpserver.starttls()
|
||||
|
@ -861,7 +863,7 @@ def SendAttestion_to_attendee_by_email_standalone(diction):
|
|||
date_jour = ct.strftime("%d/%m/%Y")
|
||||
|
||||
# msg = MIMEMultipart("alternative")
|
||||
msg = EmailMessage()
|
||||
msg = MIMEMultipart("alternative")
|
||||
smtpserver = smtplib.SMTP(MYSY_GV.O365_SMTP_COUNT_smtpsrv, MYSY_GV.O365_SMTP_COUNT_port)
|
||||
|
||||
# JINJA2
|
||||
|
@ -907,9 +909,35 @@ def SendAttestion_to_attendee_by_email_standalone(diction):
|
|||
|
||||
# close output file
|
||||
resultFile.close()
|
||||
html = '''
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
|
||||
<h1> {mymessage} </h1>
|
||||
|
||||
</body>
|
||||
</html>'''.format(mymessage="cherif bladeee")
|
||||
|
||||
html_mime = MIMEText(html, 'html')
|
||||
|
||||
# msg.attach(texte_mime)
|
||||
msg.attach(html_mime)
|
||||
|
||||
print("html_mime =" + str(html))
|
||||
|
||||
toaddr = "billardman1@gmail.com"
|
||||
cc = ['cbalde@mysy-training.com']
|
||||
toaddrs = [toaddr] + cc
|
||||
|
||||
f = './Invoices/aaa.pdf'
|
||||
part = MIMEBase('application', "octet-stream")
|
||||
part.set_payload(open(f, "rb").read())
|
||||
encoders.encode_base64(part)
|
||||
part.add_header('Content-Disposition', 'attachment; filename="{0}"'
|
||||
.format(os.path.basename(f)))
|
||||
msg.attach(part)
|
||||
|
||||
msg.set_content(sourceHtml, subtype='html')
|
||||
|
||||
msg['From'] = MYSY_GV.O365_SMTP_COUNT_From_User
|
||||
msg['Bcc'] = 'contact@mysy-training.com, mysytraining@gmail.com'
|
||||
|
@ -919,7 +947,7 @@ def SendAttestion_to_attendee_by_email_standalone(diction):
|
|||
smtpserver.ehlo()
|
||||
smtpserver.starttls()
|
||||
smtpserver.login(MYSY_GV.O365_SMTP_COUNT_user, MYSY_GV.O365_SMTP_COUNT_password)
|
||||
val = smtpserver.send_message(msg)
|
||||
smtpserver.send_message(msg)
|
||||
smtpserver.close()
|
||||
print(" Email envoyé " + str(val))
|
||||
|
||||
|
@ -939,3 +967,69 @@ def SendAttestion_to_attendee_by_email_standalone(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 "
|
||||
|
||||
|
||||
|
||||
def sendmailwith_attached():
|
||||
try:
|
||||
|
||||
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 Technology] : yesss'
|
||||
msg['From'] = MYSY_GV.O365_SMTP_COUNT_From_User
|
||||
msg['To'] = "billardman1@gmail.com"
|
||||
|
||||
html = '''
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
|
||||
<h1> {mymessage} </h1>
|
||||
|
||||
</body>
|
||||
</html>'''.format(mymessage="cherif bladeee")
|
||||
|
||||
html_mime = MIMEText(html, 'html')
|
||||
|
||||
# msg.attach(texte_mime)
|
||||
msg.attach(html_mime)
|
||||
|
||||
print("html_mime =" + str(html))
|
||||
|
||||
toaddr = "billardman1@gmail.com"
|
||||
cc = ['cbalde@mysy-training.com']
|
||||
toaddrs = [toaddr] + cc
|
||||
|
||||
f = './Invoices/aaa.pdf'
|
||||
part = MIMEBase('application', "octet-stream")
|
||||
part.set_payload(open(f, "rb").read())
|
||||
encoders.encode_base64(part)
|
||||
part.add_header('Content-Disposition', 'attachment; filename="{0}"'
|
||||
.format(os.path.basename(f)))
|
||||
msg.attach(part)
|
||||
|
||||
|
||||
|
||||
|
||||
# msg.attach(MIMEText(open(filename).read()))
|
||||
|
||||
with smtplib.SMTP(MYSY_GV.O365_SMTP_COUNT_smtpsrv, MYSY_GV.O365_SMTP_COUNT_port) as server:
|
||||
server.starttls() # Secure the connection
|
||||
|
||||
server.login(MYSY_GV.O365_SMTP_COUNT_user, MYSY_GV.O365_SMTP_COUNT_password)
|
||||
server.sendmail(MYSY_GV.O365_SMTP_COUNT_From_User, toaddrs, msg.as_string())
|
||||
mycommon.myprint("mail successfully sent to " + str(toaddrs))
|
||||
|
||||
|
||||
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 "
|
||||
|
|
11
main.py
11
main.py
|
@ -2409,6 +2409,17 @@ def SendAttestion_to_attendee_by_email_standalone():
|
|||
return jsonify(status=localStatus, message=message )
|
||||
|
||||
|
||||
@app.route('/myclass/api/sendmailwith_attached/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def sendmailwith_attached():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = request.form.to_dict()
|
||||
print(" ### sendmailwith_attached : payload = ",payload)
|
||||
localStatus, message = emails_support.sendmailwith_attached()
|
||||
return jsonify(status=localStatus, message=message )
|
||||
|
||||
|
||||
|
||||
"""
|
||||
API de test pour envoyer la notif d'evaluation
|
||||
"""
|
||||
|
|
Loading…
Reference in New Issue