26/12/2023 - 22h
parent
c143f52a10
commit
fa52f8d1de
|
@ -3,11 +3,10 @@
|
|||
<component name="ChangeListManager">
|
||||
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="20/12/2023 - 18h">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" 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$/apprenant_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/apprenant_mgt.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/attached_file_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/attached_file_mgt.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/class_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/class_mgt.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/prj_common.py" beforeDir="false" afterPath="$PROJECT_DIR$/prj_common.py" afterDir="false" />
|
||||
</list>
|
||||
|
|
|
@ -6268,7 +6268,7 @@ def Sent_Convention_Stagiaire_By_Email(tab_files, Folder, diction):
|
|||
return local_status, tab_apprenant_contact
|
||||
|
||||
tmp_tab = []
|
||||
print(" ### tab_apprenant_contact = ", tab_apprenant_contact)
|
||||
#print(" ### tab_apprenant_contact = ", tab_apprenant_contact)
|
||||
|
||||
for tmp in tab_apprenant_contact :
|
||||
if("email" in tmp.keys() ):
|
||||
|
@ -6283,7 +6283,7 @@ def Sent_Convention_Stagiaire_By_Email(tab_files, Folder, diction):
|
|||
return False, " Aucune adresse email n'a été fourni. "
|
||||
|
||||
|
||||
print(" ### tab_emails_destinataire = ", tab_emails_destinataire)
|
||||
#print(" ### tab_emails_destinataire = ", tab_emails_destinataire)
|
||||
|
||||
# Verifier que le 'courrier_template_id' est valide
|
||||
# Ici le template doit etre un email
|
||||
|
|
1820
Log/log_file.log
1820
Log/log_file.log
File diff suppressed because one or more lines are too long
|
@ -4597,7 +4597,7 @@ def Prepare_and_Send_Default_Convention_From_Session_By_PDF(diction):
|
|||
}
|
||||
)
|
||||
|
||||
print(" ### la liste des liste_client_rattachement_id = ", liste_client_rattachement_id)
|
||||
|
||||
|
||||
# --------
|
||||
"""
|
||||
|
@ -5038,7 +5038,7 @@ def Create_Convention_By_Stagiaire_PDF(diction):
|
|||
# Verifier que le statgiaire est valide
|
||||
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'])})
|
||||
|
||||
|
|
278
apprenant_mgt.py
278
apprenant_mgt.py
|
@ -6,13 +6,17 @@ Un apprenant est crée apres la validation d'une inscription ou sans.
|
|||
"""
|
||||
import ast
|
||||
|
||||
import jinja2
|
||||
import pymongo
|
||||
from flask import send_file
|
||||
from pymongo import MongoClient
|
||||
import json
|
||||
from bson import ObjectId
|
||||
import re
|
||||
from datetime import datetime, date
|
||||
|
||||
from xhtml2pdf import pisa
|
||||
|
||||
import attached_file_mgt
|
||||
import prj_common as mycommon
|
||||
import secrets
|
||||
|
@ -1931,3 +1935,277 @@ def Update_Apprenant_Tuteurs(diction):
|
|||
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
|
||||
return False, "Impossible de mettre à jour le tuteur "
|
||||
|
||||
|
||||
"""
|
||||
Fonction pour imprimer la fiche d'un apprenant (mode pdf).
|
||||
Cette fonction est prevu pour gérer le choix d'un modèle ou le modèle de courrier par defaut.
|
||||
|
||||
/!\ si courrier_template_id = "default_pdf", alors on va chercher le modèle par defaut.
|
||||
"""
|
||||
def Print_Apprenant_PDF(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', '_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', '_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'apprenant existe deja
|
||||
is_apprenant_exist = MYSY_GV.dbname['apprenant'].count_documents({'_id':ObjectId(str(diction['_id'])),
|
||||
'partner_owner_recid':str(my_partner['recid']),
|
||||
'valide':'1',
|
||||
'locked':'0'})
|
||||
if( is_apprenant_exist <= 0 ):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " L'identifiant de l'apprenant n'est pas valide ")
|
||||
return False, " L'identifiant de l'apprenant n'est pas valide ",
|
||||
|
||||
appenant_data = MYSY_GV.dbname['apprenant'].find_one({'_id': ObjectId(str(diction['_id'])),
|
||||
'partner_owner_recid': str(my_partner['recid']),
|
||||
'valide': '1',
|
||||
'locked': '0'})
|
||||
|
||||
|
||||
# Recuperation du modele de courrier
|
||||
courrier_template_data = {}
|
||||
if( str(diction['courrier_template_id']) == "default_pdf" ):
|
||||
default_courrier_template_client_count = MYSY_GV.dbname['courrier_template'].count_documents(
|
||||
{'valide': '1',
|
||||
'locked': '0',
|
||||
'ref_interne': 'FICHE_APPRENANT',
|
||||
'default_version': '1',
|
||||
'edit_by_client': '0',
|
||||
'type_doc': 'pdf',
|
||||
'partner_owner_recid': str(my_partner['recid'])}
|
||||
)
|
||||
|
||||
qry = {'valide': '1',
|
||||
'locked': '0',
|
||||
'ref_interne': 'FICHE_APPRENANT',
|
||||
'default_version': '1',
|
||||
'edit_by_client': '0',
|
||||
'type_doc': 'pdf',
|
||||
'partner_owner_recid': str(my_partner['recid'])}
|
||||
|
||||
|
||||
if (default_courrier_template_client_count != 1):
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " L'identifiant du modèle de courrier est invalide 1 ")
|
||||
return False, " L'identifiant du modèle de courrier est invalide 1 "
|
||||
|
||||
courrier_template_data = MYSY_GV.dbname['courrier_template'].find_one(
|
||||
{'valide': '1',
|
||||
'locked': '0',
|
||||
'ref_interne': 'FICHE_APPRENANT',
|
||||
'default_version': '1',
|
||||
'edit_by_client': '0',
|
||||
'type_doc': 'pdf',
|
||||
'partner_owner_recid': str(my_partner['recid'])}
|
||||
)
|
||||
|
||||
else :
|
||||
is_courrier_template_id_valide = MYSY_GV.dbname['courrier_template'].count_documents(
|
||||
{'_id': ObjectId(str(diction['courrier_template_id'])),
|
||||
'valide': '1',
|
||||
'type_doc': 'pdf',
|
||||
'ref_interne': 'FICHE_APPRENANT',
|
||||
'locked': '0',
|
||||
'partner_owner_recid': str(my_partner['recid'])}
|
||||
)
|
||||
|
||||
if (is_courrier_template_id_valide != 1):
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " L'identifiant du modèle de courrier est invalide ")
|
||||
return False, " L'identifiant du modèle de courrier est invalide "
|
||||
|
||||
courrier_template_data = MYSY_GV.dbname['courrier_template'].find_one(
|
||||
{'_id': ObjectId(str(diction['courrier_template_id'])),
|
||||
'valide': '1',
|
||||
'type_doc': 'pdf',
|
||||
'ref_interne': 'FICHE_APPRENANT',
|
||||
'locked': '0',
|
||||
'partner_owner_recid': str(my_partner['recid'])}
|
||||
)
|
||||
|
||||
|
||||
"""
|
||||
Creation du dictionnaire d'information lié à l'apprenant. Pour cela on besoin de connaitre :
|
||||
- l'id de l'apprenant
|
||||
- list_session_id associé cet apprenant
|
||||
- list_client_id associé cet apprenant
|
||||
-
|
||||
"""
|
||||
tab_apprenant = []
|
||||
tab_apprenant.append(appenant_data['_id'])
|
||||
|
||||
tab_session = []
|
||||
for val in MYSY_GV.dbname['inscription'].find({'apprenant_id':str(diction['_id']),
|
||||
'partner_owner_recid':str(my_partner['recid'])}, {'session_id':1}):
|
||||
tab_session.append(ObjectId(str(val['session_id'])))
|
||||
|
||||
tab_client = []
|
||||
if( "client_rattachement_id" in appenant_data.keys() and appenant_data['client_rattachement_id']):
|
||||
for val in MYSY_GV.dbname['partner_client'].find({'_id':ObjectId(str(appenant_data['client_rattachement_id'])),
|
||||
'valide':'1',
|
||||
'locked':'0',
|
||||
'partner_recid':str(my_partner['recid']) }, {'_id':1}):
|
||||
tab_client.append(val['_id'])
|
||||
|
||||
|
||||
|
||||
local_diction = {}
|
||||
local_diction['token'] = diction['token']
|
||||
local_diction['list_stagiaire_id'] = []
|
||||
local_diction['list_session_id'] = tab_session
|
||||
local_diction['list_class_id'] = []
|
||||
local_diction['list_client_id'] = tab_client
|
||||
local_diction['list_apprenant_id'] = tab_apprenant
|
||||
|
||||
#print(" ### local_diction = ", local_diction)
|
||||
local_status, local_retval = mycommon.Get_Dictionnary_data_For_Template(local_diction)
|
||||
|
||||
if (local_status is False):
|
||||
return local_status, local_retval
|
||||
|
||||
convention_dictionnary_data = local_retval
|
||||
|
||||
body = {
|
||||
"params": convention_dictionnary_data,
|
||||
}
|
||||
|
||||
json_formatted_str = json.dumps(body, indent=2)
|
||||
|
||||
#print(json_formatted_str)
|
||||
|
||||
#print(convention_dictionnary_data)
|
||||
|
||||
"""
|
||||
Creation du ficier PDF
|
||||
"""
|
||||
contenu_doc_Template = jinja2.Template(str(courrier_template_data['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 = "Fiche_Apprenant_" + str(my_partner['recid']) + "_" + 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()
|
||||
|
||||
if os.path.exists(outputFilename):
|
||||
# print(" ### ok os.path.exists(outputFilename) "+str(outputFilename))
|
||||
return True, send_file(outputFilename, as_attachment=True)
|
||||
|
||||
# return True on success and False on errors
|
||||
print(pisaStatus.err, type(pisaStatus.err))
|
||||
|
||||
return True, " le fichier generé "
|
||||
|
||||
|
||||
|
||||
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'imprimer les données de l'apprenant "
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Recuperation de la liste des modèles de courrier pour les fiches d'apprenants
|
||||
"""
|
||||
def Get_List_Fiche_Apprenant(diction):
|
||||
try:
|
||||
field_list_obligatoire = ['token']
|
||||
|
||||
for val in field_list_obligatoire:
|
||||
if val not in diction:
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " La valeur '" + val + "' n'est pas presente dans liste ")
|
||||
return False, " 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
|
||||
|
||||
RetObject = []
|
||||
val_tmp = 0
|
||||
|
||||
"""
|
||||
# Recuperation des documents (collection : courrier_template) de ce partenaire avec 'ref_interne' = 'CONVENTION_STAGIAIRE'
|
||||
1 - On regarde le partenaire à des conventions qui sont personnalisées, si non
|
||||
2 - On va sortir les conventions par defaut de MySy.
|
||||
|
||||
/!\ : On ne melange pas les 2. c'est l'un ou l'autre
|
||||
"""
|
||||
for retval in MYSY_GV.dbname['courrier_template'].find({'ref_interne': 'FICHE_APPRENANT',
|
||||
'valide': '1',
|
||||
'locked': '0',
|
||||
'partner_owner_recid': str(my_partner['recid'])}):
|
||||
user = retval
|
||||
val_tmp = val_tmp + 1
|
||||
RetObject.append(mycommon.JSONEncoder().encode(user))
|
||||
|
||||
# Si aucune convention personnalisée, on va chercher les conventions mysy
|
||||
if (val_tmp == 0):
|
||||
for retval in MYSY_GV.dbname['courrier_template'].find({'ref_interne': 'FICHE_APPRENANT',
|
||||
'valide': '1',
|
||||
'locked': '0',
|
||||
'partner_owner_recid': 'default'}):
|
||||
user = retval
|
||||
val_tmp = val_tmp + 1
|
||||
RetObject.append(mycommon.JSONEncoder().encode(user))
|
||||
|
||||
return True, RetObject
|
||||
|
||||
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 modèles de fiche"
|
||||
|
|
37
main.py
37
main.py
|
@ -6698,6 +6698,43 @@ def Delete_List_Apprenant():
|
|||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
"""
|
||||
API pour imprimer la fiche d'un apprenant au format PDF
|
||||
"""
|
||||
@app.route('/myclass/api/Print_Apprenant_PDF/<token>/<_id>/<courrier_template_id>', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Print_Apprenant_PDF(token, _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['_id'] = str(_id)
|
||||
payload['courrier_template_id'] = str(courrier_template_id)
|
||||
|
||||
print(" ### Print_Apprenant_PDF payload = ",payload)
|
||||
|
||||
localStatus, response= apprenant_mgt.Print_Apprenant_PDF(payload)
|
||||
if(localStatus ):
|
||||
return response
|
||||
else:
|
||||
return False
|
||||
|
||||
|
||||
"""
|
||||
API pour recuperer les modele de courrier pour les : FICHE_APPRENANT
|
||||
"""
|
||||
@app.route('/myclass/api/Get_List_Fiche_Apprenant/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Get_List_Fiche_Apprenant():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Get_List_Fiche_Apprenant payload = ",payload)
|
||||
status, retval = apprenant_mgt.Get_List_Fiche_Apprenant(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
print(" debut api")
|
||||
|
|
112
prj_common.py
112
prj_common.py
|
@ -3946,6 +3946,7 @@ convention_dictionnary_data =
|
|||
{'class_data':{....}}
|
||||
{'list_session_data':{....}}
|
||||
{'list_stagiaire_data':[{...}]}
|
||||
{'list_apprenant_data':[{...}]}
|
||||
{'client_data':{'raison_sociale':'xxx', 'nom':'yyy', list_contact_communication[{'civilite':'aa', 'nom':'bbb', ....'telephone_mobile':'01222'}, {'civilite':'aa', 'nom':'bbb', ....'telephone_mobile':'01222'} .... ]}
|
||||
{'systeme':{'date_jour':'11/02/2023'}}
|
||||
|
||||
|
@ -3960,7 +3961,7 @@ def Get_Dictionnary_data_For_Template(diction):
|
|||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', 'list_stagiaire_id', 'list_session_id', 'list_class_id', 'list_client_id']
|
||||
field_list = ['token', 'list_stagiaire_id', 'list_session_id', 'list_class_id', 'list_client_id', 'list_apprenant_id']
|
||||
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
|
@ -4037,21 +4038,50 @@ def Get_Dictionnary_data_For_Template(diction):
|
|||
dictionnary_data['company_data'] = company_data
|
||||
|
||||
"""
|
||||
Recuperartion des champs des stagiaires
|
||||
Recuperartion des champs des sessions
|
||||
"""
|
||||
session_liste_champ = ['code_session', 'class_internal_url', 'date_debut', 'session_etape', 'date_fin',
|
||||
'distantiel', 'presentiel', 'session_ondemande', 'nb_participant',
|
||||
'prix_session', 'titre', 'location_type', 'is_bpf', 'formateur_id', 'adresse',
|
||||
'code_postal', 'ville', 'pays', 'date_debut_inscription', 'date_fin_inscription',
|
||||
'formateur_nom_prenom']
|
||||
'formateur_nom_prenom', 'session_formation_titre', 'session_formation_objectif', 'session_formation_description']
|
||||
list_session_data = []
|
||||
tab_session_id = diction['list_session_id']
|
||||
|
||||
|
||||
for session_data in MYSY_GV.dbname['session_formation'].find( {'_id': {'$in': tab_session_id, } ,
|
||||
'valide': '1',
|
||||
'partner_owner_recid': str(my_partner['recid'])
|
||||
}):
|
||||
|
||||
# Recuperation des données de la formation associée
|
||||
session_formation_titre = ""
|
||||
session_formation_objectif = ""
|
||||
session_formation_description = ""
|
||||
if ("class_internal_url" in session_data.keys() and session_data['class_internal_url']):
|
||||
class_data = MYSY_GV.dbname['myclass'].find_one(
|
||||
{'internal_url': str(session_data['class_internal_url']),
|
||||
'valide': '1',
|
||||
'locked': '0',
|
||||
'partner_owner_recid': str(my_partner['recid'])
|
||||
}, {'objectif':1, 'title':1, 'description':1})
|
||||
|
||||
|
||||
if (class_data and "title" in class_data.keys() ) :
|
||||
session_formation_titre = str(class_data['title'])
|
||||
|
||||
if (class_data and "objectif" in class_data.keys() ) :
|
||||
session_formation_objectif = str(class_data['objectif'])
|
||||
|
||||
if (class_data and "description" in class_data.keys() ) :
|
||||
session_formation_description = str(class_data['description'])
|
||||
|
||||
session_data['session_formation_titre'] = session_formation_titre
|
||||
session_data['session_formation_objectif'] = session_formation_objectif
|
||||
session_data['session_formation_description'] = session_formation_description
|
||||
|
||||
|
||||
# Recuperation des données du formation
|
||||
formateur_nom_prenom = ""
|
||||
# Si il y a un code formateur_id, alors on va recuperer les nom et prenom du formation
|
||||
if ("formateur_id" in session_data.keys() and session_data['formateur_id']):
|
||||
|
@ -4083,10 +4113,82 @@ def Get_Dictionnary_data_For_Template(diction):
|
|||
|
||||
dictionnary_data['list_session_data'] = list_session_data
|
||||
|
||||
"""
|
||||
Recuperartion des champs des apprenants
|
||||
"""
|
||||
list_apprenant_data = []
|
||||
tab_apprenant_id = diction['list_apprenant_id']
|
||||
apprenant_liste_champ = ['prenom', 'nom', 'email', 'civilite', 'telephone', 'employeur', 'adresse', 'code_postal', 'ville', 'pays', 'tuteur1_nom', 'tuteur1_prenom', 'tuteur1_email', 'tuteur1_telephone',
|
||||
'tuteur2_nom', 'tuteur2_prenom', 'tuteur2_email', 'tuteur2_telephone', 'opco', 'tuteur1_adresse', 'tuteur1_cp', 'tuteur1_ville', 'tuteur1_pays', 'tuteur1_include_com', 'tuteur2_adresse',
|
||||
'tuteur2_cp', 'tuteur2_ville', 'tuteur2_pays', 'tuteur2_include_com', 'client_rattachement_id', 'photo_profil']
|
||||
|
||||
|
||||
for apprenant_data in MYSY_GV.dbname['apprenant'].find({'_id': {'$in': tab_apprenant_id, },
|
||||
'valide': '1',
|
||||
'locked':'0',
|
||||
'partner_owner_recid': str(my_partner['recid'])
|
||||
}):
|
||||
# Récuperation de l'eventuelle photo de l'apprenant
|
||||
apprenant_img = ""
|
||||
qry_img = {'related_collection':'apprenant',
|
||||
'related_collection_recid':str(apprenant_data['_id']),
|
||||
'valide':'1',
|
||||
'locked':'0'}
|
||||
|
||||
print(" ### qry_img = ", qry_img)
|
||||
apprenant_photo_data = MYSY_GV.dbname['mysy_images'].find_one({'related_collection':'apprenant',
|
||||
'related_collection_recid':str(apprenant_data['_id']),
|
||||
'valide':'1',
|
||||
'locked':'0'}, {'img':1})
|
||||
|
||||
if( apprenant_photo_data and "img" in apprenant_photo_data.keys() and apprenant_photo_data['img']):
|
||||
apprenant_img = "data:image/png;base64,"+apprenant_photo_data['img'].decode()
|
||||
|
||||
apprenant_data['photo_profil'] = apprenant_img
|
||||
|
||||
|
||||
|
||||
|
||||
new_apprenant_data = {}
|
||||
for champ in apprenant_liste_champ:
|
||||
if (champ in apprenant_data):
|
||||
# Si on a faire au champ 'client_rattachement_id' avec une valeur, on va aller chercher le nom du clien
|
||||
if( champ == "client_rattachement_id"):
|
||||
client_rattachement_nom = "";
|
||||
if( "client_rattachement_id" in apprenant_data.keys() and apprenant_data['client_rattachement_id'] ) :
|
||||
client_rattachement_id_data = MYSY_GV.dbname['partner_client'].find_one({'_id':ObjectId(str(apprenant_data['client_rattachement_id'])),
|
||||
'valide':'1',
|
||||
'locked':'0',
|
||||
'partner_recid':str(my_partner['recid'])},
|
||||
{'nom':1})
|
||||
|
||||
if(client_rattachement_id_data and "nom" in client_rattachement_id_data.keys() ):
|
||||
client_rattachement_nom = str(client_rattachement_id_data["nom"])
|
||||
|
||||
new_champ_name = "apprenant_client_rattachement_nom"
|
||||
new_field = {new_champ_name: str(client_rattachement_nom)}
|
||||
new_apprenant_data.update(new_field)
|
||||
|
||||
|
||||
else :
|
||||
new_champ_name = "apprenant_" + str(champ)
|
||||
new_field = {new_champ_name: str(apprenant_data[champ])}
|
||||
new_apprenant_data.update(new_field)
|
||||
else:
|
||||
new_champ_name = "apprenant_" + str(champ)
|
||||
new_field = {new_champ_name: ""}
|
||||
new_apprenant_data.update(new_field)
|
||||
|
||||
|
||||
|
||||
list_apprenant_data.append(new_apprenant_data)
|
||||
|
||||
dictionnary_data['list_apprenant_data'] = list_apprenant_data
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Recuperartion des champs des stagiaire
|
||||
Recuperartion des champs des stagiaires
|
||||
"""
|
||||
list_stagiaire_data = []
|
||||
tab_stagiaire_id = diction['list_stagiaire_id']
|
||||
|
@ -4122,7 +4224,7 @@ def Get_Dictionnary_data_For_Template(diction):
|
|||
|
||||
|
||||
"""
|
||||
Recuperartion des champs des formation
|
||||
Recuperartion des champs des formations
|
||||
"""
|
||||
list_myclass_data = []
|
||||
tab_myclass_id = diction['list_class_id']
|
||||
|
|
Loading…
Reference in New Issue