08/09/2024 - 21h

master
cherif 2024-09-08 21:24:56 +02:00
parent c196c94546
commit 0867158063
11 changed files with 8750 additions and 37 deletions

View File

@ -1,12 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="qsh"> <list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="06/09/2024 - 22h">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Activite.py" beforeDir="false" afterPath="$PROJECT_DIR$/Activite.py" afterDir="false" /> <change beforePath="$PROJECT_DIR$/Activite.py" beforeDir="false" afterPath="$PROJECT_DIR$/Activite.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$/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$/crm_opportunite.py" beforeDir="false" afterPath="$PROJECT_DIR$/crm_opportunite.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" /> <change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/note_evaluation_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/note_evaluation_mgt.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/partner_order.py" beforeDir="false" afterPath="$PROJECT_DIR$/partner_order.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/partners.py" beforeDir="false" afterPath="$PROJECT_DIR$/partners.py" afterDir="false" /> <change beforePath="$PROJECT_DIR$/partners.py" beforeDir="false" afterPath="$PROJECT_DIR$/partners.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/prj_common.py" beforeDir="false" afterPath="$PROJECT_DIR$/prj_common.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/ressources_humaines.py" beforeDir="false" afterPath="$PROJECT_DIR$/ressources_humaines.py" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -76,13 +82,6 @@
<option name="presentableId" value="Default" /> <option name="presentableId" value="Default" />
<updated>1680804787304</updated> <updated>1680804787304</updated>
</task> </task>
<task id="LOCAL-00343" summary="wws">
<created>1720114279292</created>
<option name="number" value="00343" />
<option name="presentableId" value="LOCAL-00343" />
<option name="project" value="LOCAL" />
<updated>1720114279293</updated>
</task>
<task id="LOCAL-00344" summary="wwssd"> <task id="LOCAL-00344" summary="wwssd">
<created>1720184777416</created> <created>1720184777416</created>
<option name="number" value="00344" /> <option name="number" value="00344" />
@ -419,7 +418,14 @@
<option name="project" value="LOCAL" /> <option name="project" value="LOCAL" />
<updated>1725630280202</updated> <updated>1725630280202</updated>
</task> </task>
<option name="localTasksCounter" value="392" /> <task id="LOCAL-00392" summary="06/09/2024 - 22h">
<created>1725652418352</created>
<option name="number" value="00392" />
<option name="presentableId" value="LOCAL-00392" />
<option name="project" value="LOCAL" />
<updated>1725652418354</updated>
</task>
<option name="localTasksCounter" value="393" />
<servers /> <servers />
</component> </component>
<component name="Vcs.Log.Tabs.Properties"> <component name="Vcs.Log.Tabs.Properties">
@ -461,7 +467,6 @@
</option> </option>
</component> </component>
<component name="VcsManagerConfiguration"> <component name="VcsManagerConfiguration">
<MESSAGE value="08/08/2024 - 20h32s" />
<MESSAGE value="10/08/2024 - 20h32s" /> <MESSAGE value="10/08/2024 - 20h32s" />
<MESSAGE value="11/08/2024 - 12h32s" /> <MESSAGE value="11/08/2024 - 12h32s" />
<MESSAGE value="11/08/2024 - 18h32s" /> <MESSAGE value="11/08/2024 - 18h32s" />
@ -486,6 +491,7 @@
<MESSAGE value="03/09/2024 - 20:00" /> <MESSAGE value="03/09/2024 - 20:00" />
<MESSAGE value="04/09/2024 - 23h" /> <MESSAGE value="04/09/2024 - 23h" />
<MESSAGE value="qsh" /> <MESSAGE value="qsh" />
<option name="LAST_COMMIT_MESSAGE" value="qsh" /> <MESSAGE value="06/09/2024 - 22h" />
<option name="LAST_COMMIT_MESSAGE" value="06/09/2024 - 22h" />
</component> </component>
</project> </project>

View File

@ -668,7 +668,7 @@ def Get_List_Entity_Activite(diction):
data_cle['locked'] = "0" data_cle['locked'] = "0"
data_cle['created_by'] = str(my_partner['_id']) data_cle['created_by'] = str(my_partner['_id'])
print(" frfrfr data_cle = ", data_cle)
RetObject = [] RetObject = []
val_tmp = 0 val_tmp = 0

File diff suppressed because one or more lines are too long

View File

