master
cherif 2024-01-27 16:30:51 +01:00
parent 0e1092b2c3
commit 71ea27c918
6 changed files with 1497 additions and 30 deletions

View File

@ -1,8 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="rrr">
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="rrrf">
<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$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
@ -76,13 +77,6 @@
<option name="presentableId" value="Default" />
<updated>1680804787304</updated>
</task>
<task id="LOCAL-00154" summary="20/11/2023 - 21h00">
<created>1700513271611</created>
<option name="number" value="00154" />
<option name="presentableId" value="LOCAL-00154" />
<option name="project" value="LOCAL" />
<updated>1700513271611</updated>
</task>
<task id="LOCAL-00155" summary="22/11/2023 - 23h00">
<created>1700691598342</created>
<option name="number" value="00155" />
@ -419,7 +413,14 @@
<option name="project" value="LOCAL" />
<updated>1706219904725</updated>
</task>
<option name="localTasksCounter" value="203" />
<task id="LOCAL-00203" summary="rrrf">
<created>1706302326449</created>
<option name="number" value="00203" />
<option name="presentableId" value="LOCAL-00203" />
<option name="project" value="LOCAL" />
<updated>1706302326450</updated>
</task>
<option name="localTasksCounter" value="204" />
<servers />
</component>
<component name="Vcs.Log.Tabs.Properties">
@ -434,7 +435,6 @@
</option>
</component>
<component name="VcsManagerConfiguration">
<MESSAGE value="18/12/2023 - 22:00" />
<MESSAGE value="20/12/2023 - 18h" />
<MESSAGE value="27/12/2023 - 13h" />
<MESSAGE value="27/12/2023 - 23h" />
@ -459,6 +459,7 @@
<MESSAGE value="22/01/2024 -22h00" />
<MESSAGE value="24/01/2024 -12h00" />
<MESSAGE value="rrr" />
<option name="LAST_COMMIT_MESSAGE" value="rrr" />
<MESSAGE value="rrrf" />
<option name="LAST_COMMIT_MESSAGE" value="rrrf" />
</component>
</project>

View File

@ -6723,7 +6723,7 @@ On accepte plusieurs versions du meme doc
def Get_List_Conventions_Stagiaire_With_Filter(diction):
try:
field_list = ['token', 'ref_interne','nom', 'type_doc' ]
field_list = ['token', 'ref_interne','nom', 'type_doc', 'courrier_template_type_document_ref_interne' ]
incom_keys = diction.keys()
for val in incom_keys:
@ -6766,6 +6766,9 @@ def Get_List_Conventions_Stagiaire_With_Filter(diction):
if ("ref_interne" in diction.keys()):
filt_ref_interne = {'ref_interne': str(diction['ref_interne'])}
filt_courrier_template_type_document_ref_interne = {}
if ("courrier_template_type_document_ref_interne" in diction.keys()):
filt_courrier_template_type_document_ref_interne = {'courrier_template_type_document_ref_interne': str(diction['courrier_template_type_document_ref_interne'])}
RetObject = []
val_tmp = 0
@ -6782,7 +6785,7 @@ def Get_List_Conventions_Stagiaire_With_Filter(diction):
for retval in MYSY_GV.dbname['courrier_template'].find({'$and': [{'ref_interne': 'CONVENTION_STAGIAIRE',
'valide': '1',
'locked': '0',
'partner_owner_recid': str(my_partner['recid'])}, filt_type_doc, filt_nom, filt_ref_interne ]}):
'partner_owner_recid': str(my_partner['recid'])}, filt_courrier_template_type_document_ref_interne, filt_type_doc, filt_nom, filt_ref_interne ]}):
user = retval
val_tmp = val_tmp + 1
RetObject.append(mycommon.JSONEncoder().encode(user))
@ -6792,7 +6795,7 @@ def Get_List_Conventions_Stagiaire_With_Filter(diction):
for retval in MYSY_GV.dbname['courrier_template'].find({'$and': [{'ref_interne': 'CONVENTION_STAGIAIRE',
'valide': '1',
'locked': '0',
'partner_owner_recid': 'default'}, filt_type_doc, filt_nom, filt_ref_interne ]}):
'partner_owner_recid': 'default'}, filt_courrier_template_type_document_ref_interne, filt_type_doc, filt_nom, filt_ref_interne ]}):
user = retval
val_tmp = val_tmp + 1
RetObject.append(mycommon.JSONEncoder().encode(user))

File diff suppressed because one or more lines are too long

View File

