14/05/2024 - 21h30
parent
fa4c081614
commit
ba19c02b07
|
@ -1,15 +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="12/05/2024 - 21h30">
|
||||
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="13/05/2024 - 18h30">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Job_Cron.py" beforeDir="false" afterPath="$PROJECT_DIR$/Job_Cron.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$/class_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/class_mgt.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/partner_base_setup.py" beforeDir="false" afterPath="$PROJECT_DIR$/partner_base_setup.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/partner_client.py" beforeDir="false" afterPath="$PROJECT_DIR$/partner_client.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/email_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/email_mgt.py" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
|
@ -79,13 +76,6 @@
|
|||
<option name="presentableId" value="Default" />
|
||||
<updated>1680804787304</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00248" summary="20/03/2024 - 22h30dss">
|
||||
<created>1711149396482</created>
|
||||
<option name="number" value="00248" />
|
||||
<option name="presentableId" value="LOCAL-00248" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1711149396483</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00249" summary="25/03/2024 - 18h30">
|
||||
<created>1711387309255</created>
|
||||
<option name="number" value="00249" />
|
||||
|
@ -422,7 +412,14 @@
|
|||
<option name="project" value="LOCAL" />
|
||||
<updated>1715541456510</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="297" />
|
||||
<task id="LOCAL-00297" summary="13/05/2024 - 18h30">
|
||||
<created>1715618340942</created>
|
||||
<option name="number" value="00297" />
|
||||
<option name="presentableId" value="LOCAL-00297" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1715618340942</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="298" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="Vcs.Log.Tabs.Properties">
|
||||
|
@ -464,7 +461,6 @@
|
|||
</option>
|
||||
</component>
|
||||
<component name="VcsManagerConfiguration">
|
||||
<MESSAGE value="18/04/2024 - 21h50" />
|
||||
<MESSAGE value="19/04/2024 - 22h22" />
|
||||
<MESSAGE value="20/04/2024 - 13h" />
|
||||
<MESSAGE value="20/04/2024 - 20h44" />
|
||||
|
@ -489,6 +485,7 @@
|
|||
<MESSAGE value="dd" />
|
||||
<MESSAGE value="ddsdfsd" />
|
||||
<MESSAGE value="12/05/2024 - 21h30" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="12/05/2024 - 21h30" />
|
||||
<MESSAGE value="13/05/2024 - 18h30" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="13/05/2024 - 18h30" />
|
||||
</component>
|
||||
</project>
|
5692
Log/log_file.log
5692
Log/log_file.log
File diff suppressed because one or more lines are too long
|
@ -4127,7 +4127,7 @@ def Duplicate_List_Session_Formation(diction):
|
|||
for val in incom_keys:
|
||||
if val not in field_list and val.startswith('my_') is False:
|
||||
mycommon.myprint(str(inspect.stack()[0][
|
||||
3]) + " - Le champ '" + val + "' n'est pas autorisé, Creation partenaire annulée")
|
||||
3]) + " - Le champ '" + val + "' n'est pas autorisé.")
|
||||
return False, " Toutes les informations fournies ne sont pas valables"
|
||||
|
||||
"""
|
||||
|
|
80
class_mgt.py
80
class_mgt.py
|
@ -4408,8 +4408,23 @@ c'est la fonction : "je me renseigne"
|
|||
"""
|
||||
def RenseignementClass(diction):
|
||||
try:
|
||||
field_list_obligatoire = ['nom', 'prenom', 'email', 'telephone', 'employeur',
|
||||
'message', 'class_internal_url']
|
||||
|
||||
field_list = ['nom', 'prenom', 'email', 'telephone', 'employeur',
|
||||
'message', 'class_internal_url',
|
||||
'raison_sociale', 'siret', 'email_requester', 'telephone_requester',
|
||||
'nom_requester', 'prenom_requester', 'nb_person_info',
|
||||
'prenom_requester', 'nom_requester', 'telephone_requester',
|
||||
'email_requester', 'siret', 'raison_sociale', 'is_company']
|
||||
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
if val not in field_list and val.startswith('my_') is False:
|
||||
mycommon.myprint(str(inspect.stack()[0][
|
||||
3]) + " - Le champ '" + val + "' n'est pas autorisé, Creation partenaire annulée")
|
||||
return False, " Toutes les informations fournies ne sont pas valables"
|
||||
|
||||
|
||||
field_list_obligatoire = ['is_company']
|
||||
|
||||
for val in field_list_obligatoire:
|
||||
if val not in diction:
|
||||
|
@ -4435,9 +4450,68 @@ def RenseignementClass(diction):
|
|||
|
||||
diction['class_title'] = local_class_info['title']
|
||||
diction['email_partnair'] = local_partner_info['email']
|
||||
diction['partner_owner_recid'] = local_class_info['partner_owner_recid']
|
||||
|
||||
"""
|
||||
On insert le lead dans la collection : lead_website
|
||||
Cela permettra par la suite de créer le devis si besoin
|
||||
ou de relancer
|
||||
"""
|
||||
new_lead_data = diction
|
||||
new_lead_data['valide'] = "1"
|
||||
new_lead_data['locked'] = "0"
|
||||
new_lead_data['date_update'] = str(datetime.now())
|
||||
new_lead_data['update_by'] = "auto"
|
||||
|
||||
inserted_invoice_id = MYSY_GV.dbname['lead_website'].insert_one(new_lead_data).inserted_id
|
||||
|
||||
diction['lead_website_id'] = str(inserted_invoice_id)
|
||||
|
||||
|
||||
#print(" #### diction demande info = "+str(diction))
|
||||
email.EmailDemandeInfoClass(diction)
|
||||
if( "is_company" in diction.keys() and diction['is_company'] == "0"):
|
||||
# Verifier les champ obligatoires
|
||||
field_list_obligatoire = ['nom', 'prenom',
|
||||
'telephone', 'email', 'class_internal_url', ]
|
||||
|
||||
for val in field_list_obligatoire :
|
||||
if( val not in diction.keys() or len(str(diction[str(val)])) <= 0 ):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " Les champs obligatoires ne sont pas renseignés ")
|
||||
return False, " Les champs obligatoires ne sont pas renseignés "
|
||||
|
||||
# Verifier que l'adresse email est valide
|
||||
if (mycommon.isEmailValide(str(diction['email']).strip()) is False):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " L'adresse email " + str(diction['email']) + " est invalide ")
|
||||
return False, " L'adresse email " + str(diction['email']) + " est invalide "
|
||||
|
||||
|
||||
email.EmailDemandeInfoClass(diction)
|
||||
elif( "is_company" in diction.keys() and diction['is_company'] == "1"):
|
||||
|
||||
# Verifier les champ obligatoires
|
||||
field_list_obligatoire = ['raison_sociale', 'siret',
|
||||
'email_requester', 'telephone_requester', 'nom_requester',
|
||||
'prenom_requester', 'nb_person_info', 'class_internal_url']
|
||||
|
||||
|
||||
for val in field_list_obligatoire:
|
||||
if (val not in diction.keys() or len(str(diction[str(val)])) <= 0):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " Les champs obligatoires ne sont pas renseignés ")
|
||||
return False, " Les champs obligatoires ne sont pas renseignés "
|
||||
|
||||
# Verifier que l'adresse email est valide
|
||||
if (mycommon.isEmailValide(str(diction['email_requester']).strip()) is False):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " L'adresse email " + str(diction['email_requester']) + " est invalide ")
|
||||
return False, " L'adresse email " + str(diction['email_requester']) + " est invalide "
|
||||
|
||||
|
||||
email.EmailDemandeInfoClass_For_Cpny_With_Quotation_Option(diction)
|
||||
|
||||
|
||||
return True, " La demande d'information a bien été envoyée"
|
||||
|
|
263
email_mgt.py
263
email_mgt.py
|
@ -1558,9 +1558,30 @@ def EmailDemandeInfoClass( diction):
|
|||
templateEnv = jinja2.Environment(loader=templateLoader)
|
||||
TEMPLATE_FILE = "Template/MySy_Demande_Info_Class_tpl.html"
|
||||
template = templateEnv.get_template(TEMPLATE_FILE)
|
||||
# This data can come from database query
|
||||
body = {
|
||||
"params":{"nom": str(diction['nom']),
|
||||
|
||||
|
||||
local_status, my_partner = mycommon.Get_Connected_User_Partner_Data_From_RecID(str(diction['partner_owner_recid']))
|
||||
if (local_status is not True):
|
||||
return local_status, my_partner
|
||||
|
||||
|
||||
# Creation du dictionnaire d'information à utiliser pour la creation du doc
|
||||
convention_dictionnary_data = {}
|
||||
new_diction = {}
|
||||
new_diction['token'] = my_partner['token']
|
||||
new_diction['list_stagiaire_id'] = []
|
||||
new_diction['list_session_id'] = []
|
||||
new_diction['list_class_id'] = []
|
||||
new_diction['list_client_id'] = []
|
||||
|
||||
local_status, local_retval = mycommon.Get_Dictionnary_data_For_Template(new_diction)
|
||||
|
||||
if (local_status is False):
|
||||
return local_status, local_retval
|
||||
|
||||
convention_dictionnary_data = local_retval
|
||||
|
||||
new_node = {"nom": str(diction['nom']),
|
||||
"prenom": str(diction['prenom']),
|
||||
"email": str(diction['email']),
|
||||
"email_partnair": str(diction['email_partnair']),
|
||||
|
@ -1569,17 +1590,80 @@ def EmailDemandeInfoClass( diction):
|
|||
"employeur": str(diction['employeur']),
|
||||
"message": str(diction['message']),
|
||||
"class_internal_url": str(diction['class_internal_url']),
|
||||
},
|
||||
}
|
||||
|
||||
convention_dictionnary_data['data_from_site'] = new_node
|
||||
|
||||
body_company_data = {
|
||||
"params": convention_dictionnary_data,
|
||||
}
|
||||
|
||||
sourceHtml = template.render(params=body["params"])
|
||||
|
||||
msg.set_content(sourceHtml, subtype='html')
|
||||
"""
|
||||
Recuperer le modèle de courrier
|
||||
"""
|
||||
courrier_template_data = None
|
||||
|
||||
is_courrier_template_id_valide = MYSY_GV.dbname['courrier_template'].count_documents(
|
||||
{'ref_interne': 'CLASS_INFO_REQUEST',
|
||||
'valide': '1',
|
||||
'type_doc': 'email',
|
||||
'locked': '0',
|
||||
'partner_owner_recid': str(diction['partner_owner_recid'])}
|
||||
)
|
||||
|
||||
if( is_courrier_template_id_valide == 1):
|
||||
courrier_template_data = MYSY_GV.dbname['courrier_template'].find_one(
|
||||
{'ref_interne': 'CLASS_INFO_REQUEST',
|
||||
'valide': '1',
|
||||
'type_doc': 'email',
|
||||
'locked': '0',
|
||||
'partner_owner_recid': str(diction['partner_owner_recid'])}
|
||||
)
|
||||
else:
|
||||
is_courrier_template_id_valide = MYSY_GV.dbname['courrier_template'].count_documents(
|
||||
{'ref_interne': 'CLASS_INFO_REQUEST',
|
||||
'valide': '1',
|
||||
'type_doc': 'email',
|
||||
'locked': '0',
|
||||
'partner_owner_recid': 'default'}
|
||||
)
|
||||
|
||||
if( is_courrier_template_id_valide != 1 ):
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " Impossible de récupérer le modèle de courrier 'CLASS_INFO_REQUEST' ")
|
||||
return False, " Impossible de récupérer le modèle de courrier 'CLASS_INFO_REQUEST' "
|
||||
|
||||
else:
|
||||
courrier_template_data = MYSY_GV.dbname['courrier_template'].find_one(
|
||||
{'ref_interne': 'CLASS_INFO_REQUEST',
|
||||
'valide': '1',
|
||||
'type_doc': 'email',
|
||||
'locked': '0',
|
||||
'partner_owner_recid': 'default'}
|
||||
)
|
||||
|
||||
if( courrier_template_data is None ):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " Impossible de récupérer le modèle de courrier 'CLASS_INFO_REQUEST' (2) ")
|
||||
return False, " Impossible de récupérer le modèle de courrier 'CLASS_INFO_REQUEST' (2) "
|
||||
|
||||
|
||||
sujet_doc_Template = jinja2.Template(str(courrier_template_data['sujet']))
|
||||
sujetHtml = sujet_doc_Template.render(params=body_company_data["params"])
|
||||
|
||||
|
||||
contenu_doc_Template = jinja2.Template(str(courrier_template_data['contenu_doc']))
|
||||
sourceHtml = contenu_doc_Template.render(params=body_company_data["params"])
|
||||
|
||||
html_mime = MIMEText(sourceHtml, 'html')
|
||||
# Creation de l'email à enoyer
|
||||
msg = MIMEMultipart("alternative")
|
||||
msg.attach(html_mime)
|
||||
|
||||
msg['From'] = MYSY_GV.O365_SMTP_COUNT_From_User
|
||||
|
||||
msg['Bcc'] = 'contact@mysy-training.com'
|
||||
msg['Subject'] = sujetHtml
|
||||
|
||||
msg['Subject'] = "[MySy Training Technology] : Demande d'information sur une formation"
|
||||
msg['To'] = str(diction['email_partnair'])
|
||||
|
||||
smtpserver.ehlo()
|
||||
|
@ -1596,6 +1680,169 @@ def EmailDemandeInfoClass( diction):
|
|||
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 "
|
||||
|
||||
|
||||
"""
|
||||
Envoi de l'email de la demande d'information
|
||||
sur une formation avec bouton de creation de devis
|
||||
|
||||
Ceci n'est valide que pour les entreprises (voir champ : 'is_company')
|
||||
"""
|
||||
|
||||
def EmailDemandeInfoClass_For_Cpny_With_Quotation_Option( diction):
|
||||
try:
|
||||
|
||||
field_list_obligatoire = ['is_company', 'raison_sociale', 'siret',
|
||||
'email_requester', 'telephone_requester', 'nom_requester',
|
||||
'prenom_requester', 'nb_person_info']
|
||||
|
||||
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, " : La valeur '" + val + "' n'est pas presente dans liste "
|
||||
|
||||
|
||||
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
|
||||
|
||||
|
||||
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)
|
||||
|
||||
|
||||
local_status, my_partner = mycommon.Get_Connected_User_Partner_Data_From_RecID(str(diction['partner_owner_recid']))
|
||||
if (local_status is not True):
|
||||
return local_status, my_partner
|
||||
|
||||
|
||||
# Creation du dictionnaire d'information à utiliser pour la creation du doc
|
||||
convention_dictionnary_data = {}
|
||||
new_diction = {}
|
||||
new_diction['token'] = my_partner['token']
|
||||
new_diction['list_stagiaire_id'] = []
|
||||
new_diction['list_session_id'] = []
|
||||
new_diction['list_class_id'] = []
|
||||
new_diction['list_client_id'] = []
|
||||
|
||||
local_status, local_retval = mycommon.Get_Dictionnary_data_For_Template(new_diction)
|
||||
|
||||
if (local_status is False):
|
||||
return local_status, local_retval
|
||||
|
||||
convention_dictionnary_data = local_retval
|
||||
|
||||
new_node = {"raison_sociale": str(diction['raison_sociale']),
|
||||
"siret": str(diction['siret']),
|
||||
"email_requester": str(diction['email_requester']),
|
||||
"email_partnair": str(diction['email_partnair']),
|
||||
"telephone_requester": str(diction['telephone_requester']),
|
||||
"nom_requester": str(diction['nom_requester']),
|
||||
"prenom_requester": str(diction['prenom_requester']),
|
||||
"nb_person_info": str(diction['nb_person_info']),
|
||||
"message": str(diction['message']),
|
||||
"class_internal_url": str(diction['class_internal_url']),
|
||||
'mysyurl':'mysyurl'
|
||||
}
|
||||
|
||||
convention_dictionnary_data['data_from_site'] = new_node
|
||||
|
||||
body_company_data = {
|
||||
"params": convention_dictionnary_data,
|
||||
}
|
||||
|
||||
|
||||
"""
|
||||
Recuperer le modèle de courrier
|
||||
"""
|
||||
courrier_template_data = None
|
||||
|
||||
is_courrier_template_id_valide = MYSY_GV.dbname['courrier_template'].count_documents(
|
||||
{'ref_interne': 'CLASS_INFO_REQUEST',
|
||||
'valide': '1',
|
||||
'type_doc': 'email',
|
||||
'locked': '0',
|
||||
'partner_owner_recid': str(diction['partner_owner_recid'])}
|
||||
)
|
||||
|
||||
if( is_courrier_template_id_valide == 1):
|
||||
courrier_template_data = MYSY_GV.dbname['courrier_template'].find_one(
|
||||
{'ref_interne': 'CLASS_INFO_REQUEST_WITH_QUOTATION',
|
||||
'valide': '1',
|
||||
'type_doc': 'email',
|
||||
'locked': '0',
|
||||
'partner_owner_recid': str(diction['partner_owner_recid'])}
|
||||
)
|
||||
else:
|
||||
is_courrier_template_id_valide = MYSY_GV.dbname['courrier_template'].count_documents(
|
||||
{'ref_interne': 'CLASS_INFO_REQUEST_WITH_QUOTATION',
|
||||
'valide': '1',
|
||||
'type_doc': 'email',
|
||||
'locked': '0',
|
||||
'partner_owner_recid': 'default'}
|
||||
)
|
||||
|
||||
if( is_courrier_template_id_valide != 1 ):
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " Impossible de récupérer le modèle de courrier 'CLASS_INFO_REQUEST_WITH_QUOTATION' ")
|
||||
return False, " Impossible de récupérer le modèle de courrier 'CLASS_INFO_REQUEST_WITH_QUOTATION' "
|
||||
|
||||
else:
|
||||
courrier_template_data = MYSY_GV.dbname['courrier_template'].find_one(
|
||||
{'ref_interne': 'CLASS_INFO_REQUEST_WITH_QUOTATION',
|
||||
'valide': '1',
|
||||
'type_doc': 'email',
|
||||
'locked': '0',
|
||||
'partner_owner_recid': 'default'}
|
||||
)
|
||||
|
||||
if( courrier_template_data is None ):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " Impossible de récupérer le modèle de courrier 'CLASS_INFO_REQUEST_WITH_QUOTATION' (2) ")
|
||||
return False, " Impossible de récupérer le modèle de courrier 'CLASS_INFO_REQUEST_WITH_QUOTATION' (2) "
|
||||
|
||||
|
||||
sujet_doc_Template = jinja2.Template(str(courrier_template_data['sujet']))
|
||||
sujetHtml = sujet_doc_Template.render(params=body_company_data["params"])
|
||||
|
||||
|
||||
contenu_doc_Template = jinja2.Template(str(courrier_template_data['contenu_doc']))
|
||||
sourceHtml = contenu_doc_Template.render(params=body_company_data["params"])
|
||||
|
||||
html_mime = MIMEText(sourceHtml, 'html')
|
||||
# Creation de l'email à enoyer
|
||||
msg = MIMEMultipart("alternative")
|
||||
msg.attach(html_mime)
|
||||
|
||||
msg['From'] = MYSY_GV.O365_SMTP_COUNT_From_User
|
||||
msg['Bcc'] = 'contact@mysy-training.com'
|
||||
msg['Subject'] = sujetHtml
|
||||
|
||||
msg['To'] = str(diction['email_partnair'])
|
||||
|
||||
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
|
||||
|
||||
|
||||
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 "
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Cette fonction envoi les factures
|
||||
"""
|
||||
|
|
Loading…
Reference in New Issue