@ -5240,12 +5240,11 @@ def Prepare_and_Send_Convention_From_Session_By_PDF(diction):
local_diction['courrier_template_id'] = diction['courrier_template_id'] local_diction['courrier_template_id'] = diction['courrier_template_id']
local_diction['client_id'] = str(val) local_diction['client_id'] = str(val)
print(" #### Traitemnt de local_diction aaa = ", local_diction)
local_status, local_full_file_name = Create_Convention_By_Client_PDF(local_diction) local_status, local_full_file_name = Create_Convention_By_Client_PDF(local_diction)
if( local_status is False): if( local_status is False):
return local_status, local_full_file_name return local_status, local_full_file_name
else: else:
print(" ### pdf_file_name = ", local_full_file_name)
list_file_name_to_zip.append(str(local_full_file_name)) list_file_name_to_zip.append(str(local_full_file_name))
@ -5443,7 +5442,7 @@ def Prepare_and_Send_Default_Convention_From_Session_By_PDF(diction):
] ]
} }
print(" ### qry_indi = ", qry_indi)
default_courrier_template_individuel_count = MYSY_GV.dbname['courrier_template'].count_documents( default_courrier_template_individuel_count = MYSY_GV.dbname['courrier_template'].count_documents(
{"$or": [{'valide': '1', {"$or": [{'valide': '1',
@ -5725,7 +5724,6 @@ def Create_Convention_By_Client_PDF(diction):
Creation du ficier PDF Creation du ficier PDF
""" """
contenu_doc_Template = jinja2.Template(str(template_courrier_data['contenu_doc'])) contenu_doc_Template = jinja2.Template(str(template_courrier_data['contenu_doc']))
sourceHtml = contenu_doc_Template.render(params=body["params"]) sourceHtml = contenu_doc_Template.render(params=body["params"])

View File

@ -165,6 +165,7 @@ def Add_CRM_Opportunite(diction):
mydata['date_update'] = str(datetime.now()) mydata['date_update'] = str(datetime.now())
mydata['update_by'] = str(my_partner['_id']) mydata['update_by'] = str(my_partner['_id'])
mydata['created_by'] = str(my_partner['_id'])
mydata['partner_owner_recid'] = str(my_partner['recid']) mydata['partner_owner_recid'] = str(my_partner['recid'])
mydata['valide'] = "1" mydata['valide'] = "1"
mydata['locked'] = "0" mydata['locked'] = "0"
@ -223,10 +224,10 @@ def Update_CRM_Opportunite(diction):
Verification de l'identité et autorisation de l'entité qui Verification de l'identité et autorisation de l'entité qui
appelle cette API appelle cette API
""" """
token = "" my_token = ""
if ("token" in diction.keys()): if ("token" in diction.keys()):
if diction['token']: if diction['token']:
token = diction['token'] my_token = diction['token']
opport_id = "" opport_id = ""
if ("opport_id" in diction.keys()): if ("opport_id" in diction.keys()):
@ -250,6 +251,12 @@ def Update_CRM_Opportunite(diction):
str(inspect.stack()[0][3]) + " L'identifiant de l'opportunité est invalide ") str(inspect.stack()[0][3]) + " L'identifiant de l'opportunité est invalide ")
return False, " L'identifiant de l'opportunité client_id est invalide " return False, " L'identifiant de l'opportunité client_id est invalide "
crm_opport_old_data = MYSY_GV.dbname['crm_opportunite'].find_one({'_id': ObjectId(str(opport_id)),
'valide': '1',
'locked': '0',
'partner_owner_recid': str(
my_partner['recid'])})
mydata = {} mydata = {}
mydata = diction mydata = diction
@ -320,7 +327,150 @@ def Update_CRM_Opportunite(diction):
" Impossible de mettre à jour l'opportunité (2) ") " Impossible de mettre à jour l'opportunité (2) ")
return False, " Impossible de mettre à jour l'opportunité (2) " return False, " Impossible de mettre à jour l'opportunité (2) "
"""
Si le statut de l'opportunité à changé alors declenché une notification
a la liste de difusion du Vendeur (vendeur_id) et vers la personne qui a créé l'opportunité
"""
old_status_id = ""
new_status_id = ""
if( "statut_id" in diction.keys() ):
new_status_id = diction['statut_id']
if( "statut_id" in crm_opport_old_data.keys() ):
old_status_id = crm_opport_old_data['statut_id']
if( old_status_id != new_status_id ):
"""
Recuperer le modèle de document
"""
local_diction = {}
local_diction['ref_interne'] = "CRM_OPPORTUNITE_CHANGE_NOTIF"
local_diction['type_doc'] = "email"
local_diction['partner_owner_recid'] = str(my_partner['recid'])
courrier_data_status, courrier_data_retval = mycommon.Get_Courrier_Template_Include_Default_Data(local_diction)
if (courrier_data_status is False):
return courrier_data_status, courrier_data_retval
if ("contenu_doc" not in courrier_data_retval.keys() or str(courrier_data_retval['contenu_doc']) == ""):
mycommon.myprint(
str(inspect.stack()[0][
3]) + " Le modèle de courrier 'CRM_OPPORTUNITE_CHANGE_NOTIF' n'est pas correctement configuré ")
return False, " Le modèle de courrier 'CRM_OPPORTUNITE_CHANGE_NOTIF' n'est pas correctement configuré "
# Recuperation des donnes smtp
local_stpm_status, partner_SMTP_COUNT_smtpsrv, partner_own_smtp_value, partner_SMTP_COUNT_password, partner_SMTP_COUNT_user, partner_SMTP_COUNT_From_User, partner_SMTP_COUNT_port = mycommon.Get_Partner_SMTP_Param(
my_partner['recid'])
if (local_stpm_status is False):
return local_stpm_status, partner_own_smtp_value
convention_dictionnary_data = {}
new_diction = {}
new_diction['token'] = str(my_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
new_status_id_data = MYSY_GV.dbname['base_partner_opportunite_step'].find_one({'_id':ObjectId(str(new_status_id)),
'valide':'1',
'locked':'0',
}, {'description':1, 'gagne':1})
print(" #### new_status_id_data = ", new_status_id_data)
new_status_label = ""
if( new_status_id_data and "description" in new_status_id_data.keys() ):
new_status_label = new_status_id_data['description']
new_status_is_gagne = "0"
if( new_status_id_data and "gagne" in new_status_id_data.keys() ):
new_status_is_gagne = new_status_id_data['gagne']
crm_opp_data = result
crm_opp_data['new_status_label'] = str(new_status_label)
crm_opp_data['new_status_is_gagne'] = str(new_status_is_gagne)
print(" #### crm_opp_data = ", crm_opp_data)
dictionnary_data = local_retval
dictionnary_data['mysyurl'] = MYSY_GV.CLIENT_URL_BASE+"Partner/mes_opportunites"
dictionnary_data['crm_opp_data'] = crm_opp_data
body = {
"params": dictionnary_data,
}
"""
Recuperer les donnés du vendeur associé à l'opportunité
"""
email_to = []
if( "vendeur_id" in result.keys() and result['vendeur_id']):
vendeur_id_data = MYSY_GV.dbname['ressource_humaine'].find_one({'_id':ObjectId(str(result['vendeur_id'])),
'valide':'1',
'partner_recid':str(my_partner['recid'])})
if (vendeur_id_data and "email" in vendeur_id_data.keys() and vendeur_id_data[
'email']):
email_to.append(str(vendeur_id_data['email']))
if( vendeur_id_data and "diffusion_mail" in vendeur_id_data.keys() and vendeur_id_data['diffusion_mail']):
email_to.append(str(vendeur_id_data['diffusion_mail']))
if (str(partner_own_smtp_value) == "1"):
smtpserver = smtplib.SMTP(partner_SMTP_COUNT_smtpsrv, partner_SMTP_COUNT_port)
else:
smtpserver = smtplib.SMTP(MYSY_GV.O365_SMTP_COUNT_smtpsrv, MYSY_GV.O365_SMTP_COUNT_port)
smtpserver.ehlo()
smtpserver.starttls()
smtpserver.login(MYSY_GV.O365_SMTP_COUNT_user, MYSY_GV.O365_SMTP_COUNT_password)
# Traitement du sujet du mail
sujet_mail_Template = jinja2.Template(str(courrier_data_retval['sujet']))
sujetHtml = sujet_mail_Template.render(params=body["params"])
# Traitement du corps du mail
contenu_doc_Template = jinja2.Template(str(courrier_data_retval['contenu_doc']))
sourceHtml = contenu_doc_Template.render(params=body["params"])
html_mime = MIMEText(sourceHtml, 'html')
# Creation de l'email à enoyer
msg = MIMEMultipart("alternative")
if (str(partner_own_smtp_value) == "1"):
msg.attach(html_mime)
msg['From'] = partner_SMTP_COUNT_From_User
msg['Bcc'] = 'contact@mysy-training.com'
msg['Subject'] = sujetHtml
toaddrs = ", ".join(email_to)
msg['to'] = str(toaddrs)
val = smtpserver.send_message(msg)
print(" Email de notification envoyé " + str(val))
else:
msg.attach(html_mime)
msg['From'] = MYSY_GV.O365_SMTP_COUNT_From_User
msg['Bcc'] = 'contact@mysy-training.com'
msg['Subject'] = sujetHtml
toaddrs = ", ".join(email_to)
msg['to'] = str(toaddrs)
val = smtpserver.send_message(msg)
print(" Email de notification envoyé " + str(val))
smtpserver.close()
return True, " L'opportunité a été correctement mise à jour " return True, " L'opportunité a été correctement mise à jour "
@ -919,7 +1069,7 @@ def Add_CRM_Opportunite_Etape(diction):
""" """
Verification des input acceptés Verification des input acceptés
""" """
field_list = ['token', 'code', 'description', 'rang'] field_list = ['token', 'code', 'description', 'rang', 'gagne']
incom_keys = diction.keys() incom_keys = diction.keys()
for val in incom_keys: for val in incom_keys:
@ -968,7 +1118,13 @@ def Add_CRM_Opportunite_Etape(diction):
new_data['code'] = str(diction['code']).lower() new_data['code'] = str(diction['code']).lower()
new_data['date_update'] = str(datetime.now()) new_data['date_update'] = str(datetime.now())
new_data['update_by'] = str(my_partner['recid']) new_data['update_by'] = str(my_partner['_id'])
if( "gagne" in diction.keys() and diction['gagne'] in ['0', '1']):
new_data['gagne'] = str(diction['gagne'])
else:
new_data['gagne'] = '0'
new_data['partner_owner_recid'] = str(my_partner['recid']) new_data['partner_owner_recid'] = str(my_partner['recid'])
new_data['valide'] = "1" new_data['valide'] = "1"
@ -1043,6 +1199,11 @@ def Get_CRM_List_Opportunite_Etape(diction):
my_partner['recid'])}).sort([("rang", pymongo.ASCENDING), ]): my_partner['recid'])}).sort([("rang", pymongo.ASCENDING), ]):
user = retval user = retval
user['id'] = str(val_tmp) user['id'] = str(val_tmp)
if( "gagne" not in user.keys() ):
user['gagne'] = "0"
val_tmp = val_tmp + 1 val_tmp = val_tmp + 1
RetObject.append(mycommon.JSONEncoder().encode(user)) RetObject.append(mycommon.JSONEncoder().encode(user))
@ -1132,7 +1293,7 @@ def Delete_CRM_List_Opportunite_Etape(diction):
""" """
Mettre à jour une étape d'opportunité Mettre à jour une étape d'opportunité et declenchement envoi email de notif
""" """
def Update_CRM_List_Opportunite_Etape(diction): def Update_CRM_List_Opportunite_Etape(diction):
@ -1142,7 +1303,7 @@ def Update_CRM_List_Opportunite_Etape(diction):
""" """
Verification des input acceptés Verification des input acceptés
""" """
field_list = ['token', '_id', 'code', 'description', 'rang'] field_list = ['token', '_id', 'code', 'description', 'rang', 'gagne']
incom_keys = diction.keys() incom_keys = diction.keys()
for val in incom_keys: for val in incom_keys:
@ -1214,7 +1375,6 @@ def Update_CRM_List_Opportunite_Etape(diction):
return True, " L'étape a été correctement mise à jour" return True, " L'étape a été correctement mise à jour"