@ -17,6 +17,7 @@ from datetime import datetime, date
from xhtml2pdf import pisa
import Session_Formation_Sequence
import module_editique
import partner_client
import prj_common as mycommon
import secrets
@ -670,6 +671,136 @@ def GetSessionFormation(diction):
return False, "Impossible de récupérer la session de formation"
"""
Recuperer les données d'un session de formation à partir du _Id seulement et token
"""
def Get_Given_SessionFormation_From_Id(diction):
try:
field_list = ['token', 'session_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é, Creation partenaire annulée")
return False, "de récupérer la liste des stagiaires . Toutes les informations fournies ne sont pas valables"
"""
Verification de la liste des champs obligatoires
"""
field_list_obligatoire = ['token', 'session_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, "Impossible de récupérer la liste des stagiaires, Toutes les informations necessaires n'ont pas été fournies"
# Recuperation du recid du partner
mydata = {}
mytoken = ""
if ("token" in diction.keys()):
if diction['token']:
mytoken = diction['token']
local_status, my_partner = mycommon.Check_Connexion_And_Return_Partner_Data({'token':str(diction['token'])})
if (local_status is not True):
return local_status, my_partner
partner_recid = my_partner['recid']
session_id = ""
if ("session_id" in diction.keys()):
if diction['session_id']:
session_id = diction['session_id']
if(str(session_id).strip() == ""):
return True, []
coll_session = MYSY_GV.dbname['session_formation']
myquery = [{'$match':{'_id':ObjectId(str(session_id)), 'partner_owner_recid':str(partner_recid)}},
{'$lookup':
{
'from': 'myclass',
'localField': 'class_internal_url',
'foreignField': 'internal_url',
'pipeline': [{'$project': {'title': 1, 'lms_class_code':1, 'external_code':1, 'published':1}}],
'as': 'myclass'
}
}
]
print(" ##### myquery Get_Given_SessionFormation_From_Is = "+str(myquery))
RetObject = []
nb_val = 0
for retval in coll_session.aggregate(myquery):
#print(" ##### retval = " + str(retval))
user = {}
user = retval
user['id'] = str(nb_val)
nb_val = nb_val + 1
title = ""
lms_class_code = ""
class_external_code = ""
class_ispublished = "0"
if ('myclass' in retval.keys() and len(retval['myclass']) > 0):
if( "title" in retval['myclass'][0].keys()):
title = retval['myclass'][0]['title']
if ("lms_class_code" in retval['myclass'][0].keys()):
lms_class_code = retval['myclass'][0]['lms_class_code']
if ("external_code" in retval['myclass'][0].keys()):
class_external_code = retval['myclass'][0]['external_code']
if ("published" in retval['myclass'][0].keys()):
class_ispublished = retval['myclass'][0]['published']
user['title'] = title
user['lms_class_code'] = lms_class_code
user['class_external_code'] = class_external_code
user['class_ispublished'] = class_ispublished
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 retval.keys() and retval['formateur_id']):
formateur_data = MYSY_GV.dbname['ressource_humaine'].find_one({'_id':ObjectId(str(retval['formateur_id'])),
'valide':'1',
'locked':'0',
'partner_recid':str(partner_recid)
})
if(formateur_data and "nom" in formateur_data.keys() and "prenom" in formateur_data.keys() ):
formateur_nom_prenom = str(formateur_data['nom'])+" "+str(formateur_data['prenom'])
user['formateur_nom_prenom'] = formateur_nom_prenom
#print(" ### user = ", user)
RetObject.append(mycommon.JSONEncoder().encode(user))
# Si le nombre de session trouvé est > 1 alors incohérence, retourner une message d'erreur
if( nb_val > 1 ):
mycommon.myprint(str(inspect.stack()[0][3]) + " - la query "+str(myquery)+" retourne "+str(nb_val)+" session. ceci n'est pas normal. il ne doit pas y avoir plus 1 session")
return False, " Les informations de la session "+str(session_id)+" sont incohérentes. Merci de contacter le support"
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) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
return False, "Impossible de récupérer la session de formation"
"""
@ -4157,15 +4288,19 @@ def Prepare_and_Send_Convention_From_Session_By_Email(tab_files, Folder, diction
"""
25/01/2024 : pour loger une action dans la collection ==> courrier_template_tracking_history
"""
courrier_template_type_document_id = "-1"
if( "courrier_template_type_document_id" in courrier_template_data.keys() ):
courrier_template_type_document_id = courrier_template_data['courrier_template_type_document_id']
local_status, local_retval = module_editique.Editic_Log_History_Action(my_partner, courrier_template_data,
str(diction['session_id']))
"""
courrier_template_type_document_ref_interne = ""
if( "courrier_template_type_document_ref_interne" in courrier_template_data.keys() ):
courrier_template_type_document_ref_interne = courrier_template_data['courrier_template_type_document_ref_interne']
courrier_template_tracking_id = ""
courrier_template_tracking_data = MYSY_GV.dbname['courrier_template_tracking'].find_one({'partner_owner_recid':str(my_partner['recid']),
'valide':'1',
'locked':'0',
'courrier_template_type_document_id':str(courrier_template_type_document_id)})
'courrier_template_type_document_ref_interne':str(courrier_template_type_document_ref_interne)})
if(courrier_template_tracking_data is None ):
mycommon.myprint(
" WARNING impossible de recuperer le 'courrier_template_tracking' pour courrier_template_id : " +str(diction['courrier_template_id']) )
@ -4187,7 +4322,7 @@ def Prepare_and_Send_Convention_From_Session_By_Email(tab_files, Folder, diction
MYSY_GV.dbname['courrier_template_tracking_history'].insert_one(history_data_to_log)
"""
return True, " Les conventions ont été correctement envoyées par emails"
except Exception as e:
@ -4677,8 +4812,53 @@ def Prepare_and_Send_Convention_From_Session_By_PDF(diction):
if os.path.exists(zip_file_name):
# print(" ### ok os.path.exists(outputFilename) "+str(outputFilename))
"""
25/01/2024 : pour loger une action dans la collection ==> courrier_template_tracking_history
"""
"""
courrier_template_type_document_ref_interne = ""
if ("courrier_template_type_document_ref_interne" in courrier_template_data.keys()):
courrier_template_type_document_ref_interne = courrier_template_data[
'courrier_template_type_document_ref_interne']
courrier_template_tracking_id = ""
courrier_template_tracking_data = MYSY_GV.dbname['courrier_template_tracking'].find_one(
{'partner_owner_recid': str(my_partner['recid']),
'valide': '1',
'locked': '0',
'courrier_template_type_document_ref_interne': str(courrier_template_type_document_ref_interne)})
if (courrier_template_tracking_data is None):
mycommon.myprint(
" WARNING impossible de recuperer le 'courrier_template_tracking' pour courrier_template_id : " + str(
diction['courrier_template_id']))
return True, " WARNING impossible de récuperer le 'courrier_template_tracking' pour courrier_template_id : " + str(
diction['courrier_template_id'])
courrier_template_tracking_id = str(courrier_template_tracking_data['_id'])
history_data_to_log = {}
history_data_to_log['partner_owner_recid'] = str(my_partner['recid'])
history_data_to_log['related_collection_recid'] = str(diction['session_id'])
history_data_to_log['courrier_template_tracking_id'] = courrier_template_tracking_id
history_data_to_log['date_update'] = str(datetime.now())
history_data_to_log['update_by'] = str(my_partner['_id'])
history_data_to_log['valide'] = "1"
history_data_to_log['locked'] = "0"
print("#### history_data_to_log = ", history_data_to_log)
MYSY_GV.dbname['courrier_template_tracking_history'].insert_one(history_data_to_log)
"""
"""
25/01/2024 : pour loger une action dans la collection ==> courrier_template_tracking_history
"""
local_status, local_retval = module_editique.Editic_Log_History_Action(my_partner, courrier_template_data,
str(diction['session_id']))
return True, send_file(zip_file_name, as_attachment=True)
return False, " Impossible de générer les conventions par pdf PDF (1) "

14
main.py
View File

@ -2080,6 +2080,20 @@ def GetSessionFormation():
return jsonify(status=localStatus, message=message )
"""
API de recuperation session de formation, ceci à partir du _Id seulement et token
"""
@app.route('/myclass/api/Get_Given_SessionFormation_From_Id/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_Given_SessionFormation_From_Id():
# On recupere le corps (payload) de la requete
payload = mycommon.strip_dictionary (request.form.to_dict())
print(" ### Get_Given_SessionFormation_From_Id : payload = ",str(payload))
localStatus, message= SF.Get_Given_SessionFormation_From_Id(payload)
return jsonify(status=localStatus, message=message )
"""
API de suppression d'une session de formation :
/!\ : il faut s'assurer qu'il n'y a aucune inscription avant de supprimer valide.

View File

@ -209,19 +209,15 @@ def Get_Editable_Document_By_Partner_By_Collection(diction):
{'$sort': {'rang': 1}},
{'$lookup': {
'from': 'courrier_template_type_document',
"let": {'courrier_template_type_document_id': "$courrier_template_type_document_id", 'partner_owner_recid': '$partner_owner_recid'},
"let": {'courrier_template_type_document_ref_interne': '$courrier_template_type_document_ref_interne',
'partner_owner_recid': '$partner_owner_recid'},
'pipeline': [
{'$match':
{'$expr':
{'$and':
[
{'$eq': ["$_id", {'$convert': {
'input': "$$courrier_template_type_document_id",
'to': "objectId",
'onError': {'error': 'true'},
'onNull': {'isnull': 'true'}
}}]},
{'$eq': ["$ref_interne", '$$courrier_template_type_document_ref_interne']},
{'$eq': ["$valide", "1"]},
{'$eq': ["$partner_owner_recid", '$$partner_owner_recid']}
@ -241,7 +237,10 @@ def Get_Editable_Document_By_Partner_By_Collection(diction):
}
])
print(" #### Get_Editable_Document_By_Partner_By_Collection pipe_qry_Get_Editable_Document_By_Partner = ", pipe_qry)
#print(" #### Get_Editable_Document_By_Partner_By_Collection pipe_qry_Get_Editable_Document_By_Partner = ", pipe_qry)
json_formatted_str = json.dumps(pipe_qry, indent=2)
print(" #### Get_Editable_Document_By_Partner_By_Collection pipe_qry_Get_Editable_Document_By_Partner = ", json_formatted_str)
for New_retVal in MYSY_GV.dbname['courrier_template_tracking'].aggregate(pipe_qry):
if ("collection_courrier_template" in New_retVal.keys()):
@ -297,6 +296,7 @@ def Get_Editable_Document_By_Partner_By_Collection(diction):
user['courrier_template_type_doc'] = str(
New_retVal['collection_courrier_template']['type_doc'])
list_document_history_event = []
has_history_event = "0"
if( "related_collection_recid" in diction.keys() and diction['related_collection_recid']):
"""
@ -310,16 +310,21 @@ def Get_Editable_Document_By_Partner_By_Collection(diction):
'valide':'1',
'locked':'0'}
print(" #### is_document_has_history_event qry = ", local_qry)
#print(" #### is_document_has_history_event qry = ", local_qry)
is_document_has_history_event = MYSY_GV.dbname['courrier_template_tracking_history'].count_documents(local_qry)
if( is_document_has_history_event > 0 ):
has_history_event = "1"
for val in MYSY_GV.dbname['courrier_template_tracking_history'].find(local_qry):
list_document_history_event.append(val)
#print(" #### is_document_has_history_event RESULT = ", is_document_has_history_event)
#print(" #### is_document_has_history_event RESULT = ", is_document_has_history_event)
user['has_history_event'] = has_history_event
user['list_document_history_event'] = list_document_history_event
#print(" #### user['list_document_history_event'] = ", user['list_document_history_event'] )
val_tmp = val_tmp + 1
RetObject.append(mycommon.JSONEncoder().encode(user))
@ -591,7 +596,7 @@ def Init_And_Update_courrier_template_tracking(diction):
new_data['courrier_template_type_document_id'] = str(retval['_id'])
new_data['partner_owner_recid'] = str(my_partner['recid'])
new_data['related_collection'] = str(collection)
new_data['courrier_template_ref_interne'] = str(retval['ref_interne'])
new_data['courrier_template_type_document_ref_interne'] = str(retval['ref_interne'])
new_data['rang'] = str(retval['rang'])
new_data['server_action_name'] = "a préciser"
new_data['valide'] = "1"
@ -640,6 +645,52 @@ def Init_And_Update_courrier_template_tracking(diction):
"""
Cette fonction log un historique d'envoie email ou de telechargement
d'un document
"""
def Editic_Log_History_Action(my_partner, courrier_template_data, related_collection_recid):
try:
courrier_template_type_document_ref_interne = ""
if( "courrier_template_type_document_ref_interne" in courrier_template_data.keys() ):
courrier_template_type_document_ref_interne = courrier_template_data['courrier_template_type_document_ref_interne']
courrier_template_tracking_id = ""
courrier_template_tracking_data = MYSY_GV.dbname['courrier_template_tracking'].find_one({'partner_owner_recid':str(my_partner['recid']),
'valide':'1',
'locked':'0',
'courrier_template_type_document_ref_interne':str(courrier_template_type_document_ref_interne)})
if(courrier_template_tracking_data is None ):
mycommon.myprint(
" WARNING impossible de recuperer le 'courrier_template_tracking' ")
return True, " WARNING impossible de récuperer le 'courrier_template_tracking' "
courrier_template_tracking_id = str(courrier_template_tracking_data['_id'])
history_data_to_log = {}
history_data_to_log ['partner_owner_recid'] = str(my_partner['recid'])
history_data_to_log['related_collection_recid'] = related_collection_recid
history_data_to_log['courrier_template_tracking_id'] = courrier_template_tracking_id
history_data_to_log['date_update'] = str(datetime.now())
history_data_to_log['update_by'] = str(my_partner['_id'])
history_data_to_log['valide'] = "1"
history_data_to_log['locked'] = "0"
print( "#### history_data_to_log = ", history_data_to_log)
MYSY_GV.dbname['courrier_template_tracking_history'].insert_one(history_data_to_log)
return True, " L'évènement Editique a été correctement enregistré "
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'enregistrer de l'évènement éditique"
"""
Au lieu de travailler sur : 'courrier_template' dans la reccherche des courriers
je dois créer une nouvelle collection 'type_doc' qui contient les infos statiques de 'courrier_template' comment