16/12/2023 - 23h12

master
cherif 2023-12-16 23:13:27 +01:00
parent 18c251e2a2
commit 42c7e2b590
7 changed files with 4254 additions and 120 deletions

View File

@ -3,10 +3,12 @@
<component name="ChangeListManager">
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="15/12/2023 - 18h">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Collection_Historique.py" beforeDir="false" afterPath="$PROJECT_DIR$/Collection_Historique.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Dashbord_queries/session_tbd_qries.py" beforeDir="false" afterPath="$PROJECT_DIR$/Dashbord_queries/session_tbd_qries.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$/Session_Formation.py" beforeDir="false" afterPath="$PROJECT_DIR$/Session_Formation.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/partner_document_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/partner_document_mgt.py" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />

View File

@ -298,7 +298,7 @@ def Get_Qery_Session_By_Trainer_By_Periode(diction):
filt_session_end_date_ISODATE = datetime.strptime(str(filt_session_end_date), '%d/%m/%Y')
qery_match = {'$and': [ {"partner_owner_recid":str(my_partner['recid']) }, {"valide":'1'}, {"formateur_id": { "$exists": 'true' } }, { 'mysy_date_debut_session': { '$gte': filt_session_start_date_ISODATE, '$lte': filt_session_end_date_ISODATE } } , ]}
qery_match = {'$and': [ {"partner_owner_recid":str(my_partner['recid']) }, {"valide":'1'}, {"formateur_id": { "$exists": True } }, { 'mysy_date_debut_session': { '$gte': filt_session_start_date_ISODATE, '$lte': filt_session_end_date_ISODATE } } , ]}
pipe_qry = ([
{"$addFields": {

View File

@ -6146,11 +6146,16 @@ adresse email de test, on accepte en non obligatoire
/!\ : Regle de gestion :
Si le modele de courrier est 'edit_by_client', alors le mail est envoyé au contact de communication
1) Si le modele de courrier est 'edit_by_client', alors le mail est envoyé au contact de communication
du client rattaché au stagiaire.
Si le stagiaire n'a pas de client rattacher, le système retourne un message d'erreur.
2) Règle d'utilisation des emails destinantaire
Si 'email_test' est rempli, on envoie l'email de test si non
Si 'email_production' on prend cette liste d'adresse si non
On va chercher les adresse de communication par defaut de l'apprenant
"""
def Sent_Convention_Stagiaire_By_Email(tab_files, Folder, diction):
try:
@ -6220,9 +6225,12 @@ def Sent_Convention_Stagiaire_By_Email(tab_files, Folder, diction):
"""
send_in_production = 0
tab_emails_destinataire = []
if( "email_test" in diction.keys() and diction['email_test']):
tab_email_test = str(diction['email_test']).replace(";",",").split(",")
for email in tab_email_test:
@ -6246,16 +6254,33 @@ def Sent_Convention_Stagiaire_By_Email(tab_files, Folder, diction):
3]) + " L'adresse email '" + str(email) + "' est invalide ")
return False, " L'adresse email " + str(email) + " est invalide "
tab_emails_destinataire = tab_email_prod
else:
tab_email_prod = "default"
else:
send_in_production = 1
# On va chercher les adresse email de communication du
local_dict = {'token':str(diction['token']), '_id':str(diction['inscription_id'])}
local_status, tab_apprenant_contact = Get_Statgiaire_Communication_Contact(local_dict)
if( local_status is False ):
return local_status, tab_apprenant_contact
tmp_tab = []
print(" ### tab_apprenant_contact = ", tab_apprenant_contact)
for tmp in tab_apprenant_contact :
if("email" in tmp.keys() ):
tab_emails_destinataire.append((tmp['email']))
if(len(tab_emails_destinataire) <= 0 ):
mycommon.myprint(
str(inspect.stack()[0][
3]) + " Aucune adresse email n'a été fourni. ")
return False, " Aucune adresse email n'a été fourni. "
print(" ### tab_emails_destinataire = ", tab_emails_destinataire)
# Verifier que le 'courrier_template_id' est valide
# Ici le template doit etre un email
is_courrier_template_id_valide = MYSY_GV.dbname['courrier_template'].count_documents({'_id':ObjectId(str(diction['courrier_template_id'])),
@ -7053,7 +7078,7 @@ def Download_Convention_Stagiaire_PDF_By_Partner_client(diction):
"""
Envoie par email pour les stagiaires rattachés à un client
"""
def Sent_Convention_Stagiaire_By_Email_By_Partner_client(tab_files, Folder, diction):
def Sent_Convention_Stagiaire_By_Email_By_Partner_client(tab_files_name_full_path, Folder, diction):
try:
field_list_obligatoire = ['token', 'courrier_template_id', 'email_test', 'email_production', 'partner_client_id', 'session_id']
@ -7108,18 +7133,19 @@ def Sent_Convention_Stagiaire_By_Email_By_Partner_client(tab_files, Folder, dict
# Traitement de l'eventuel fichier joint
tab_files_to_attache_to_mail = []
for file in tab_files:
status, saved_file = mycommon.Upload_Save_PDF_IMG_File(file, Folder)
for file_name_full_path in tab_files_name_full_path:
"""status, saved_file = mycommon.Upload_Save_PDF_IMG_File(file, Folder)
if (status is False):
mycommon.myprint("Impossible de récupérer correctement le fichier à importer")
return False, "Impossible de récupérer correctement le fichier à importer"
"""
file_to_attache_to_mail = MIMEBase('application', "octet-stream")
file_to_attache_to_mail.set_payload(open(saved_file, "rb").read())
file_to_attache_to_mail.set_payload(open(file_name_full_path, "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)))
'attachment; filename="{0}"'.format(os.path.basename(file_name_full_path)))
new_node = {"attached_file": file_to_attache_to_mail}
tab_files_to_attache_to_mail.append(new_node)
@ -7543,4 +7569,214 @@ def Get_Stagiaire_Communication_List_Email(diction):
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 récupérer la liste des emails de communication "
return False, " Impossible de récupérer la liste des emails de communication "
"""
Cette fonction permet de recuperer les contacts de communication d'un stagiaire.
Par exemple :
- le stagiaire, le tuteur1 et le tuteur 2
"""
def Get_Statgiaire_Communication_Contact(diction):
try:
diction = mycommon.strip_dictionary(diction)
"""
Verification des input acceptés
"""
field_list = ['token','_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'existe pas")
return False, " Les informations fournies sont incorrectes",
"""
Verification des champs obligatoires
"""
field_list_obligatoire = ['token','_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 la validité du client
is_stagiaire_exist_valide = MYSY_GV.dbname['inscription'].count_documents({"_id":ObjectId(str(diction['_id'])),
'partner_owner_recid':str(my_partner['recid'])})
if( is_stagiaire_exist_valide <= 0 ):
mycommon.myprint(
str(inspect.stack()[0][3]) + " - L'identifiant du stagiaire est invalide ")
return False, " L'identifiant du stagiaire est invalide ",
# Verifier la validité du client
stagiaire_data = MYSY_GV.dbname['inscription'].find_one(
{"_id": ObjectId(str(diction['_id'])),
'partner_owner_recid': str(my_partner['recid'])})
tab_stagiaire_contact_communication = []
# Ajout des datas du stagiaire
new_node = {}
if ("nom" in stagiaire_data.keys()):
new_node['nom'] = stagiaire_data['nom']
else:
new_node['nom'] = ""
if ("prenom" in stagiaire_data.keys()):
new_node['prenom'] = stagiaire_data['prenom']
else:
new_node['prenom'] = ""
if ("adresse" in stagiaire_data.keys()):
new_node['adresse'] = stagiaire_data['adresse']
else:
new_node['adresse'] = ""
if ("code_postal" in stagiaire_data.keys()):
new_node['code_postal'] = stagiaire_data['code_postal']
else:
new_node['code_postal'] = ""
if ("ville" in stagiaire_data.keys()):
new_node['ville'] = stagiaire_data['ville']
else:
new_node['ville'] = ""
if ("pays" in stagiaire_data.keys()):
new_node['pays'] = stagiaire_data['pays']
else:
new_node['pays'] = ""
if ("email" in stagiaire_data.keys()):
new_node['email'] = stagiaire_data['email']
else:
new_node['email'] = ""
if ("telephone" in stagiaire_data.keys()):
new_node['telephone'] = stagiaire_data['telephone']
else:
new_node['telephone'] = ""
tab_stagiaire_contact_communication.append(new_node)
# Ajout des datas du tuteur 1 s'il est autorisé
if( stagiaire_data and "tuteur1_include_com" in stagiaire_data.keys() and str(stagiaire_data['tuteur1_include_com']) == "1" ):
new_node = {}
if( "tuteur1_nom" in stagiaire_data.keys()):
new_node['nom'] = stagiaire_data['tuteur1_nom']
else:
new_node['nom'] = ""
if ("tuteur1_prenom" in stagiaire_data.keys()):
new_node['prenom'] = stagiaire_data['tuteur1_prenom']
else:
new_node['prenom'] = ""
if ("tuteur1_adresse" in stagiaire_data.keys()):
new_node['adresse'] = stagiaire_data['tuteur1_adresse']
else:
new_node['adresse'] = ""
if ("tuteur1_cp" in stagiaire_data.keys()):
new_node['code_postal'] = stagiaire_data['tuteur1_cp']
else:
new_node['code_postal'] = ""
if ("tuteur1_ville" in stagiaire_data.keys()):
new_node['ville'] = stagiaire_data['tuteur1_ville']
else:
new_node['ville'] = ""
if ("tuteur1_pays" in stagiaire_data.keys()):
new_node['pays'] = stagiaire_data['tuteur1_pays']
else:
new_node['pays'] = ""
if ("tuteur1_email" in stagiaire_data.keys()):
new_node['email'] = stagiaire_data['tuteur1_email']
else:
new_node['email'] = ""
if ("tuteur1_telephone" in stagiaire_data.keys()):
new_node['telephone'] = stagiaire_data['tuteur1_telephone']
else:
new_node['telephone'] = ""
tab_stagiaire_contact_communication.append(new_node)
# Ajout des datas du tuteur 2 s'il est autorisé
if (stagiaire_data and "tuteur2_include_com" in stagiaire_data.keys() and str( stagiaire_data['tuteur2_include_com']) == "1"):
new_node = {}
if ("tuteur2_nom" in stagiaire_data.keys()):
new_node['nom'] = stagiaire_data['tuteur2_nom']
else:
new_node['nom'] = ""
if ("tuteur2_prenom" in stagiaire_data.keys()):
new_node['prenom'] = stagiaire_data['tuteur2_prenom']
else:
new_node['prenom'] = ""
if ("tuteur2_adresse" in stagiaire_data.keys()):
new_node['adresse'] = stagiaire_data['tuteur2_adresse']
else:
new_node['adresse'] = ""
if ("tuteur2_cp" in stagiaire_data.keys()):
new_node['code_postal'] = stagiaire_data['tuteur2_cp']
else:
new_node['code_postal'] = ""
if ("tuteur2_ville" in stagiaire_data.keys()):
new_node['ville'] = stagiaire_data['tuteur2_ville']
else:
new_node['ville'] = ""
if ("tuteur2_pays" in stagiaire_data.keys()):
new_node['pays'] = stagiaire_data['tuteur2_pays']
else:
new_node['pays'] = ""
if ("tuteur2_email" in stagiaire_data.keys()):
new_node['email'] = stagiaire_data['tuteur2_email']
else:
new_node['email'] = ""
if ("tuteur2_telephone" in stagiaire_data.keys()):
new_node['telephone'] = stagiaire_data['tuteur2_telephone']
else:
new_node['telephone'] = ""
tab_stagiaire_contact_communication.append(new_node)
return True, tab_stagiaire_contact_communication
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 récupérer la liste des contacts du stagiaire "

File diff suppressed because one or more lines are too long

View File

@ -3895,8 +3895,6 @@ pour les autres, on envoi des conventions individuelle
def Prepare_and_Send_Convention_From_Session_By_Email(tab_files, Folder, diction):
try:
print(" #### INITIAL tab_files = ", tab_files)
ORIG_tab_files = tab_files
field_list_obligatoire = ['token', 'session_id', 'courrier_template_id', 'email_test', 'email_production']
for val in field_list_obligatoire:
@ -3941,78 +3939,112 @@ def Prepare_and_Send_Convention_From_Session_By_Email(tab_files, Folder, diction
print(" ### la liste des liste_client_rattachement_id = ", liste_client_rattachement_id)
# Recuperer inscriptions indépenantes, donc pas liée à un client
liste_inscription_no_client = MYSY_GV.dbname['inscription'].find( {'session_id': str(diction['session_id']),
'status': '1',
'partner_owner_recid': str(my_partner['recid']),
"client_rattachement_id":''
}
)
for tmp in liste_inscription_no_client:
print(" ### la liste des liste_inscription_no_client = ", str(tmp))
# 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):
mycommon.myprint("Impossible de récupérer correctement le fichier à importer")
return False, "Impossible de récupérer correctement le fichier à importer"
tab_saved_file_full_path.append(saved_file_full_path)
print(" #### tab_saved_file_full_path = ", tab_saved_file_full_path)
# Recupération des données du modèle de document
is_convention_by_client = "0"
courrier_template_data = MYSY_GV.dbname['courrier_template'].find_one(
{'_id': ObjectId(str(diction['courrier_template_id'])),
'valide': '1',
'locked': '0',
'partner_owner_recid': str(my_partner['recid'])}
)
if( courrier_template_data and "edit_by_client" in courrier_template_data.keys() and courrier_template_data['edit_by_client'] == "1"):
is_convention_by_client = "1"
if( str(is_convention_by_client) == "1" ):
# Envoie des conventions pour les inscrits AVEC client_id (conventions d'entreprise)
for single_client in liste_client_rattachement_id :
print(" Traintement du client_id = ", single_client)
# Recuperation des contacts de communication du client
local_diction = {}
local_diction['token'] = diction['token']
local_diction['_id'] = str(single_client)
print(" ##### local_diction = ", local_diction)
local_status, partner_client_contact_communication = partner_client.Get_Partner_Client_Communication_Contact(local_diction)
for single_client in liste_client_rattachement_id :
print(" Traintement du client_id = ", single_client)
#field_list_obligatoire = ['token', 'courrier_template_id', 'email_test', 'email_production', 'partner_client_id', 'session_id']
if (local_status is False):
mycommon.myprint(" Impossible de récupérer les contacts de communication du client ")
return False, " Impossible de récupérer les contacts de communication du client "
# Recuperation des contacts de communication du client
local_diction = {}
local_diction['token'] = diction['token']
local_diction['_id'] = str(single_client)
print(" ### partner_client_contact_communication = ", partner_client_contact_communication)
tab_local_email_production = []
for tmp in partner_client_contact_communication:
tmp_JSON = ast.literal_eval(tmp)
if ("email" in tmp_JSON.keys()):
tab_local_email_production.append(str(tmp_JSON["email"]))
print(" ##### local_diction = ", local_diction)
local_status, partner_client_contact_communication = partner_client.Get_Partner_Client_Communication_Contact(local_diction)
list_local_email_production = ",".join(tab_local_email_production)
new_diction_client = {}
new_diction_client['partner_client_id'] = single_client
new_diction_client['token'] = diction['token']
new_diction_client['courrier_template_id'] = diction['courrier_template_id']
new_diction_client['email_test'] = diction['email_test']
new_diction_client['email_production'] = str(list_local_email_production)
new_diction_client['session_id'] = diction['session_id']
print(" ##### new_diction_client = ", new_diction_client)
print(" ##### tab_files = ", tab_files)
local_status, local_retval = Inscription_mgt.Sent_Convention_Stagiaire_By_Email_By_Partner_client(tab_saved_file_full_path, Folder, new_diction_client)
if( local_status is False):
mycommon.myprint(" WARNING : impossible d'envoyer la convention au client : "+str( single_client))
elif (str(is_convention_by_client) == "0"):
liste_inscription_no_client = MYSY_GV.dbname['inscription'].find(
{"$or": [{'session_id': str(diction['session_id']),
'status': '1',
'partner_owner_recid': str(my_partner['recid']),
"client_rattachement_id": ''
},
{'session_id': str(diction['session_id']),
'status': '1',
'partner_owner_recid': str(my_partner['recid']),
'client_rattachement_id': {'$exists': False}
}]
}
)
# Envoie des conventions pour les inscrits SANS client_id (conventions individuelles)
print(" ### is_convention_by_client ==== 0 : ")
print(" ### LIST traitement de l'inscrit : ", liste_inscription_no_client)
if (local_status is False):
mycommon.myprint(" Impossible de récupérer les contacts de communication du client ")
return False, " Impossible de récupérer les contacts de communication du client "
for single_inscrit_no_client in liste_inscription_no_client :
print(" ### traitement de l'inscrit : ",single_inscrit_no_client )
#field_list_obligatoire = [ 'token', 'inscription_id', 'courrier_template_id', 'email_test', 'email_production' ]
new_diction_no_client = {}
new_diction_no_client['token'] = str(diction['token'])
new_diction_no_client['inscription_id'] = str(single_inscrit_no_client['_id'])
new_diction_no_client['courrier_template_id'] = diction['courrier_template_id']
print(" ### partner_client_contact_communication = ", partner_client_contact_communication)
tab_local_email_production = []
for tmp in partner_client_contact_communication:
tmp_JSON = ast.literal_eval(tmp)
if ("email" in tmp_JSON.keys()):
tab_local_email_production.append(str(tmp_JSON["email"]))
new_diction_no_client['session_id'] = diction['session_id']
new_diction_no_client['email_test'] = diction['email_test']
new_diction_no_client['email_production'] = diction['email_production']
list_local_email_production = ",".join(tab_local_email_production)
print(" ##### new_diction_no_client = ", new_diction_no_client)
local_status, local_retval = Inscription_mgt.Sent_Convention_Stagiaire_By_Email(tab_files, Folder, new_diction_no_client)
new_diction_client = {}
new_diction_client['partner_client_id'] = single_client
new_diction_client['token'] = diction['token']
new_diction_client['courrier_template_id'] = diction['courrier_template_id']
new_diction_client['email_test'] = diction['email_test']
new_diction_client['email_production'] = str(list_local_email_production)
new_diction_client['session_id'] = diction['session_id']
if (local_status is False):
mycommon.myprint(" WARNING impossible d'envoyer la convention a l'apprenant : " + str(single_inscrit_no_client['_id']) )
print(" ##### new_diction_client = ", new_diction_client)
print(" ##### tab_files = ", tab_files)
print(" ##### ORIG_tab_files = ", ORIG_tab_files)
local_status, local_retval = Inscription_mgt.Sent_Convention_Stagiaire_By_Email_By_Partner_client(tab_files, Folder, new_diction_client)
if( local_status is False):
mycommon.myprint(" WARNING : impossible d'envoyer la convention au client : "+str( single_client))
# Envoie des convention pour les inscrits sans client_id
for single_inscrit_no_client in liste_inscription_no_client :
print(" ### traitement de l'inscrit : ",single_inscrit_no_client )
#field_list_obligatoire = [ 'token', 'inscription_id', 'courrier_template_id', 'email_test', 'email_production' ]
new_diction_no_client = {}
new_diction_no_client['token'] = str(diction['token'])
new_diction_no_client['inscription_id'] = str(single_inscrit_no_client['_id'])
new_diction_no_client['courrier_template_id'] = diction['courrier_template_id']
new_diction_no_client['session_id'] = diction['session_id']
new_diction_no_client['email_test'] = diction['email_test']
new_diction_no_client['email_production'] = diction['email_production']
print(" ##### new_diction_no_client = ", new_diction_no_client)
local_status, local_retval = Inscription_mgt.Sent_Convention_Stagiaire_By_Email(tab_files, Folder, new_diction_no_client)
if (local_status is False):
mycommon.myprint(" WARNING impossible d'envoyer la convention a l'apprenant : " + str(single_inscrit_no_client['_id']) )
else:
return False, " Vous devez definir si la convention est individuelle ou par client"
# Traitement de l'eventuel fichier joint
tab_files_to_attache_to_mail = []
@ -4026,6 +4058,326 @@ def Prepare_and_Send_Convention_From_Session_By_Email(tab_files, Folder, diction
return False, " Impossible d'envoyer les conventions par email "
"""
Cette fonction envoie les convention cochées par 'default'.
La fonction va envoyer les convention par defaut pour les inscrit rattachés à une societé et ceux rattaché à une societe
"""
def Prepare_and_Send_Default_Convention_From_Session_By_Email(tab_files, Folder, diction):
try:
field_list_obligatoire = ['token', 'session_id', 'courrier_template_id', 'email_test', 'email_production']
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"
my_token = ""
if ("token" in diction.keys()):
if diction['token']:
my_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 la session est valide
is_session_valide = MYSY_GV.dbname['session_formation'].count_documents(
{'_id': ObjectId(str(diction['session_id'])),
'valide': '1',
'partner_owner_recid': str(my_partner['recid'])})
if (is_session_valide != 1):
mycommon.myprint(
str(inspect.stack()[0][
3]) + " L'identifiant de la session est invalide ")
return False, " L'identifiant de la session est invalide "
# Verifier qu'il ya bien des inscriptions valides dans la session pour le client
liste_client_rattachement_id = MYSY_GV.dbname['inscription'].distinct("client_rattachement_id",
{'session_id':str(diction['session_id']),
'status': '1',
'partner_owner_recid': str(
my_partner['recid']),
"client_rattachement_id": { '$ne': ''}
}
)
print(" ### la liste des liste_client_rattachement_id = ", liste_client_rattachement_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):
mycommon.myprint("Impossible de récupérer correctement le fichier à importer")
return False, "Impossible de récupérer correctement le fichier à importer"
tab_saved_file_full_path.append(saved_file_full_path)
"""
On verifie s'il y a des convention d'entreprise à faire, si oui on verifie si il y a un document
qui a été configuré
"""
if (len(liste_client_rattachement_id) > 0):
"""
# Recupération de la convention d'entreprise par defaut de à envoyer par email :
- ref_interne = "CONVENTION_STAGIAIRE"
- default_version = "1"
- edit_by_client = "1"
- type_doc = "email"
"""
default_courrier_template_client_count = MYSY_GV.dbname['courrier_template'].count_documents(
{'valide': '1',
'locked': '0',
'ref_interne': 'CONVENTION_STAGIAIRE',
'default_version': '1',
'edit_by_client': '1',
'type_doc': 'email',
'partner_owner_recid': str(my_partner['recid'])}
)
if( default_courrier_template_client_count <= 0 ):
mycommon.myprint(
str(inspect.stack()[0][
3]) + " Aucune convention d'entreprise n'est configurée ")
return False, " Aucune convention d'entreprise n'est configurée "
if (default_courrier_template_client_count > 1):
mycommon.myprint(
str(inspect.stack()[0][
3]) + " Il y a " + str(
default_courrier_template_client_count) + " conventions d'entreprise configurées. Il ne doit y avoir qu'une seule ")
return False, " Il y a " + str(
default_courrier_template_client_count) + " conventions d'entreprise configurées. Il ne doit y avoir qu'une seule "
nb_liste_inscription_no_client = MYSY_GV.dbname['inscription'].count_documents(
{"$or": [{'session_id': str(diction['session_id']),
'status': '1',
'partner_owner_recid': str(my_partner['recid']),
"client_rattachement_id": ''
},
{'session_id': str(diction['session_id']),
'status': '1',
'partner_owner_recid': str(my_partner['recid']),
'client_rattachement_id': {'$exists': False}
}]
}
)
"""
On verifie s'il y a des conventions individuelles à faire, si oui on verifie si il y a un document
qui a été configuré
"""
if (nb_liste_inscription_no_client > 0):
"""
# Recupération de la convention individuelle par defaut de à envoyer par email :
- ref_interne = "CONVENTION_STAGIAIRE"
- default_version = "1"
- edit_by_client = "0"
- type_doc = "email"
"""
qry_indi = {"$or": [{'valide': '1',
'locked': '0',
'ref_interne': 'CONVENTION_STAGIAIRE',
'default_version': '1',
'edit_by_client': '0',
'type_doc':'email',
'partner_owner_recid': str(my_partner['recid'])}
,
{'valide': '1',
'locked': '0',
'ref_interne': 'CONVENTION_STAGIAIRE',
'default_version': '1',
'edit_by_client': {'$exists': False},
'type_doc':'email',
'partner_owner_recid': str(my_partner['recid'])}
]
}
print(" ### qry_indi = ", qry_indi)
default_courrier_template_individuel_count = MYSY_GV.dbname['courrier_template'].count_documents(
{"$or": [{'valide': '1',
'locked': '0',
'ref_interne': 'CONVENTION_STAGIAIRE',
'default_version': '1',
'edit_by_client': '0',
'type_doc': 'email',
'partner_owner_recid': str(my_partner['recid'])}
,
{'valide': '1',
'locked': '0',
'ref_interne': 'CONVENTION_STAGIAIRE',
'default_version': '1',
'edit_by_client': {'$exists': False},
'type_doc': 'email',
'partner_owner_recid': str(my_partner['recid'])}
]
}
)
if (default_courrier_template_individuel_count <= 0):
mycommon.myprint(
str(inspect.stack()[0][
3]) + " Aucune convention individuelle n'est configurée ")
return False, " Aucune convention d'individuelle n'est configurée "
if (default_courrier_template_individuel_count > 1):
mycommon.myprint(
str(inspect.stack()[0][
3]) + " Il y a "+str(default_courrier_template_individuel_count)+" conventions individuelles configurées. Il ne doit y avoir qu'une seule ")
return False, " Il y a "+str(default_courrier_template_individuel_count)+" conventions individuelles configurées. Il ne doit y avoir qu'une seule "
# Envoi des conventions d'entreprise par default
if( len(liste_client_rattachement_id) > 0 ):
# Il y a bien de inscris rattachés à des client. on cherche et envoie les conventions d'entreprises)
# Recuperer les datas de la convention par defautl
default_courrier_template_client_data = MYSY_GV.dbname['courrier_template'].find_one(
{'valide': '1',
'locked': '0',
'ref_interne': 'CONVENTION_STAGIAIRE',
'default_version': '1',
'edit_by_client': '1',
'type_doc': 'email',
'partner_owner_recid': str(my_partner['recid'])}
)
for single_client in liste_client_rattachement_id :
print(" Traintement du client_id = ", single_client)
# Recuperation des contacts de communication du client
local_diction = {}
local_diction['token'] = diction['token']
local_diction['_id'] = str(single_client)
print(" ##### local_diction = ", local_diction)
local_status, partner_client_contact_communication = partner_client.Get_Partner_Client_Communication_Contact(local_diction)
if (local_status is False):
mycommon.myprint(" Impossible de récupérer les contacts de communication du client ")
return False, " Impossible de récupérer les contacts de communication du client "
print(" ### partner_client_contact_communication = ", partner_client_contact_communication)
tab_local_email_production = []
for tmp in partner_client_contact_communication:
tmp_JSON = ast.literal_eval(tmp)
if ("email" in tmp_JSON.keys()):
tab_local_email_production.append(str(tmp_JSON["email"]))
list_local_email_production = ",".join(tab_local_email_production)
new_diction_client = {}
new_diction_client['partner_client_id'] = single_client
new_diction_client['token'] = diction['token']
new_diction_client['courrier_template_id'] = default_courrier_template_client_data['_id']
new_diction_client['email_test'] = diction['email_test']
new_diction_client['email_production'] = str(list_local_email_production)
new_diction_client['session_id'] = diction['session_id']
print(" ##### new_diction_client = ", new_diction_client)
print(" ##### tab_files = ", tab_files)
local_status, local_retval = Inscription_mgt.Sent_Convention_Stagiaire_By_Email_By_Partner_client(tab_saved_file_full_path, Folder, new_diction_client)
if( local_status is False):
mycommon.myprint(" WARNING : impossible d'envoyer la convention au client : "+str( single_client))
# Envoi des conventions individuelles par defaut
if (nb_liste_inscription_no_client > 0):
liste_inscription_no_client = MYSY_GV.dbname['inscription'].find(
{"$or": [{'session_id': str(diction['session_id']),
'status': '1',
'partner_owner_recid': str(my_partner['recid']),
"client_rattachement_id": ''
},
{'session_id': str(diction['session_id']),
'status': '1',
'partner_owner_recid': str(my_partner['recid']),
'client_rattachement_id': {'$exists': False}
}]
}
)
# Recuperer les datas de la convention par defautl
default_courrier_template_individuel_data = MYSY_GV.dbname['courrier_template'].find_one(
{"$or": [{'valide': '1',
'locked': '0',
'ref_interne': 'CONVENTION_STAGIAIRE',
'default_version': '1',
'edit_by_client': '0',
'type_doc': 'email',
'partner_owner_recid': str(my_partner['recid'])}
,
{'valide': '1',
'locked': '0',
'ref_interne': 'CONVENTION_STAGIAIRE',
'default_version': '1',
'edit_by_client': {'$exists': False},
'type_doc': 'email',
'partner_owner_recid': str(my_partner['recid'])}
]
}
)
# Envoie des conventions pour les inscrits SANS client_id (conventions individuelles)
print(" ### is_convention_by_client ==== 0 : ")
print(" ### LIST traitement de l'inscrit : ", liste_inscription_no_client)
for single_inscrit_no_client in liste_inscription_no_client :
print(" ### traitement de l'inscrit : ",single_inscrit_no_client )
#field_list_obligatoire = [ 'token', 'inscription_id', 'courrier_template_id', 'email_test', 'email_production' ]
new_diction_no_client = {}
new_diction_no_client['token'] = str(diction['token'])
new_diction_no_client['inscription_id'] = str(single_inscrit_no_client['_id'])
new_diction_no_client['courrier_template_id'] = default_courrier_template_individuel_data['_id']
new_diction_no_client['session_id'] = diction['session_id']
new_diction_no_client['email_test'] = ""
new_diction_no_client['email_production'] = ""
print(" ##### new_diction_no_client = ", new_diction_no_client)
local_status, local_retval = Inscription_mgt.Sent_Convention_Stagiaire_By_Email(tab_files, Folder, new_diction_no_client)
if (local_status is False):
mycommon.myprint(" WARNING impossible d'envoyer la convention a l'apprenant : " + str(single_inscrit_no_client['_id']) )
else:
return False, " Vous devez definir si la convention est individuelle ou par client"
# Traitement de l'eventuel fichier joint
tab_files_to_attache_to_mail = []
return True, " Les conventions ont été correctement envoyées par emails"
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 les conventions par email "
"""
Cette fonction permet de telecharger PDF toutes les conventions d'une session.
Depuis la session, l'utilisateur choisi le modele PDF et
@ -4081,49 +4433,69 @@ def Prepare_and_Send_Convention_From_Session_By_PDF(diction):
print(" ### la liste des liste_client_rattachement_id = ", liste_client_rattachement_id)
for val in liste_client_rattachement_id:
local_diction = {}
# field_list_obligatoire = ['token', 'session_id', 'courrier_template_id', 'client_id']
local_diction['token'] = diction['token']
local_diction['session_id'] = diction['session_id']
local_diction['courrier_template_id'] = diction['courrier_template_id']
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)
if( local_status is False):
return local_status, local_full_file_name
else:
print(" ### pdf_file_name = ", local_full_file_name)
list_file_name_to_zip.append(str(local_full_file_name))
# Recuperer inscriptions indépenantes, donc pas liée à un client
liste_inscription_no_client = MYSY_GV.dbname['inscription'].find( {'session_id': str(diction['session_id']),
'status': '1',
'partner_owner_recid': str(my_partner['recid']),
"client_rattachement_id":''
}, {'_id':1}
)
liste_inscription_no_client = MYSY_GV.dbname['inscription'].find({'session_id': str(diction['session_id']),
'status': '1',
'partner_owner_recid': str(
my_partner['recid']),
"client_rattachement_id": ''
}, {'_id': 1}
)
for val in liste_inscription_no_client:
print(" ### la liste des liste_inscription_no_client = ", str(val))
for val in liste_inscription_no_client:
local_diction = {}
# field_list_obligatoire = ['token', 'session_id', 'courrier_template_id', 'client_id']
local_diction['token'] = diction['token']
local_diction['session_id'] = diction['session_id']
local_diction['courrier_template_id'] = diction['courrier_template_id']
local_diction['inscription_id'] = str(val['_id'])
print(" #### Traitemnt de local_diction bb = ", local_diction)
local_status, local_full_file_name = Create_Convention_By_Stagiaire_PDF(local_diction)
if( local_status is False):
return local_status, local_full_file_name
else:
list_file_name_to_zip.append(str(local_full_file_name))
# Recupération des données du modèle de document
is_convention_by_client = "0"
courrier_template_data = MYSY_GV.dbname['courrier_template'].find_one(
{'_id': ObjectId(str(diction['courrier_template_id'])),
'valide': '1',
'locked': '0',
'partner_owner_recid': str(my_partner['recid'])}
)
if (courrier_template_data and "edit_by_client" in courrier_template_data.keys() and courrier_template_data[
'edit_by_client'] == "1"):
is_convention_by_client = "1"
if (str(is_convention_by_client) == "1"):
# Envoie des conventions pour les inscrits AVEC client_id
for val in liste_client_rattachement_id:
local_diction = {}
# field_list_obligatoire = ['token', 'session_id', 'courrier_template_id', 'client_id']
local_diction['token'] = diction['token']
local_diction['session_id'] = diction['session_id']
local_diction['courrier_template_id'] = diction['courrier_template_id']
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)
if( local_status is False):
return local_status, local_full_file_name
else:
print(" ### pdf_file_name = ", local_full_file_name)
list_file_name_to_zip.append(str(local_full_file_name))
elif (str(is_convention_by_client) == "0"):
for val in liste_inscription_no_client:
local_diction = {}
# field_list_obligatoire = ['token', 'session_id', 'courrier_template_id', 'client_id']
local_diction['token'] = diction['token']
local_diction['session_id'] = diction['session_id']
local_diction['courrier_template_id'] = diction['courrier_template_id']
local_diction['inscription_id'] = str(val['_id'])
print(" #### Traitemnt de local_diction bb = ", local_diction)
local_status, local_full_file_name = Create_Convention_By_Stagiaire_PDF(local_diction)
if( local_status is False):
return local_status, local_full_file_name
else:
list_file_name_to_zip.append(str(local_full_file_name))
# Create a ZipFile Object
@ -4153,6 +4525,311 @@ def Prepare_and_Send_Convention_From_Session_By_PDF(diction):
"""
Cette fonction permet de telecharge les conventions par defaut pour les entreprises et les individuels
"""
def Prepare_and_Send_Default_Convention_From_Session_By_PDF(diction):
try:
field_list_obligatoire = ['token', 'session_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, " La valeur '" + val + "' n'est pas presente dans liste"
my_token = ""
if ("token" in diction.keys()):
if diction['token']:
my_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 la session est valide
is_session_valide = MYSY_GV.dbname['session_formation'].count_documents(
{'_id': ObjectId(str(diction['session_id'])),
'valide': '1',
'partner_owner_recid': str(my_partner['recid'])})
if (is_session_valide != 1):
mycommon.myprint(
str(inspect.stack()[0][
3]) + " L'identifiant de la session est invalide ")
return False, " L'identifiant de la session est invalide "
# Verifier qu'il ya bien des inscriptions valides dans la session pour le client
liste_client_rattachement_id = MYSY_GV.dbname['inscription'].distinct("client_rattachement_id",
{'session_id': str(
diction['session_id']),
'status': '1',
'partner_owner_recid': str(
my_partner['recid']),
"client_rattachement_id": {'$ne': ''}
}
)
print(" ### la liste des liste_client_rattachement_id = ", liste_client_rattachement_id)
# --------
"""
On verifie s'il y a des convention d'entreprise à faire, si oui on verifie si il y a un document
qui a été configuré
"""
if (len(liste_client_rattachement_id) > 0):
"""
# Recupération de la convention d'entreprise par defaut de à envoyer par email :
- ref_interne = "CONVENTION_STAGIAIRE"
- default_version = "1"
- edit_by_client = "1"
- type_doc = "pdf"
"""
default_courrier_template_client_count = MYSY_GV.dbname['courrier_template'].count_documents(
{'valide': '1',
'locked': '0',
'ref_interne': 'CONVENTION_STAGIAIRE',
'default_version': '1',
'edit_by_client': '1',
'type_doc': 'pdf',
'partner_owner_recid': str(my_partner['recid'])}
)
if (default_courrier_template_client_count <= 0):
mycommon.myprint(
str(inspect.stack()[0][
3]) + " Aucune convention d'entreprise n'est configurée ")
return False, " Aucune convention d'entreprise n'est configurée "
if (default_courrier_template_client_count > 1):
mycommon.myprint(
str(inspect.stack()[0][
3]) + " Il y a " + str(
default_courrier_template_client_count) + " conventions d'entreprise configurées. Il ne doit y avoir qu'une seule ")
return False, " Il y a " + str(
default_courrier_template_client_count) + " conventions d'entreprise configurées. Il ne doit y avoir qu'une seule "
nb_liste_inscription_no_client = MYSY_GV.dbname['inscription'].count_documents(
{"$or": [{'session_id': str(diction['session_id']),
'status': '1',
'partner_owner_recid': str(my_partner['recid']),
"client_rattachement_id": ''
},
{'session_id': str(diction['session_id']),
'status': '1',
'partner_owner_recid': str(my_partner['recid']),
'client_rattachement_id': {'$exists': False}
}]
}
)
"""
On verifie s'il y a des conventions individuelles à faire, si oui on verifie si il y a un document
qui a été configuré
"""
if (nb_liste_inscription_no_client > 0):
"""
# Recupération de la convention individuelle par defaut de à envoyer par email :
- ref_interne = "CONVENTION_STAGIAIRE"
- default_version = "1"
- edit_by_client = "0"
- type_doc = "pdf"
"""
qry_indi = {"$or": [{'valide': '1',
'locked': '0',
'ref_interne': 'CONVENTION_STAGIAIRE',
'default_version': '1',
'edit_by_client': '0',
'type_doc': 'pdf',
'partner_owner_recid': str(my_partner['recid'])}
,
{'valide': '1',
'locked': '0',
'ref_interne': 'CONVENTION_STAGIAIRE',
'default_version': '1',
'edit_by_client': {'$exists': False},
'type_doc': 'pdf',
'partner_owner_recid': str(my_partner['recid'])}
]
}
print(" ### qry_indi = ", qry_indi)
default_courrier_template_individuel_count = MYSY_GV.dbname['courrier_template'].count_documents(
{"$or": [{'valide': '1',
'locked': '0',
'ref_interne': 'CONVENTION_STAGIAIRE',
'default_version': '1',
'edit_by_client': '0',
'type_doc': 'pdf',
'partner_owner_recid': str(my_partner['recid'])}
,
{'valide': '1',
'locked': '0',
'ref_interne': 'CONVENTION_STAGIAIRE',
'default_version': '1',
'edit_by_client': {'$exists': False},
'type_doc': 'pdf',
'partner_owner_recid': str(my_partner['recid'])}
]
}
)
if (default_courrier_template_individuel_count <= 0):
mycommon.myprint(
str(inspect.stack()[0][
3]) + " Aucune convention individuelle n'est configurée ")
return False, " Aucune convention d'individuelle n'est configurée "
if (default_courrier_template_individuel_count > 1):
mycommon.myprint(
str(inspect.stack()[0][
3]) + " Il y a " + str(
default_courrier_template_individuel_count) + " conventions individuelles configurées. Il ne doit y avoir qu'une seule ")
return False, " Il y a " + str(
default_courrier_template_individuel_count) + " conventions individuelles configurées. Il ne doit y avoir qu'une seule "
# -------------
# Stokage des nom de fichier à zipper
list_file_name_to_zip = []
# Recuperer inscriptions indépenantes, donc pas liée à un client
liste_inscription_no_client = MYSY_GV.dbname['inscription'].find(
{"$or": [{'session_id': str(diction['session_id']),
'status': '1',
'partner_owner_recid': str(my_partner['recid']),
"client_rattachement_id": ''
},
{'session_id': str(diction['session_id']),
'status': '1',
'partner_owner_recid': str(my_partner['recid']),
'client_rattachement_id': {'$exists': False}
}]
}
)
# Envoi des conventions d'entreprise par default
if (len(liste_client_rattachement_id) > 0):
# Recuperer les datas de la convention par defautl
default_courrier_template_client_data = MYSY_GV.dbname['courrier_template'].find_one(
{'valide': '1',
'locked': '0',
'ref_interne': 'CONVENTION_STAGIAIRE',
'default_version': '1',
'edit_by_client': '1',
'type_doc': 'email',
'partner_owner_recid': str(my_partner['recid'])}
)
for val in liste_client_rattachement_id:
local_diction = {}
# field_list_obligatoire = ['token', 'session_id', 'courrier_template_id', 'client_id']
local_diction['token'] = diction['token']
local_diction['session_id'] = diction['session_id']
local_diction['courrier_template_id'] = default_courrier_template_client_data['_id']
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)
if( local_status is False):
return local_status, local_full_file_name
else:
print(" ### pdf_file_name = ", local_full_file_name)
list_file_name_to_zip.append(str(local_full_file_name))
# Envoi des conventions individuelles par defaut
# Envoi des conventions individuelles par defaut
if (nb_liste_inscription_no_client > 0):
liste_inscription_no_client = MYSY_GV.dbname['inscription'].find(
{"$or": [{'session_id': str(diction['session_id']),
'status': '1',
'partner_owner_recid': str(my_partner['recid']),
"client_rattachement_id": ''
},
{'session_id': str(diction['session_id']),
'status': '1',
'partner_owner_recid': str(my_partner['recid']),
'client_rattachement_id': {'$exists': False}
}]
}
)
# Recuperer les datas de la convention par defautl
default_courrier_template_individuel_data = MYSY_GV.dbname['courrier_template'].find_one(
{"$or": [{'valide': '1',
'locked': '0',
'ref_interne': 'CONVENTION_STAGIAIRE',
'default_version': '1',
'edit_by_client': '0',
'type_doc': 'pdf',
'partner_owner_recid': str(my_partner['recid'])}
,
{'valide': '1',
'locked': '0',
'ref_interne': 'CONVENTION_STAGIAIRE',
'default_version': '1',
'edit_by_client': {'$exists': False},
'type_doc': 'pdf',
'partner_owner_recid': str(my_partner['recid'])}
]
}
)
for val in liste_inscription_no_client:
local_diction = {}
# field_list_obligatoire = ['token', 'session_id', 'courrier_template_id', 'client_id']
local_diction['token'] = diction['token']
local_diction['session_id'] = diction['session_id']
local_diction['courrier_template_id'] = default_courrier_template_individuel_data['_id']
local_diction['inscription_id'] = str(val['_id'])
print(" #### Traitemnt de local_diction bb = ", local_diction)
local_status, local_full_file_name = Create_Convention_By_Stagiaire_PDF(local_diction)
if( local_status is False):
return local_status, local_full_file_name
else:
list_file_name_to_zip.append(str(local_full_file_name))
# 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 = "List_Convention_session_"+str(diction['session_id'])+"_"+str(ts)+".zip"
with ZipFile(zip_file_name, 'w') as zip_object:
for pdf_files in list_file_name_to_zip :
print(" ### fichier a zipper = ", pdf_files)
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 conventions 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 conventions par pdf PDF "
"""
Cette fonction créer un PDF par client et retounr l'url complet du fichier pdf
pour les client (convention de type client)
@ -4312,16 +4989,20 @@ def Create_Convention_By_Stagiaire_PDF(diction):
template_courrier_data = MYSY_GV.dbname['courrier_template'].find_one({'_id':ObjectId(str(diction['courrier_template_id'])),
'valide':'1',
'locked':'0',
'ref_interne': 'CONVENTION_STAGIAIRE',
'partner_owner_recid':str(my_partner['recid'])})
if( template_courrier_data is None or "edit_by_client" not in template_courrier_data.keys() or str(template_courrier_data['edit_by_client']) == "1" ):
if( template_courrier_data is None or ("edit_by_client" in template_courrier_data.keys() and str(template_courrier_data['edit_by_client']) == "1" ) ):
mycommon.myprint(
str(inspect.stack()[0][
3]) + " Le modèle de courrier n'est pas éditable par stagiaire. ")
return False, " Le modèle de courrier n'est pas éditable par stagiaire "
# Verifier que le statgiaire est valide
statgiaire_data = MYSY_GV.dbname['inscription'].find_one({'_id':ObjectId(str(diction['inscription_id'])), 'status':'1','locked':'0',
local_qry = {'_id':ObjectId(str(diction['inscription_id'])), 'status':'1',
'partner_owner_recid':str(my_partner['recid'])}
print(" #### local qry = ", local_qry)
statgiaire_data = MYSY_GV.dbname['inscription'].find_one({'_id':ObjectId(str(diction['inscription_id'])), 'status':'1',
'partner_owner_recid':str(my_partner['recid'])})
if (statgiaire_data is None ):
@ -4403,7 +5084,7 @@ def Create_Convention_By_Stagiaire_PDF(diction):
resultFile.close()
return True, template_courrier_data
return True, outputFilename
except Exception as e:
exc_type, exc_obj, exc_tb = sys.exc_info()

47
main.py
View File

@ -2145,6 +2145,28 @@ def Prepare_and_Send_Convention_From_Session_By_Email():
return jsonify(status=status, message=retval)
"""
API : pour préprer et envoyer les conventions PAR DEFAUT en partant d'une session
"""
@app.route('/myclass/api/Prepare_and_Send_Default_Convention_From_Session_By_Email/', methods=['POST','GET'])
@crossdomain(origin='*')
def Prepare_and_Send_Default_Convention_From_Session_By_Email():
# On recupere le corps (payload) de la requete
payload = mycommon.strip_dictionary (request.form.to_dict())
print(" ### Prepare_and_Send_Default_Convention_From_Session_By_Email : payload = ",str(payload))
file = []
if request.method == 'POST':
# Create variable for uploaded file
tab_files = []
for tmp in request.files.getlist("File"):
tab_files.append(tmp)
status, retval = SF.Prepare_and_Send_Default_Convention_From_Session_By_Email(tab_files, MYSY_GV.TEMPORARY_DIRECTORY_V2, payload)
return jsonify(status=status, message=retval)
"""
API : pour préprer et générer un zip de fichier PDF pour les convention en partant d'une session
@ -2159,7 +2181,7 @@ def Prepare_and_Send_Convention_From_Session_By_PDF(token, session_id, courrier_
payload['session_id'] = str(session_id)
payload['courrier_template_id'] = str(courrier_template_id)
print(" ### GerneratePDFEmargementList : payload = ",str(payload))
print(" ### Prepare_and_Send_Convention_From_Session_By_PDF : payload = ",str(payload))
localStatus, response= SF.Prepare_and_Send_Convention_From_Session_By_PDF(payload)
if(localStatus ):
@ -2168,6 +2190,29 @@ def Prepare_and_Send_Convention_From_Session_By_PDF(token, session_id, courrier_
return False
"""
API : pour préprer et générer un zip de fichier PDF pour les convention par defaut en partant d'une session.
ici les convention pdf par default
"""
@app.route('/myclass/api/Prepare_and_Send_Default_Convention_From_Session_By_PDF/<token>/<session_id>/<courrier_template_id>', methods=['POST','GET'])
@crossdomain(origin='*')
def Prepare_and_Send_Default_Convention_From_Session_By_PDF(token, session_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['session_id'] = str(session_id)
payload['courrier_template_id'] = str(courrier_template_id)
print(" ### Prepare_and_Send_Default_Convention_From_Session_By_PDF : payload = ",str(payload))
localStatus, response= SF.Prepare_and_Send_Default_Convention_From_Session_By_PDF(payload)
if(localStatus ):
return response
else:
return False
"""
API de generation de liste PDF des liste d'emargement

View File

@ -226,6 +226,7 @@ def Add_Partner_Document(diction):
if( "default_version" in diction.keys() and str(diction['default_version']) == "1"):
MYSY_GV.dbname['courrier_template'].update_many({'ref_interne':str(ref_interne),
'valide':'1',
'edit_by_client':str(edit_by_client),
'partner_owner_recid':str(my_partner['recid']),
'type_doc':str(diction['type_doc'])},
{'$set':{'default_version':'0'}})
@ -302,8 +303,6 @@ def Update_Partner_Document(diction):
print(" ### qry_update zz = ", qry_update)
tmp_count = MYSY_GV.dbname['courrier_template'].count_documents(qry_update)
if (tmp_count <= 0):
mycommon.myprint(
@ -446,9 +445,18 @@ def Update_Partner_Document(diction):
- type_doc
"""
qry_update ={'ref_interne': str(ref_interne),
'valide': '1',
'edit_by_client': str(edit_by_client),
'partner_owner_recid': str(my_partner['recid']),
'type_doc': str(diction['type_doc'])}
print(" ### qry_update = ", qry_update)
if ("default_version" in diction.keys() and str(diction['default_version']) == "1"):
MYSY_GV.dbname['courrier_template'].update_many({'ref_interne': str(ref_interne),
'valide': '1',
'edit_by_client': str(edit_by_client),
'partner_owner_recid': str(my_partner['recid']),
'type_doc': str(diction['type_doc'])},
{'$set': {'default_version': '0'}})
@ -1309,6 +1317,20 @@ def Duplicate_Given_Partner_Document(diction):
new_document['sujet'] = str(diction['sujet'])
if( "joint_pdf" in is_document_data.keys()):
new_document['is_document_data'] = str(is_document_data['is_document_data'])
else:
new_document['is_document_data'] = "0"
if ("corps_mail" in is_document_data.keys()):
new_document['corps_mail'] = str(is_document_data['corps_mail'])
else:
new_document['corps_mail'] = ""
# On ne reprend jamais le 'default_version' dans une duplicata
new_document['default_version'] = "0"
inserted_id = MYSY_GV.dbname['courrier_template'].insert_one(new_document).inserted_id
if (not inserted_id):
mycommon.myprint(