63
main.py
View File

@ -6253,10 +6253,18 @@ API qui envoie un partner_order par email au client
@crossdomain(origin='*') @crossdomain(origin='*')
def Send_Partner_Order_By_Email(): def Send_Partner_Order_By_Email():
# On recupere le corps (payload) de la requete # On recupere le corps (payload) de la requete
payload = mycommon.strip_dictionary (request.form.to_dict()) payload = mycommon.strip_dictionary(request.form.to_dict())
print(" ### Send_Partner_Order_By_Email payload = ", str(payload)) print(" ### Send_Partner_Order_By_Email : payload = ", str(payload))
status, message = partner_order.Send_Partner_Order_By_Email(payload)
return jsonify(status=status, message=message) file = []
tab_files = []
if request.method == 'POST':
# Create variable for uploaded file
for tmp in request.files.getlist("File"):
tab_files.append(tmp)
status, retval = partner_order.Send_Partner_Order_By_Email(tab_files, MYSY_GV.TEMPORARY_DIRECTORY_V2, payload)
return jsonify(status=status, message=retval)
""" """
Conversion d'un devis en commande Conversion d'un devis en commande
@ -10039,6 +10047,53 @@ def Delete_Participant_From_Evaluation():
return jsonify(status=status, message=retval) return jsonify(status=status, message=retval)
"""
API pour envoyer les convocation à une evaluation par email a chaque apprenant choisi
"""
@app.route('/myclass/api/Send_Evaluation_Convocation_Participant_By_Email/', methods=['POST','GET'])
@crossdomain(origin='*')
def Send_Evaluation_Convocation_Participant_By_Email():
# On recupere le corps (payload) de la requete
payload = mycommon.strip_dictionary(request.form.to_dict())
print(" ### Send_Evaluation_Convocation_Participant_By_Email : payload = ", str(payload))
file = []
tab_files = []
if request.method == 'POST':
# Create variable for uploaded file
for tmp in request.files.getlist("File"):
tab_files.append(tmp)
status, retval = note_evaluation_mgt.Send_Evaluation_Convocation_Participant_By_Email(tab_files, MYSY_GV.TEMPORARY_DIRECTORY_V2, payload)
return jsonify(status=status, message=retval)
"""
API pour generer et telecharge le fichier PDF d'une convocation a une evaluation
"""
@app.route('/myclass/api/Send_Evaluation_Convocation_Participant_By_PDF/<token>/<evaluation_id>/<tab_eval_inscription_id>/<courrier_template_id>', methods=['POST','GET'])
@crossdomain(origin='*')
def Send_Evaluation_Convocation_Participant_By_PDF(token, evaluation_id, tab_eval_inscription_id, courrier_template_id):
# On recupere le corps (payload) de la requete
payload = mycommon.strip_dictionary (request.form.to_dict())
payload = {}
payload['token'] = str(token)
payload['evaluation_id'] = str(evaluation_id)
payload['tab_eval_inscription_id'] = str(tab_eval_inscription_id)
payload['courrier_template_id'] = str(courrier_template_id)
print(" ### Send_Evaluation_Convocation_Participant_By_PDF : payload = ",str(payload))
localStatus, response= note_evaluation_mgt.Send_Evaluation_Convocation_Participant_By_PDF(payload)
if(localStatus ):
return response
else:
return False
""" """
API pour Mise à jour les note evaluation API pour Mise à jour les note evaluation
à une évaluation à une évaluation

View File

