25/03/23 - 12h

master
cherif 2023-03-25 12:10:55 +01:00
parent 1ff8c40637
commit b257a79c86
6 changed files with 1332 additions and 6 deletions

View File

@ -1,11 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="1122d9e2-679f-46d6-8c4f-97e9ae4041b5" name="Changes" comment="24/03/23 - 17h">
<list default="true" id="1122d9e2-679f-46d6-8c4f-97e9ae4041b5" name="Changes" comment="24/03/23 - 23h">
<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$/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$/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" />
@ -379,7 +381,14 @@
<option name="project" value="LOCAL" />
<updated>1679672559062</updated>
</task>
<option name="localTasksCounter" value="45" />
<task id="LOCAL-00045" summary="24/03/23 - 23h">
<created>1679698893677</created>
<option name="number" value="00045" />
<option name="presentableId" value="LOCAL-00045" />
<option name="project" value="LOCAL" />
<updated>1679698893677</updated>
</task>
<option name="localTasksCounter" value="46" />
<servers />
</component>
<component name="Vcs.Log.Tabs.Properties">
@ -394,7 +403,6 @@
</option>
</component>
<component name="VcsManagerConfiguration">
<MESSAGE value="19/01/23 - 20h" />
<MESSAGE value="21/01/23 - 12h" />
<MESSAGE value="24/01/23 - 19h" />
<MESSAGE value="25/01/23 - 16h" />
@ -419,6 +427,7 @@
<MESSAGE value="19/03/23 - 19h45" />
<MESSAGE value="21/03/23 - 22h" />
<MESSAGE value="24/03/23 - 17h" />
<option name="LAST_COMMIT_MESSAGE" value="24/03/23 - 17h" />
<MESSAGE value="24/03/23 - 23h" />
<option name="LAST_COMMIT_MESSAGE" value="24/03/23 - 23h" />
</component>
</project>

View File

@ -309,6 +309,8 @@ if (MYSY_ENV == "PROD"):
MYSY_MARIADB_HOST = "192.168.1.21"
MYSY_MARIADB_PORT = 3306
MYSY_LMS_BDD = "mysy_db_chamilo_prod"
MYSY_LMS_URL = ""
elif (MYSY_ENV == "DEV"):
@ -317,6 +319,7 @@ elif (MYSY_ENV == "DEV"):
MYSY_MARIADB_HOST = "192.168.1.21"
MYSY_MARIADB_PORT = 3306
MYSY_LMS_BDD = "mysy_db_chamilo_dev"
MYSY_LMS_URL = "https://lms.mysy-training.com/"
elif (MYSY_ENV == "REC"):
@ -325,8 +328,7 @@ elif (MYSY_ENV == "REC"):
MYSY_MARIADB_HOST = "192.168.1.21"
MYSY_MARIADB_PORT = 3306
MYSY_LMS_BDD = "mysy_db_chamilo_rec"
MYSY_LMS_URL = "https://reclms.mysy-training.com/"

View File

