15/04/23 - 14h
parent
c2b289d2ac
commit
712d69d663
|
@ -1,14 +1,12 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="10/04/23 - 17h">
|
||||
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="14/04/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$/Log/log_file.log" beforeDir="false" afterPath="$PROJECT_DIR$/Log/log_file.log" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/email_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/email_mgt.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/lms_chamilo/mysy_lms.py" beforeDir="false" afterPath="$PROJECT_DIR$/lms_chamilo/mysy_lms.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/tools_cherif/tools_cherif.py" beforeDir="false" afterPath="$PROJECT_DIR$/tools_cherif/tools_cherif.py" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
|
@ -93,7 +91,14 @@
|
|||
<option name="project" value="LOCAL" />
|
||||
<updated>1681138622687</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="5" />
|
||||
<task id="LOCAL-00005" summary="14/04/23 - 23h">
|
||||
<created>1681505500999</created>
|
||||
<option name="number" value="00005" />
|
||||
<option name="presentableId" value="LOCAL-00005" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1681505500999</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="6" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="Vcs.Log.Tabs.Properties">
|
||||
|
@ -111,6 +116,7 @@
|
|||
<MESSAGE value="07/04/23 - 9h" />
|
||||
<MESSAGE value="07/04/23 - 11h" />
|
||||
<MESSAGE value="10/04/23 - 17h" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="10/04/23 - 17h" />
|
||||
<MESSAGE value="14/04/23 - 23h" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="14/04/23 - 23h" />
|
||||
</component>
|
||||
</project>
|
|
@ -342,4 +342,4 @@ CLASS_DURATION_UNIT = ['heure', 'jour', 'mois', 'annee']
|
|||
Cette variable est le l'url de base pour le lms.
|
||||
cette valeur est utilisée pour la creation des url du lms
|
||||
"""
|
||||
LMS_BAS_URL = "mysy-training.fr"
|
||||
LMS_BAS_URL = "mysy-training.fr/"
|
2156
Log/log_file.log
2156
Log/log_file.log
File diff suppressed because one or more lines are too long
107
email_mgt.py
107
email_mgt.py
|
@ -2275,3 +2275,110 @@ def EmailNotifEvaluation_Done(diction):
|
|||
return False, " Impossible d'envoyer l'email de notification "
|
||||
|
||||
|
||||
"""
|
||||
Cette fonction envoie un email à partenaire avec ses identfiants
|
||||
de connexion à son espace hebergement de formation
|
||||
"""
|
||||
def Email_Part_Espace_Hosting( diction):
|
||||
try:
|
||||
field_list_obligatoire = ['token', ]
|
||||
|
||||
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 emails avec les information d'hébergement"
|
||||
|
||||
my_token = ""
|
||||
if ("token" in diction.keys()):
|
||||
if diction['token']:
|
||||
my_token = diction['token']
|
||||
|
||||
|
||||
|
||||
partner_recid = mycommon.get_parnter_recid_from_token(my_token)
|
||||
if (partner_recid is False):
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - partner_recid est KO ")
|
||||
return False, "Impossible d'envoyer les emails avec les information d'hébergement "
|
||||
|
||||
# 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, str(inspect.stack()[0][3]) + " - impossible de recuperer les données du partenaire"
|
||||
|
||||
nom = ""
|
||||
if ("nom" in my_partner.keys()):
|
||||
nom = my_partner['nom']
|
||||
|
||||
mysy_pack = ""
|
||||
if ("pack_service" in my_partner.keys()):
|
||||
mysy_pack = my_partner['pack_service']
|
||||
|
||||
nb_formation = ""
|
||||
if ("nb_formation" in my_partner.keys()):
|
||||
nb_formation = my_partner['nb_formation']
|
||||
|
||||
mysy_url = MYSY_GV.CLIENT_URL_BASE
|
||||
|
||||
lms_url = ""
|
||||
if ("lms_virtualhost_url" in my_partner.keys()):
|
||||
lms_url = my_partner['lms_virtualhost_url']
|
||||
|
||||
login = ""
|
||||
if ("email" in my_partner.keys()):
|
||||
if( '@' in str(my_partner['email'])):
|
||||
login_tab = str(my_partner['email']).strip().split('@')
|
||||
login = login_tab[0]
|
||||
|
||||
if( login == ""):
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - Le login du partenaire est incorrecte")
|
||||
return False, str(inspect.stack()[0][3]) + " - Le login du partenaire est incorrecte"
|
||||
|
||||
tomorrow = datetime.date.today() + datetime.timedelta(days=1)
|
||||
tomorrow_day = tomorrow.strftime("%A")
|
||||
|
||||
smtpserver = smtplib.SMTP(MYSY_GV.O365_SMTP_COUNT_smtpsrv, MYSY_GV.O365_SMTP_COUNT_port)
|
||||
|
||||
# msg = MIMEMultipart("alternative")
|
||||
msg = EmailMessage()
|
||||
|
||||
# JINJA2
|
||||
templateLoader = jinja2.FileSystemLoader(searchpath="./")
|
||||
templateEnv = jinja2.Environment(loader=templateLoader)
|
||||
TEMPLATE_FILE = "Template/MySy_Acces_Espace_Hebergement_Partner_tpl.html"
|
||||
template = templateEnv.get_template(TEMPLATE_FILE)
|
||||
# This data can come from database query
|
||||
body = {
|
||||
"params":{"nom": str(nom),
|
||||
"mysy_pack": str(mysy_pack),
|
||||
"nb_formation": str(nb_formation),
|
||||
"lms_url": str(lms_url),
|
||||
"mysy_url": str(mysy_url),
|
||||
"login": str(login),
|
||||
},
|
||||
}
|
||||
|
||||
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'
|
||||
|
||||
msg['Subject'] = "[MySy Training Technology] : Vos identifiants de connexion à la plateforme d'hébergement. "
|
||||
msg['To'] = str(my_partner['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))
|
||||
return True, " Les identifiants de connexion à la plateforme d'hébergement a été correctement 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 les identifiants de connexion à la plateforme d'hébergement par email "
|
||||
|
|
|
@ -15,7 +15,7 @@ from pymongo import ReturnDocument
|
|||
from math import isnan
|
||||
import GlobalVariable as MYSY_GV
|
||||
import ela_index_bdd_classes as eibdd
|
||||
import email_mgt as email
|
||||
import email_mgt as email_mgt
|
||||
import socket
|
||||
import smtplib
|
||||
import re
|
||||
|
@ -300,6 +300,7 @@ def Create_MySy_LMS_User(diction):
|
|||
else:
|
||||
"""
|
||||
/!\ On va l'ajouter une 2ieme fois si le compte partenaire necessite la creation d'un nouvel url.
|
||||
:!\ : on ajoute aussi le user ad
|
||||
"""
|
||||
virutal_host_id = local_virtualhost_id
|
||||
virutal_host_url = local_virtualhost_full_url
|
||||
|
@ -316,6 +317,17 @@ def Create_MySy_LMS_User(diction):
|
|||
|
||||
conn.commit()
|
||||
|
||||
"""
|
||||
Envoie de l'email contenant les information de connection à la plateforme
|
||||
d'hébergement
|
||||
"""
|
||||
local_mydata2 = {}
|
||||
local_mydata2['token'] = my_token
|
||||
local_status2, local_message2 = email_mgt.Email_Part_Espace_Hosting(local_mydata2)
|
||||
if( local_status2 is False):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " - WARNING : Impossible d'envoyer les identifiants de connexion à la plateforme d'hébergement par email ")
|
||||
|
||||
|
||||
conn.close()
|
||||
|
||||
|
|
Loading…
Reference in New Issue