@ -15,6 +15,7 @@ En suite la saisie de la note dans la collection : 'note_evaluation_apprenant'
""" """
import ast import ast
from zipfile import ZipFile
import bson import bson
import pymongo import pymongo
@ -23,7 +24,9 @@ from pymongo import MongoClient
import json import json
from bson import ObjectId from bson import ObjectId
import re import re
from datetime import datetime from datetime import datetime, date
import partner_client
import prj_common as mycommon import prj_common as mycommon
import secrets import secrets
import inspect import inspect
@ -47,6 +50,7 @@ from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText from email.mime.text import MIMEText
from email.mime.base import MIMEBase from email.mime.base import MIMEBase
from email import encoders from email import encoders
import attached_file_mgt
""" """
Ajout d'une evaluation planifiée Ajout d'une evaluation planifiée
@ -1076,6 +1080,624 @@ def Delete_Participant_From_Evaluation(diction):
return False, "Impossible de supprimer les inscriptions à l'évaluation " return False, "Impossible de supprimer les inscriptions à l'évaluation "
"""
Cette fonction permet d'envoyer les convocation a une evalution
a une liste d'_id participants
"""
def Send_Evaluation_Convocation_Participant_By_Email(tab_files, Folder, diction):
try:
diction = mycommon.strip_dictionary(diction)
"""
Verification des input acceptés
"""
field_list = ['token', 'evaluation_id', 'tab_eval_inscription_id', 'courrier_template_id']
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é")
return False, " Les informations fournies sont incorrectes"
"""
Verification des champs obligatoires
"""
field_list_obligatoire = ['token', 'evaluation_id', 'tab_eval_inscription_id', 'courrier_template_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 sont incorrectes"
"""
Verification de l'identité et autorisation de l'entité qui
appelle cette API
"""
token = ""
if ("token" in diction.keys()):
if diction['token']:
token = diction['token']
local_status, my_partner = mycommon.Check_Connexion_And_Return_Partner_Data(diction)
if (local_status is not True):
return local_status, my_partner
"""
Verifier que l'evaluation est valide
"""
is_evaluation_valide = MYSY_GV.dbname['note_evaluation'].count_documents(
{"_id": ObjectId(str(diction['evaluation_id'])),
'valide': '1',
'locked': '0',
'partner_owner_recid': str(my_partner['recid'])})
if (is_evaluation_valide != 1):
mycommon.myprint(
str(inspect.stack()[0][3]) + " L'identifiant de l'évaluation n'est pas valide ")
return False, " L'identifiant de l'évaluation n'est pas valide "
evaluation_data = MYSY_GV.dbname['note_evaluation'].find_one(
{"_id": ObjectId(str(diction['evaluation_id'])),
'valide': '1',
'locked': '0',
'partner_owner_recid': str(my_partner['recid'])})
eval_class_data = None
if( "class_id" in evaluation_data.keys() and evaluation_data['class_id']):
eval_class_data = MYSY_GV.dbname['myclass'].find_one({'_id':ObjectId(str(evaluation_data['class_id'])),
'partner_owner_recid':str(my_partner['recid'])})
eval_eu_data = None
if ("class_eu_id" in evaluation_data.keys() and evaluation_data['class_eu_id']):
eval_eu_data = MYSY_GV.dbname['unite_enseignement'].find_one({'_id': ObjectId(str(evaluation_data['class_eu_id'])),
'partner_owner_recid': str(my_partner['recid'])})
tab_eval_final_inscription_id = []
tab_final_inscription_id = []
tab_eval_inscription_id = str(diction['tab_eval_inscription_id']).split(",")
for eval_inscription_id in tab_eval_inscription_id:
if( eval_inscription_id ):
# Verifier que le stagiaire est bien inscrit. Le statut de l'inscription doit etre "1"
is_eval_inscription_valide = MYSY_GV.dbname['note_evaluation_participant'].count_documents(
{'_id': ObjectId(str(eval_inscription_id)),
'partner_owner_recid': str(my_partner['recid'])})
if (is_eval_inscription_valide != 1):
mycommon.myprint(
str(inspect.stack()[0][
3]) + " L'identifiant de la note_evaluation_participant " + str(eval_inscription_id) + " est invalide ")
return False, " L'identifiant de la note_evaluation_participant " + str(eval_inscription_id) + " est invalide "
is_eval_inscription_data = MYSY_GV.dbname['note_evaluation_participant'].find_one(
{'_id': ObjectId(str(eval_inscription_id)),
'partner_owner_recid': str(my_partner['recid'])})
tab_final_inscription_id.append(ObjectId(str(is_eval_inscription_data['inscription_id'])))
tab_eval_final_inscription_id.append(ObjectId(str(eval_inscription_id)))
# Sauvegarde des fichiers joints depuis le front
tab_saved_file_full_path = []
for file in tab_files:
status, saved_file_full_path = mycommon.Upload_Save_PDF_IMG_File(file, Folder)
if (status is False):
return status, saved_file_full_path
tab_saved_file_full_path.append(saved_file_full_path)
# Traitement de l'eventuel fichier joint
tab_files_to_attache_to_mail = []
for saved_file in tab_saved_file_full_path:
file_to_attache_to_mail = MIMEBase('application', "octet-stream")
file_to_attache_to_mail.set_payload(open(saved_file, "rb").read())
encoders.encode_base64(file_to_attache_to_mail)
file_to_attache_to_mail.add_header('Content-Disposition',
'attachment; filename="{0}"'.format(os.path.basename(saved_file)))
new_node = {"attached_file": file_to_attache_to_mail}
tab_files_to_attache_to_mail.append(new_node)
# Creation du dictionnaire d'information à utiliser pour la creation du doc
convention_dictionnary_data = {}
new_diction = {}
new_diction['token'] = diction['token']
new_diction['list_stagiaire_id'] = []
new_diction['list_session_id'] = []
new_diction['list_class_id'] = []
new_diction['list_client_id'] = []
new_diction['list_apprenant_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
convention_dictionnary_data['evaluation_data'] = evaluation_data
convention_dictionnary_data['evaluation_class_data'] = eval_class_data
convention_dictionnary_data['evaluation_ue_data'] = eval_eu_data
"""
Recuperer le modèle de document
"""
courrier_data_retval = MYSY_GV.dbname['courrier_template'].find_one(
{'partner_owner_recid': str(my_partner['recid']),
'valide': '1',
'locked': '0',
'_id': ObjectId(str(diction['courrier_template_id']))})
if ("contenu_doc" not in courrier_data_retval.keys() or str(courrier_data_retval['contenu_doc']) == ""):
mycommon.myprint(
str(inspect.stack()[0][
3]) + " Le modèle de courrier 'EVALUATION_CONVOCATION' n'est pas correctement configuré ")
return False, " Le modèle de courrier 'EVALUATION_CONVOCATION' n'est pas correctement configuré "
if ("corps_mail" not in courrier_data_retval.keys() or str(courrier_data_retval['corps_mail']) == ""):
mycommon.myprint(
str(inspect.stack()[0][
3]) + " Le modèle de courrier 'EVALUATION_CONVOCATION' n'est pas correctement configuré (2) ")
return False, " Le modèle de courrier 'EVALUATION_CONVOCATION' n'est pas correctement configuré (2) "
# Recuperation des eventuelles pièces jointes du modèle que courrier
local_dic = {}
local_dic['token'] = str(diction['token'])
local_dic['object_owner_collection'] = "courrier_template"
local_dic['object_owner_id'] = str(courrier_data_retval['_id'])
local_status, local_retval = attached_file_mgt.Get_List_object_owner_collection_Stored_Files(local_dic)
if (local_status is False):
return local_status, local_retval
# Recuperation des donnes smtp
local_stpm_status, partner_SMTP_COUNT_smtpsrv, partner_own_smtp_value, partner_SMTP_COUNT_password, partner_SMTP_COUNT_user, \
partner_SMTP_COUNT_From_User, partner_SMTP_COUNT_port = mycommon.Get_Partner_SMTP_Param(
my_partner['recid'])
if (local_stpm_status is False):
return local_stpm_status, partner_own_smtp_value
if (str(partner_own_smtp_value) == "1"):
smtpserver = smtplib.SMTP(partner_SMTP_COUNT_smtpsrv, partner_SMTP_COUNT_port)
else:
smtpserver = smtplib.SMTP(MYSY_GV.O365_SMTP_COUNT_smtpsrv, MYSY_GV.O365_SMTP_COUNT_port)
smtpserver.ehlo()
smtpserver.starttls()
smtpserver.login(MYSY_GV.O365_SMTP_COUNT_user, MYSY_GV.O365_SMTP_COUNT_password)
for inscription_id in tab_final_inscription_id:
inscription_id_data = MYSY_GV.dbname['inscription'].find_one(
{'_id': ObjectId(str(inscription_id)),
'partner_owner_recid': str(my_partner['recid'])})
email_to_cc = []
email_to_bcc = []
email_to_bcc.append(str(my_partner['email']))
email_to_bcc.append('contact@mysy-training.com')
"""
Recuperer les données de contact du client si l'inscrit est lié à un client
"""
if( "client_rattachement_id" in inscription_id_data.keys() and inscription_id_data['client_rattachement_id']):
# Recuperation des contacts de communication du client
local_diction = {}
local_diction['token'] = diction['token']
local_diction['_id'] = str(inscription_id_data['client_rattachement_id'])
local_status, partner_client_contact_communication = partner_client.Get_Partner_Client_Communication_Contact( local_diction)
if (local_status is True):
for contact_communication_str in partner_client_contact_communication:
contact_communication = ast.literal_eval(contact_communication_str)
email_to_cc.append(contact_communication['email'])
apprenant_id_data = None
if( "apprenant_id" in inscription_id_data.keys() and inscription_id_data['apprenant_id']):
apprenant_id_data = MYSY_GV.dbname['apprenant'].find_one(
{'_id': ObjectId(str(inscription_id_data['apprenant_id'])),
'partner_owner_recid': str(my_partner['recid'])})
convention_dictionnary_data['evaluation_apprenant_data'] = apprenant_id_data
body = {
"params": convention_dictionnary_data,
}
# Verifier s'il s'agit d'un document à envoyer avec une version de pièce jointe.
if ("joint_pdf" in courrier_data_retval.keys() and str(courrier_data_retval['joint_pdf']) == "1"):
# Il s'agit bien d'un envoie avec 'contenu_doc' en pièce jointe PDF
"""
1 - Creation du PDF
"""
contenu_doc_Template = jinja2.Template(str(courrier_data_retval['contenu_doc']))
sourceHtml = contenu_doc_Template.render(params=body["params"])
todays_date = str(date.today().strftime("%d/%m/%Y"))
ts = datetime.now().timestamp()
ts = str(ts).replace(".", "").replace(",", "")[-5:]
orig_file_name = "Evaluation_Convocation_" + str(my_partner['recid'])[0:5] + "_" + str(ts) + ".pdf"
outputFilename = str(MYSY_GV.TEMPORARY_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()
# Attachement du fichier joint
file_to_attache_to_mail = MIMEBase('application', "octet-stream")
file_to_attache_to_mail.set_payload(open(outputFilename, "rb").read())
encoders.encode_base64(file_to_attache_to_mail)
file_to_attache_to_mail.add_header('Content-Disposition',
'attachment; filename="{0}"'.format(
os.path.basename(outputFilename)))
new_node = {"attached_file": file_to_attache_to_mail}
single_inscription_tab_files_to_attache_to_mail = []
for file in tab_files_to_attache_to_mail:
single_inscription_tab_files_to_attache_to_mail.append(file)
single_inscription_tab_files_to_attache_to_mail.append(new_node)
# Traitement du sujet du mail
sujet_mail_Template = jinja2.Template(str(courrier_data_retval['sujet']))
sujetHtml = sujet_mail_Template.render(params=body["params"])
# Traitement du corps du mail
corps_Template = jinja2.Template(str(courrier_data_retval['corps_mail']))
corpsHtml = corps_Template.render(params=body["params"])
html_mime = MIMEText(corpsHtml, 'html')
# Creation de l'email à enoyer
msg = MIMEMultipart("alternative")
else:
# Il s'agit d'une simple email
# Traitement du sujet du mail
sujet_mail_Template = jinja2.Template(str(courrier_data_retval['sujet']))
sujetHtml = sujet_mail_Template.render(params=body["params"])
# Traitement du corps du mail
corps_Template = jinja2.Template(str(courrier_data_retval['corps_mail']))
corpsHtml = corps_Template.render(params=body["params"])
html_mime = MIMEText(corpsHtml, 'html')
# Creation de l'email à envoyer
msg = MIMEMultipart("alternative")
if (str(partner_own_smtp_value) == "1"):
msg.attach(html_mime)
msg['From'] = partner_SMTP_COUNT_From_User
msg['Subject'] = sujetHtml
email_to_bcc = ", ".join(email_to_bcc)
msg['Bcc'] = str(email_to_bcc)
toaddrs = ", ".join(email_to_cc)
msg['to'] = str(toaddrs)
# Attacher l'eventuelle pièces jointes
for myfile in single_inscription_tab_files_to_attache_to_mail:
msg.attach(myfile['attached_file'])
val = smtpserver.send_message(msg)
print("Email convocation evaluation envoyé " + str(val))
else:
msg.attach(html_mime)
msg['From'] = MYSY_GV.O365_SMTP_COUNT_From_User
msg['Subject'] = sujetHtml
email_to_bcc = ", ".join(email_to_bcc)
msg['Bcc'] = str(email_to_bcc)
toaddrs = ", ".join(email_to_cc)
msg['to'] = str(toaddrs)
# Attacher l'eventuelle pièces jointes
for myfile in single_inscription_tab_files_to_attache_to_mail:
msg.attach(myfile['attached_file'])
val = smtpserver.send_message(msg)
print("Email convocation evaluation envoyé " + str(val))
"""
Mettre à jour note_evaluation_participant pour dire que la convocation a été envoyée
"""
now = str(datetime.now())
MYSY_GV.dbname['note_evaluation_participant'].update_many({'_id':{'$in':tab_eval_final_inscription_id}, 'partner_owner_recid':str(my_partner['recid'])},
{'$set':{'convocation_send_date':now, 'convocation_send_by':str(my_partner['_id']),
'convocation_send_type':'email'}})
smtpserver.close()
return True, "Les convocations à l'évaluation ont été correctement envoyées "
except Exception as e:
exc_type, exc_obj, exc_tb = sys.exc_info()
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - Line : " + str(exc_tb.tb_lineno))
return False, "Impossible d'envoyer es convocations à l'évaluation "
"""
Cette fonction permet de créer et telecharger une convocation
a un examen au format PDF
"""
def Send_Evaluation_Convocation_Participant_By_PDF(diction):
try:
diction = mycommon.strip_dictionary(diction)
"""
Verification des input acceptés
"""
field_list = ['token', 'evaluation_id', 'tab_eval_inscription_id', 'courrier_template_id']
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é")
return False, " Les informations fournies sont incorrectes"
"""
Verification des champs obligatoires
"""
field_list_obligatoire = ['token', 'evaluation_id', 'tab_eval_inscription_id', 'courrier_template_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 sont incorrectes"
"""
Verification de l'identité et autorisation de l'entité qui
appelle cette API
"""
token = ""
if ("token" in diction.keys()):
if diction['token']:
token = diction['token']
local_status, my_partner = mycommon.Check_Connexion_And_Return_Partner_Data(diction)
if (local_status is not True):
return local_status, my_partner
"""
Verifier que l'evaluation est valide
"""
is_evaluation_valide = MYSY_GV.dbname['note_evaluation'].count_documents(
{"_id": ObjectId(str(diction['evaluation_id'])),
'valide': '1',
'locked': '0',
'partner_owner_recid': str(my_partner['recid'])})
if (is_evaluation_valide != 1):
mycommon.myprint(
str(inspect.stack()[0][3]) + " L'identifiant de l'évaluation n'est pas valide ")
return False, " L'identifiant de l'évaluation n'est pas valide "
evaluation_data = MYSY_GV.dbname['note_evaluation'].find_one(
{"_id": ObjectId(str(diction['evaluation_id'])),
'valide': '1',
'locked': '0',
'partner_owner_recid': str(my_partner['recid'])})
eval_class_data = None
if( "class_id" in evaluation_data.keys() and evaluation_data['class_id']):
eval_class_data = MYSY_GV.dbname['myclass'].find_one({'_id':ObjectId(str(evaluation_data['class_id'])),
'partner_owner_recid':str(my_partner['recid'])})
eval_eu_data = None
if ("class_eu_id" in evaluation_data.keys() and evaluation_data['class_eu_id']):
eval_eu_data = MYSY_GV.dbname['unite_enseignement'].find_one({'_id': ObjectId(str(evaluation_data['class_eu_id'])),
'partner_owner_recid': str(my_partner['recid'])})
tab_eval_final_inscription_id = []
tab_final_inscription_id = []
tab_eval_inscription_id = str(diction['tab_eval_inscription_id']).split(",")
for eval_inscription_id in tab_eval_inscription_id:
if( eval_inscription_id ):
# Verifier que le stagiaire est bien inscrit. Le statut de l'inscription doit etre "1"
is_eval_inscription_valide = MYSY_GV.dbname['note_evaluation_participant'].count_documents(
{'_id': ObjectId(str(eval_inscription_id)),
'partner_owner_recid': str(my_partner['recid'])})
if (is_eval_inscription_valide != 1):
mycommon.myprint(
str(inspect.stack()[0][
3]) + " L'identifiant de la note_evaluation_participant " + str(eval_inscription_id) + " est invalide ")
return False, " L'identifiant de la note_evaluation_participant " + str(eval_inscription_id) + " est invalide "
is_eval_inscription_data = MYSY_GV.dbname['note_evaluation_participant'].find_one(
{'_id': ObjectId(str(eval_inscription_id)),
'partner_owner_recid': str(my_partner['recid'])})
tab_final_inscription_id.append(ObjectId(str(is_eval_inscription_data['inscription_id'])))
tab_eval_final_inscription_id.append(ObjectId(str(eval_inscription_id)))
# Creation du dictionnaire d'information à utiliser pour la creation du doc
convention_dictionnary_data = {}
new_diction = {}
new_diction['token'] = diction['token']
new_diction['list_stagiaire_id'] = []
new_diction['list_session_id'] = []
new_diction['list_class_id'] = []
new_diction['list_client_id'] = []
new_diction['list_apprenant_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
convention_dictionnary_data['evaluation_data'] = evaluation_data
convention_dictionnary_data['evaluation_class_data'] = eval_class_data
convention_dictionnary_data['evaluation_ue_data'] = eval_eu_data
"""
Recuperer le modèle de document
"""
courrier_data_retval = MYSY_GV.dbname['courrier_template'].find_one(
{'partner_owner_recid': str(my_partner['recid']),
'valide': '1',
'locked': '0',
'_id':ObjectId(str(diction['courrier_template_id']))})
if ("contenu_doc" not in courrier_data_retval.keys() or str(courrier_data_retval['contenu_doc']) == ""):
mycommon.myprint(
str(inspect.stack()[0][
3]) + " Le modèle de courrier 'EVALUATION_CONVOCATION' n'est pas correctement configuré ")
return False, " Le modèle de courrier 'EVALUATION_CONVOCATION' n'est pas correctement configuré "
# Stokage des nom de fichier à zipper
list_file_name_to_zip = []
for inscription_id in tab_final_inscription_id:
inscription_id_data = MYSY_GV.dbname['inscription'].find_one(
{'_id': ObjectId(str(inscription_id)),
'partner_owner_recid': str(my_partner['recid'])})
"""
Recuperer les données de contact du client si l'inscrit est lié à un client
"""
if( "client_rattachement_id" in inscription_id_data.keys() and inscription_id_data['client_rattachement_id']):
# Recuperation des contacts de communication du client
local_diction = {}
local_diction['token'] = diction['token']
local_diction['_id'] = str(inscription_id_data['client_rattachement_id'])
local_status, partner_client_contact_communication = partner_client.Get_Partner_Client_Communication_Contact( local_diction)
if (local_status is True):
for contact_communication_str in partner_client_contact_communication:
contact_communication = ast.literal_eval(contact_communication_str)
apprenant_id_data = None
if( "apprenant_id" in inscription_id_data.keys() and inscription_id_data['apprenant_id']):
apprenant_id_data = MYSY_GV.dbname['apprenant'].find_one(
{'_id': ObjectId(str(inscription_id_data['apprenant_id'])),
'partner_owner_recid': str(my_partner['recid'])})
convention_dictionnary_data['evaluation_apprenant_data'] = apprenant_id_data
body = {
"params": convention_dictionnary_data,
}
"""
1 - Creation du PDF
"""
contenu_doc_Template = jinja2.Template(str(courrier_data_retval['contenu_doc']))
sourceHtml = contenu_doc_Template.render(params=body["params"])
todays_date = str(date.today().strftime("%d/%m/%Y"))
ts = datetime.now().timestamp()
ts = str(ts).replace(".", "").replace(",", "")[-5:]
orig_file_name = "Eval_Convocation_"+str(apprenant_id_data['nom']) + "_" + str(ts) + ".pdf"
outputFilename = str(MYSY_GV.TEMPORARY_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()
list_file_name_to_zip.append(str(outputFilename))
"""
Mettre à jour note_evaluation_participant pour dire que la convocation a été envoyée
"""
now = str(datetime.now())
MYSY_GV.dbname['note_evaluation_participant'].update_many(
{'_id': {'$in': tab_eval_final_inscription_id}, 'partner_owner_recid': str(my_partner['recid'])},
{'$set': {'convocation_send_date': now, 'convocation_send_by': str(my_partner['_id']),
'convocation_send_type': 'pdf'}})
# Create a ZipFile Object
todays_date = str(date.today().strftime("%d/%m/%Y"))
ts = datetime.now().timestamp()
ts = str(ts).replace(".", "").replace(",", "")[-3:]
zip_file_name = str(MYSY_GV.TEMPORARY_DIRECTORY_V2) + "List_Convocation_Evaluation_" + str(ts) + ".zip"
with ZipFile(zip_file_name, 'w') as zip_object:
for pdf_files in list_file_name_to_zip:
zip_object.write(str(pdf_files))
if os.path.exists(zip_file_name):
# print(" ### ok os.path.exists(outputFilename) "+str(outputFilename))
return True, send_file(zip_file_name, as_attachment=True)
return False, " Impossible de générer les convocation par PDF (1) "
except Exception as e:
exc_type, exc_obj, exc_tb = sys.exc_info()
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - Line : " + str(exc_tb.tb_lineno))
return False, " Impossible de générer les convocation par PDF (1) "
""" """
Mise à jour note evaluation Mise à jour note evaluation
Cette fonction met à jour la note d'un inscrit ou groupe d'inscrit. Cette fonction met à jour la note d'un inscrit ou groupe d'inscrit.
@ -1267,6 +1889,14 @@ def Get_List_Participant_To_Evaluation(diction):
if( "note" not in retval.keys() ): if( "note" not in retval.keys() ):
user['note'] = "-1" user['note'] = "-1"
if( "convocation_send_date" not in user.keys() ):
user['convocation_send_date'] = ""
if ("convocation_send_type" not in user.keys()):
user['convocation_send_type'] = ""
nb_val = nb_val + 1 nb_val = nb_val + 1
RetObject.append(mycommon.JSONEncoder().encode(user)) RetObject.append(mycommon.JSONEncoder().encode(user))

View File

@ -3260,7 +3260,7 @@ def Get_Given_Partner_Order(diction):
RetObject.append(mycommon.JSONEncoder().encode(user)) RetObject.append(mycommon.JSONEncoder().encode(user))
print(" ### RetObject Get_Given_Partner_Order = ", RetObject) #print(" ### RetObject Get_Given_Partner_Order = ", RetObject)
return True, RetObject return True, RetObject
@ -6043,7 +6043,7 @@ def Gernerate_Stock_PDF_Partner_Order(diction):
""" """
Envoie de la commande par email Envoie de la commande par email
""" """
def Send_Partner_Order_By_Email(diction): def Send_Partner_Order_By_Email(tab_files, Folder, diction):
try: try:
field_list = ['order_id', 'token', 'request_digital_signature'] field_list = ['order_id', 'token', 'request_digital_signature']
incom_keys = diction.keys() incom_keys = diction.keys()
@ -6463,6 +6463,30 @@ def Send_Partner_Order_By_Email(diction):
3]) + " - Aucune ligne de détail pour cette commande ") 3]) + " - Aucune ligne de détail pour cette commande ")
return False, " Aucune ligne de détail pour cette commande " return False, " Aucune ligne de détail pour cette commande "
# Sauvegarde des fichiers joints depuis le front
tab_saved_file_full_path = []
for file in tab_files:
status, saved_file_full_path = mycommon.Upload_Save_PDF_IMG_File(file, Folder)
if (status is False):
return status, saved_file_full_path
tab_saved_file_full_path.append(saved_file_full_path)
# Traitement de l'eventuel fichier joint
tab_files_to_attache_to_mail = []
for saved_file in tab_saved_file_full_path:
file_to_attache_to_mail = MIMEBase('application', "octet-stream")
file_to_attache_to_mail.set_payload(open(saved_file, "rb").read())
encoders.encode_base64(file_to_attache_to_mail)
file_to_attache_to_mail.add_header('Content-Disposition',
'attachment; filename="{0}"'.format(os.path.basename(saved_file)))
new_node = {"attached_file": file_to_attache_to_mail}
tab_files_to_attache_to_mail.append(new_node)
print(" ## tab_files_to_attache_to_mail 01 = ", tab_files_to_attache_to_mail)
# Creation du dictionnaire d'information à utiliser pour la creation du doc # Creation du dictionnaire d'information à utiliser pour la creation du doc
tab_client = [] tab_client = []
@ -6491,8 +6515,6 @@ def Send_Partner_Order_By_Email(diction):
"params": convention_dictionnary_data, "params": convention_dictionnary_data,
} }
# Traitement de l'eventuel fichier joint
tab_files_to_attache_to_mail = []
# Verifier s'il s'agit d'un document à envoyer avec une version de pièce jointe. # Verifier s'il s'agit d'un document à envoyer avec une version de pièce jointe.
if ("joint_pdf" in partner_document_CONF_ORDER_data.keys() and str(partner_document_CONF_ORDER_data['joint_pdf']) == "1"): if ("joint_pdf" in partner_document_CONF_ORDER_data.keys() and str(partner_document_CONF_ORDER_data['joint_pdf']) == "1"):
@ -6537,6 +6559,8 @@ def Send_Partner_Order_By_Email(diction):
corps_mail_doc_Template = jinja2.Template(str(partner_document_CONF_ORDER_data['corps_mail'])) corps_mail_doc_Template = jinja2.Template(str(partner_document_CONF_ORDER_data['corps_mail']))
sujet_doc_Template_subject = jinja2.Template(str(partner_document_CONF_ORDER_data['sujet'])) sujet_doc_Template_subject = jinja2.Template(str(partner_document_CONF_ORDER_data['sujet']))
#print(" #### Order_header_data = ", Order_header_data) #print(" #### Order_header_data = ", Order_header_data)
Order_header_data['order_header_type'] = str(Order_header_data['order_header_type']).capitalize() Order_header_data['order_header_type'] = str(Order_header_data['order_header_type']).capitalize()