@ -2638,3 +2638,132 @@ def CancelAttendeeInscription(diction):
exc_type, exc_obj, exc_tb = sys.exc_info()
print(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
return False, " Impossible de recuperer la liste des evaluations"
"""
Cette fonction envoie l'email de connexion à la plateformation LMS
au participant
Cet email met en copie le responsable de la formation. ceci pour pouvoir renvoyer le mail au besoin
"""
def Send_LMS_Credentials_to_particpants(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, " Les informations fournies ne sont pas correctes"
mytoken = ""
if ("token" in diction.keys()):
if diction['token']:
mytoken = diction['token']
partner_recid = mycommon.get_parnter_recid_from_token(mytoken)
if (partner_recid is False):
mycommon.myprint(str(inspect.stack()[0][3]) + " - Impossible de recuperer le recid du partenaire")
return False, "Impossible de recuperer le recid du partenaire"
# 0 -Recuperation des données du partenaire
local_status, my_partner = mycommon.get_partner_data_from_recid(partner_recid)
if (local_status is False):
mycommon.myprint(str(inspect.stack()[0][3]) + " - impossible de recuperer les données du partenaire")
return False, " - impossible de recuperer les données du partenaire"
data_mail = {}
# 1 - Recuperation des données de la formation
local_class = MYSY_GV.dbname['myclass'].find({'internal_url': str(diction['class_internal_url'])})
data_mail['title'] = local_class[0]['title']
class_title = local_class[0]['title']
# 2 - Recuperation des données de l'inscription
local_inscription = MYSY_GV.dbname['inscription'].find({'session_id': str(diction['session_id']),
'email': str(diction['email'])})
lms_class_code = ""
if ("lms_class_code" in local_inscription[0].keys()):
if local_inscription[0]['lms_class_code']:
lms_class_code = local_inscription[0]['lms_class_code']
lms_user_id = ""
if ("lms_user_id" in local_inscription[0].keys()):
if local_inscription[0]['lms_user_id']:
lms_user_id = local_inscription[0]['lms_user_id']
lms_pwd = ""
if ("lms_pwd" in local_inscription[0].keys()):
if local_inscription[0]['lms_pwd']:
lms_pwd = local_inscription[0]['lms_pwd']
nom = ""
if ("nom" in local_inscription[0].keys()):
if local_inscription[0]['nom']:
nom = local_inscription[0]['nom']
prenom = ""
if ("prenom" in local_inscription[0].keys()):
if local_inscription[0]['prenom']:
prenom = local_inscription[0]['prenom']
email = ""
if ("email" in local_inscription[0].keys()):
if local_inscription[0]['email']:
email = local_inscription[0]['email']
date_du = ""
if ("date_du" in local_inscription[0].keys()):
if local_inscription[0]['date_du']:
date_du = str(local_inscription[0]['date_du'])[0:10]
date_au = ""
if ("date_au" in local_inscription[0].keys()):
if local_inscription[0]['date_au']:
date_au = str(local_inscription[0]['date_au'])[0:10]
# Recuperation des données de la session
local_session = MYSY_GV.dbname['session_formation'].find_one(
{'formation_session_id': str(diction['session_id']),
'class_internal_url': str(diction['class_internal_url'])})
if (local_session is None):
mycommon.myprint(str(inspect.stack()[0][3]) + " - Impossible de recuperer les données de la session ")
return False, " Impossible de recuperer les données de la session "
now = str(datetime.now().strftime("%d/%m/%Y %H:%M:%S"))
return_message = ""
email_data = {}
email_data['nom'] = nom
email_data['prenom'] = prenom
email_data['email'] = email
email_data['date_du'] = date_du
email_data['date_au'] = date_au
email_data['title'] = class_title
email_data['login'] = email
email_data['pwd'] = lms_pwd
email_data['lms_url'] = MYSY_GV.MYSY_LMS_URL
email_data['course_owner_email'] = my_partner['email']
local_status, local_message = email_session.LMS_Credential_Sending_mail(email_data)
if (local_status is False):
mycommon.myprint(str(
inspect.stack()[0][3]) + " - WARNING : Impossible d'envoyer le mail de notification pour " + str(
diction['email']))
return_message = return_message + str(
" Impossible d'envoyer le mail de notification pour : " + str(diction['email']))
if (return_message.strip() != ""):
return True, return_message
return True, " Les informations de connexion ont été correctement envoyées"
except Exception as e:
exc_type, exc_obj, exc_tb = sys.exc_info()
print(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
return False, " Impossible d'envoyer les informations de connexion à la plateforme LMS"

File diff suppressed because one or more lines are too long

View File

@ -1148,3 +1148,106 @@ def sendmailwith_attached():
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 envoie les informations d'identification de connexion à la plateforme
LMS
"""
def LMS_Credential_Sending_mail(diction):
try:
"""
Verification de la liste des champs obligatoires
"""
field_list_obligatoire = ['nom', 'prenom', 'email', 'date_du', 'date_au', 'title', 'login', 'pwd', 'lms_url', 'course_owner_email' ]
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 les information de connexion à la plateforme LMS"
tomorrow = datetime.date.today() + datetime.timedelta(days=1)
tomorrow_day = tomorrow.strftime("%A")
print("debut envoi mail de test ")
"""
Verification si c'est une formation en ligne.
auquel cas, l'adresse est du type : enligne"""
my_adress = ""
if ("adresse" in diction.keys()):
if diction['adresse']:
my_adress = diction['adresse']
presentiel = ""
if ("presentiel" in diction.keys()):
if diction['presentiel']:
presentiel = diction['presentiel']
distantiel = ""
if ("distantiel" in diction.keys()):
if diction['distantiel']:
distantiel = diction['distantiel']
adresse_session = my_adress
# on rentre les renseignements pris sur le site du fournisseur
# msg = MIMEMultipart("alternative")
smtpserver = smtplib.SMTP(MYSY_GV.O365_SMTP_COUNT_smtpsrv, MYSY_GV.O365_SMTP_COUNT_port)
msg = EmailMessage()
# JINJA2
templateLoader = jinja2.FileSystemLoader(searchpath="./")
templateEnv = jinja2.Environment(loader=templateLoader)
TEMPLATE_FILE = "Template/MySy_LMS_credential_sending_tpl.html"
template = templateEnv.get_template(TEMPLATE_FILE)
# This data can come from database query
body = {}
body = {
"params": {"nom": str(diction['nom']),
"prenom": str(diction['prenom']),
"date_du": str(diction['date_du']),
"date_fin": str(diction['date_au']),
"adresse": str(adresse_session),
"title": str(diction['title']),
"email": str(diction['email']),
"login": str(diction['login']),
"pwd": str(diction['pwd']),
"lms_url": str(diction['lms_url']),
"course_owner_email": str(diction['course_owner_email'])},
}
sourceHtml = template.render(params=body["params"])
msg.set_content(sourceHtml, subtype='html')
msg['From'] = MYSY_GV.O365_SMTP_COUNT_From_User
msg['Bcc'] = 'contact@mysy-training.com,'+str(str(diction['course_owner_email']))
msg['Subject'] = '[MySy Training]: Vos identifications de connexion'
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 confirlation envoyé " + str(val))
return True, " Email d'identification de connexion 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 "

13
main.py
View File

@ -2771,6 +2771,19 @@ def CancelAttendeeInscription():
return jsonify(status=localStatus, message=message )
"""
Cette API permet d'envoyer les identifiants de connexion à la plateforme de plateforme LMS
"""
@app.route('/myclass/api/LMS_Credential_Sending_mail/', methods=['POST','GET'])
@crossdomain(origin='*')
def LMS_Credential_Sending_mail():
# On CancelAttendeeInscription le corps (payload) de la requete
payload = request.form.to_dict()
print(" ### LMS_Credential_Sending_mail : payload = ",payload)
localStatus, message= inscription.Send_LMS_Credentials_to_particpants(payload)
return jsonify(status=localStatus, message=message )
if __name__ == '__main__':
print(" debut api")
context = SSL.Context(SSL.SSLv23_METHOD)