View File

@ -120,9 +120,9 @@ def add_partner_account(diction):
if (mycommon.isEmailValide(diction['email']) is False): if (mycommon.isEmailValide(diction['email']) is False):
mycommon.myprint( mycommon.myprint(
str(inspect.stack()[0][ str(inspect.stack()[0][
3]) + " - L'adresse email " + str(diction['email']) + " n'est pas valide") 3]) + " L'adresse email " + str(diction['email']) + " n'est pas valide")
return False, " - - L'adresse email " + str(diction['email']) + " n'est pas valide " return False, " L'adresse email " + str(diction['email']) + " n'est pas valide "
if ("telephone" in diction.keys()): if ("telephone" in diction.keys()):
@ -150,6 +150,7 @@ def add_partner_account(diction):
if diction['contact_mail']: if diction['contact_mail']:
mydata['contact_mail'] = diction['contact_mail'] mydata['contact_mail'] = diction['contact_mail']
if ("link_linkedin" in diction.keys()): if ("link_linkedin" in diction.keys()):
if diction['link_linkedin']: if diction['link_linkedin']:
mydata['link_linkedin'] = diction['link_linkedin'] mydata['link_linkedin'] = diction['link_linkedin']
@ -619,7 +620,7 @@ def update_partner_account(file_logo=None, file_cachet=None, Folder=None, dictio
'invoice_adr_country', 'invoice_email', 'invoice_telephone', 'invoice_adr_country', 'invoice_email', 'invoice_telephone',
'siret', 'num_nda', 'iscertitrace', 'isdatadock', 'isqualiopi', 'website', 'siret', 'num_nda', 'iscertitrace', 'isdatadock', 'isqualiopi', 'website',
'isbureaucertitrace', 'iscertifvoltaire', 'file_logo_recid', 'file_cachet_recid', 'isbureaucertitrace', 'iscertifvoltaire', 'file_logo_recid', 'file_cachet_recid',
'partner_account_id', 'invoice_taux_vat', 'subdomaine_catalog_pub' ] 'partner_account_id', 'invoice_taux_vat', 'subdomaine_catalog_pub', ]
incom_keys = diction.keys() incom_keys = diction.keys()
@ -752,6 +753,8 @@ def update_partner_account(file_logo=None, file_cachet=None, Folder=None, dictio
if ("contact_mail" in diction.keys()): if ("contact_mail" in diction.keys()):
mydata['contact_mail'] = diction['contact_mail'] mydata['contact_mail'] = diction['contact_mail']
if ("link_linkedin" in diction.keys()): if ("link_linkedin" in diction.keys()):
mydata['link_linkedin'] = diction['link_linkedin'] mydata['link_linkedin'] = diction['link_linkedin']

View File

@ -5485,6 +5485,7 @@ def Get_Partner_SMTP_Param(partner_recid):
partner_SMTP_COUNT_port = "" partner_SMTP_COUNT_port = ""
partner_own_smtp = MYSY_GV.dbname['base_partner_setup'].find_one( partner_own_smtp = MYSY_GV.dbname['base_partner_setup'].find_one(
{'partner_owner_recid': str(partner_recid), {'partner_owner_recid': str(partner_recid),
'config_name': 'partner_smtp', 'config_name': 'partner_smtp',

View File

@ -339,7 +339,8 @@ def Add_Ressource_Humaine(diction):
field_list = ['token', "nom", "email", "telephone", "website", "comment",'adr_adresse', 'adr_code_postal', field_list = ['token', "nom", "email", "telephone", "website", "comment",'adr_adresse', 'adr_code_postal',
'adr_ville', 'adr_pays', 'profil', 'telephone_mobile', 'linkedin', 'adr_ville', 'adr_pays', 'profil', 'telephone_mobile', 'linkedin',
'facebook', 'twitter', 'prenom', 'fonction', 'civilite', 'superieur_hierarchie_id', 'ismanager', 'facebook', 'twitter', 'prenom', 'fonction', 'civilite', 'superieur_hierarchie_id', 'ismanager',
'groupe_prix_achat_id', 'prix_achat', 'type_contrat', 'gategorie', 'date_naissance', 'competence' 'groupe_prix_achat_id', 'prix_achat', 'type_contrat', 'gategorie', 'date_naissance', 'competence',
'diffusion_mail'
] ]
incom_keys = diction.keys() incom_keys = diction.keys()
@ -472,6 +473,25 @@ def Add_Ressource_Humaine(diction):
gategorie = diction['gategorie'] gategorie = diction['gategorie']
data['gategorie'] = gategorie data['gategorie'] = gategorie
diffusion_mail = ""
if ("diffusion_mail" in diction.keys()):
if (diction['diffusion_mail']):
# Verifier les list de diffusion
tab_list_diffusion = str(diction['diffusion_mail']).replace(";", ",").strip().split(",")
for mail_diffusion in tab_list_diffusion:
if (mycommon.isEmailValide(mail_diffusion) is False):
mycommon.myprint(
str(inspect.stack()[0][
3]) + " Liste de diffusion : L'adresse email " + str(
mail_diffusion) + " n'est pas valide")
return False, " Liste de diffusion : : L'adresse email " + str(
mail_diffusion) + " n'est pas valide "
diffusion_mail = str(diction['diffusion_mail']).strip()
data['diffusion_mail'] = diffusion_mail
ismanager = "0" ismanager = "0"
@ -676,7 +696,7 @@ def Update_Ressource_Humaine(diction):
'adr_ville', 'adr_pays', 'profil', 'telephone_mobile', 'linkedin', 'adr_ville', 'adr_pays', 'profil', 'telephone_mobile', 'linkedin',
'facebook', 'twitter', '_id', 'prenom', 'fonction', 'civilite', 'facebook', 'twitter', '_id', 'prenom', 'fonction', 'civilite',
'superieur_hierarchie_id', 'ismanager', 'groupe_prix_achat_id', 'prix_achat', 'type_contrat', 'superieur_hierarchie_id', 'ismanager', 'groupe_prix_achat_id', 'prix_achat', 'type_contrat',
'gategorie', 'date_naissance', 'competence'] 'gategorie', 'date_naissance', 'competence', 'diffusion_mail']
incom_keys = diction.keys() incom_keys = diction.keys()
@ -846,6 +866,22 @@ def Update_Ressource_Humaine(diction):
data_update['superieur_hierarchie_id'] = diction['superieur_hierarchie_id'] data_update['superieur_hierarchie_id'] = diction['superieur_hierarchie_id']
if ("diffusion_mail" in diction.keys()):
if( diction['diffusion_mail']):
# Verifier les list de diffusion
tab_list_diffusion = str(diction['diffusion_mail']).replace(";", ",").strip().split(",")
for mail_diffusion in tab_list_diffusion:
if (mycommon.isEmailValide(mail_diffusion) is False):
mycommon.myprint(
str(inspect.stack()[0][
3]) + " Liste de diffusion : L'adresse email " + str(
mail_diffusion) + " n'est pas valide")
return False, " Liste de diffusion : : L'adresse email " + str(
mail_diffusion) + " n'est pas valide "
data_update['diffusion_mail'] = str(diction['diffusion_mail']).strip()
profil = "" profil = ""
if ("profil" in diction.keys()): if ("profil" in diction.keys()):
@ -1320,6 +1356,7 @@ def Get_List_Profil_Ressource_Humaine(diction):
RetObject.append(mycommon.JSONEncoder().encode(user)) RetObject.append(mycommon.JSONEncoder().encode(user))
return True, RetObject return True, RetObject