21/08/2024 - 13h55

master
cherif 2024-08-21 13:48:39 +02:00
parent 133e7f04c3
commit 272665efde
6 changed files with 3193 additions and 51 deletions

View File

@ -1,16 +1,13 @@
<?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="20/08/2024 - 13h55">
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="20/08/2024 - 21h55">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Dashbord_queries/inscription_tdb_qries.py" beforeDir="false" afterPath="$PROJECT_DIR$/Dashbord_queries/inscription_tdb_qries.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Dashbord_queries/ressources_humaines_tbd_qries.py" beforeDir="false" afterPath="$PROJECT_DIR$/Dashbord_queries/ressources_humaines_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$/apprenant_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/apprenant_mgt.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/lms_chamilo/mysy_lms.py" beforeDir="false" afterPath="$PROJECT_DIR$/lms_chamilo/mysy_lms.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/partner_order.py" beforeDir="false" afterPath="$PROJECT_DIR$/partner_order.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/ressources_humaines.py" beforeDir="false" afterPath="$PROJECT_DIR$/ressources_humaines.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/suivi_pedagogique_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/suivi_pedagogique_mgt.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/survey_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/survey_mgt.py" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -80,13 +77,6 @@
<option name="presentableId" value="Default" />
<updated>1680804787304</updated>
</task>
<task id="LOCAL-00328" summary="ssq">
<created>1717867948694</created>
<option name="number" value="00328" />
<option name="presentableId" value="LOCAL-00328" />
<option name="project" value="LOCAL" />
<updated>1717867948695</updated>
</task>
<task id="LOCAL-00329" summary="qqsd">
<created>1718034595563</created>
<option name="number" value="00329" />
@ -423,7 +413,14 @@
<option name="project" value="LOCAL" />
<updated>1724154821337</updated>
</task>
<option name="localTasksCounter" value="377" />
<task id="LOCAL-00377" summary="20/08/2024 - 21h55">
<created>1724183059275</created>
<option name="number" value="00377" />
<option name="presentableId" value="LOCAL-00377" />
<option name="project" value="LOCAL" />
<updated>1724183059276</updated>
</task>
<option name="localTasksCounter" value="378" />
<servers />
</component>
<component name="Vcs.Log.Tabs.Properties">
@ -465,7 +462,6 @@
</option>
</component>
<component name="VcsManagerConfiguration">
<MESSAGE value="17/07/2024 - 11h30sdf" />
<MESSAGE value="21/07/2024 - 12h" />
<MESSAGE value="23/07/2024 - 12h" />
<MESSAGE value="26/07/2024 - 12h" />
@ -490,6 +486,7 @@
<MESSAGE value="18/08/2024 - 16h55" />
<MESSAGE value="18/08/2024 - 21h55" />
<MESSAGE value="20/08/2024 - 13h55" />
<option name="LAST_COMMIT_MESSAGE" value="20/08/2024 - 13h55" />
<MESSAGE value="20/08/2024 - 21h55" />
<option name="LAST_COMMIT_MESSAGE" value="20/08/2024 - 21h55" />
</component>
</project>

File diff suppressed because one or more lines are too long

42
main.py
View File

@ -10243,6 +10243,22 @@ def Get_List_Suivi_Pedagogique_No_Filter():
"""
API pour Recuperation de la liste des suivis pédagoqiques d'un employe
"""
@app.route('/myclass/api/Get_List_Employee_Suivi_Pedagogique_No_Filter/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_List_Employee_Suivi_Pedagogique_No_Filter():
# On recupere le corps (payload) de la requete
payload = mycommon.strip_dictionary (request.form.to_dict())
print(" ### Get_List_Employee_Suivi_Pedagogique_No_Filter payload = ",payload)
status, retval = suivi_pedagogique_mgt.Get_List_Employee_Suivi_Pedagogique_No_Filter(payload)
return jsonify(status=status, message=retval)
"""
API pour Recuperer les données d'un Suivi Pedagogique
"""
@ -10843,6 +10859,32 @@ def Apply_Planning_Model_To_Session():
"""
API de generation la version PDF d'un contrat d'un employé
"""
@app.route('/myclass/api/Print_Employee_Given_Contrat/<token>/<rh_id>/<contract_id>/', methods=['POST','GET'])
@crossdomain(origin='*')
def Print_Employee_Given_Contrat(token, rh_id, contract_id):
# On recupere le corps (payload) de la requete
payload = mycommon.strip_dictionary (request.form.to_dict())
payload = {}
payload['token'] = str(token)
payload['rh_id'] = str(rh_id)
payload['contract_id'] = str(contract_id)
print(" ### Print_Employee_Given_Contrat : payload = ",str(payload))
localStatus, response= ressources_humaines.Print_Employee_Given_Contrat(payload)
if(localStatus ):
return response
else:
return False
if __name__ == '__main__':
print(" debut api")
context = SSL.Context(SSL.SSLv23_METHOD)

View File

@ -10,11 +10,15 @@ Une ressource humaine a toujours un profil (enseignant, cadre admin) et une fonc
"""
import pymongo
from flask import send_file
from pandas.io.formats.style import jinja2
from pymongo import MongoClient
import json
from bson import ObjectId
import re
from datetime import datetime
from datetime import datetime, date
from xhtml2pdf import pisa
import partners
import prj_common as mycommon
@ -5143,3 +5147,176 @@ def Delete_RH_Competence(diction):
"""
Cette fonction permet d'imprimer le contrat d'un empoyé
"""
def Print_Employee_Given_Contrat(diction):
try:
diction = mycommon.strip_dictionary(diction)
"""
Verification des input acceptés
"""
field_list = ['token', 'rh_id', 'contract_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', 'rh_id', 'contract_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 la ressource_humaine est valide
is_rh_id_valide = MYSY_GV.dbname['ressource_humaine'].count_documents(
{'_id': ObjectId(str(diction['rh_id'])),
'valide': '1',
'locked': '0',
'partner_recid': str(
my_partner['recid'])})
if (is_rh_id_valide != 1):
mycommon.myprint(
str(inspect.stack()[0][3]) + " L'identifiant de la ressource humaine est invalide ")
return False, " L'identifiant de la ressource humaine est invalide "
RetObject = []
val_tmp = 0
for retval in MYSY_GV.dbname['ressource_humaine_contrat'].find({'rh_id':str(diction['rh_id']),
'valide': '1','locked': '0', 'partner_owner_recid': str(my_partner['recid']),
'_id':ObjectId(str(diction['contract_id']))}):
user = retval
user['id'] = str(val_tmp)
val_tmp = val_tmp + 1
RetObject.append(user)
if(len(RetObject) != 1 ):
mycommon.myprint(
str(inspect.stack()[0][3]) + " Il y a "+str(val_tmp)+ " contrats valide pour cet identifiant ")
return False, " Il y a "+str(val_tmp)+ " contrats valide pour cet identifiant "
"""
Recuperer les données de l'employe
"""
rh_employee_data = MYSY_GV.dbname['ressource_humaine'].find_one(
{'_id': ObjectId(str(diction['rh_id'])),
'valide': '1',
'locked': '0',
'partner_recid': str(
my_partner['recid'])})
# Creation du dictionnaire d'information à utiliser pour la creation du doc
convention_dictionnary_data = {}
new_diction = {}
new_diction['token'] = diction['token']
new_diction['list_stagiaire_id'] = []
new_diction['list_session_id'] = []
new_diction['list_class_id'] = []
new_diction['list_client_id'] = []
new_diction['list_apprenant_id'] = []
local_status, local_retval = mycommon.Get_Dictionnary_data_For_Template(new_diction)
if (local_status is False):
return local_status, local_retval
convention_dictionnary_data = local_retval
convention_dictionnary_data['rh_employee_data'] = rh_employee_data
convention_dictionnary_data['rh_contract_data'] = RetObject[0]
body = {
"params": convention_dictionnary_data,
}
"""
Recuperer le modèle de document
"""
local_diction = {}
local_diction['ref_interne'] = "EMPLOYEE_CONTRACT"
local_diction['type_doc'] = "pdf"
local_diction['partner_owner_recid'] = str(my_partner['recid'])
courrier_data_status, courrier_data_retval = mycommon.Get_Courrier_Template_Include_Default_Data(local_diction)
if (courrier_data_status is False):
return courrier_data_status, courrier_data_retval
if ("contenu_doc" not in courrier_data_retval.keys() or str(courrier_data_retval['contenu_doc']) == ""):
mycommon.myprint(
str(inspect.stack()[0][
3]) + " Le modèle de courrier 'EMPLOYEE_CONTRACT' n'est pas correctement configuré ")
return False, " Le modèle de courrier 'EMPLOYEE_CONTRACT' n'est pas correctement configuré "
"""
Creation du fichier PDF
"""
contenu_doc_Template = jinja2.Template(str(courrier_data_retval['contenu_doc']))
sourceHtml = contenu_doc_Template.render(params=body["params"])
todays_date = str(date.today().strftime("%d/%m/%Y"))
ts = datetime.now().timestamp()
ts = str(ts).replace(".", "").replace(",", "")[-3:]
tmp_file_name = str(rh_employee_data['nom']) + "_" + str(rh_employee_data['prenom'])
if (len(str(tmp_file_name)) > 30):
tmp_file_name = str(tmp_file_name)[0:30]
orig_file_name = "Contrat_" + str(tmp_file_name) + "_" + 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()
# print(" ### outputFilename = "+str(outputFilename))
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 de générer la version PDF du contrat "

View File

@ -59,7 +59,7 @@ def Add_Suivi_Pedagogique(diction):
"""
field_list = ['token', 'apprenant_id', 'class_id', 'session_id', 'class_eu_id', 'responsable_id',
'date_heure_debut', 'date_heure_fin', 'observation',
'commentaire', 'employee_id']
'commentaire', 'employee_id', 'sujet']
incom_keys = diction.keys()
for val in incom_keys:
@ -105,7 +105,7 @@ def Add_Suivi_Pedagogique(diction):
# Verifier que la formation et l'ue de la formation existe et sont valides
if( "class_id" in diction.keys() and "class_eu_id" in diction.keys() ):
if( "class_id" in diction.keys() and "class_eu_id" in diction.keys() and diction['class_id'] and diction['class_eu_id']):
is_existe_class_and_class_ue = MYSY_GV.dbname['myclass'].count_documents({ '_id':ObjectId(str(diction['class_id'])),
'list_unite_enseignement._id': str(diction['class_eu_id']),
'partner_owner_recid':my_partner['recid'],
@ -118,7 +118,7 @@ def Add_Suivi_Pedagogique(diction):
str(inspect.stack()[0][3]) + " La formation et l'UE ne sont pas cohérents ")
return False, " La formation et l'UE ne sont pas cohérents "
elif ("class_id" in diction.keys() ):
elif ("class_id" in diction.keys() and diction['class_id'] ):
is_existe_class_and_class_ue = MYSY_GV.dbname['myclass'].count_documents(
{'_id': ObjectId(str(diction['class_id'])),
'partner_owner_recid': my_partner['recid'],
@ -130,10 +130,12 @@ def Add_Suivi_Pedagogique(diction):
str(inspect.stack()[0][3]) + " La formation est invalide ")
return False, " La formation est invalide "
local_eu_data = MYSY_GV.dbname['unite_enseignement'].find_one({'_id': ObjectId(str(diction['class_eu_id'])),
'partner_owner_recid': my_partner['recid'],
'valide': '1',
'locked': '0'})
local_eu_data = None
if( "class_eu_id" in diction.keys() and diction['class_eu_id']):
local_eu_data = MYSY_GV.dbname['unite_enseignement'].find_one({'_id': ObjectId(str(diction['class_eu_id'])),
'partner_owner_recid': my_partner['recid'],
'valide': '1',
'locked': '0'})
"""
Verifier que le l'apprenant est valide
@ -171,8 +173,8 @@ def Add_Suivi_Pedagogique(diction):
str(inspect.stack()[0][3]) + " L'identifiant de l'employé est invalide ")
return False, " L'identifiant de l'employé est invalide "
cible_evaluation_data = MYSY_GV.dbname['apprenant'].find_one(
{'_id': ObjectId(str(diction['apprenant_id'])),
cible_evaluation_data = MYSY_GV.dbname['ressource_humaine'].find_one(
{'_id': ObjectId(str(diction['employee_id'])),
'partner_recid': my_partner['recid'],
'valide': '1',
'locked': '0'})
@ -253,6 +255,11 @@ def Add_Suivi_Pedagogique(diction):
new_data = diction
my_token = str(diction['token'])
my_sujet = ""
if( "sujet" in diction.keys() ):
my_sujet = diction['sujet']
del diction['token']
# Initialisation des champs non envoyés à vide
@ -267,6 +274,8 @@ def Add_Suivi_Pedagogique(diction):
new_data['update_by'] = str(my_partner['_id'])
new_data['partner_owner_recid'] = str(my_partner['recid'])
inserted_id = MYSY_GV.dbname['suivi_pedagogique'].insert_one(new_data).inserted_id
if (not inserted_id):
mycommon.myprint(
@ -284,7 +293,7 @@ def Add_Suivi_Pedagogique(diction):
new_event['token'] = str(my_token)
new_event['related_collection'] = "apprenant"
new_event['related_role'] = "target"
new_event['event_title'] = "Suivi Pédagogique"
new_event['event_title'] = "Suivi Pédagogique "+str(my_sujet)
new_event['event_start'] = datetime.strptime(str(date_heure_debut).strip(), '%d/%m/%Y %H:%M').strftime("%Y-%m-%dT%H:%M")
new_event['event_end'] = datetime.strptime(str(date_heure_fin).strip(), '%d/%m/%Y %H:%M').strftime("%Y-%m-%dT%H:%M")
new_event['related_collection_recid'] = str(diction['apprenant_id'])
@ -292,7 +301,9 @@ def Add_Suivi_Pedagogique(diction):
comment = " Responsable : "+str(is_valide_responsable_data['civilite']) +" "+str(is_valide_responsable_data['prenom'])+" "+str(is_valide_responsable_data['nom'])+" "
comment = comment+ "\n Pour : " + str(cible_evaluation_data['civilite']) + " " + str( cible_evaluation_data['prenom']) + " " + str(cible_evaluation_data['nom']) + " \n "
comment = comment +"\n Unite Enseignement : " + str(local_eu_data['titre'])
if( local_eu_data and "titre" in local_eu_data.keys() ):
comment = comment +"\n Unite Enseignement : " + str(local_eu_data['titre'])
new_event['comment'] = comment
new_event['_id'] = ""
@ -313,19 +324,21 @@ def Add_Suivi_Pedagogique(diction):
new_event['token'] = str(my_token)
new_event['related_collection'] = "ressource_humaine"
new_event['related_role'] = "target"
new_event['event_title'] = "Suivi Pédagogique"
new_event['event_title'] = "Suivi Pédagogique "+str(my_sujet)
new_event['event_start'] = datetime.strptime(str(date_heure_debut).strip(), '%d/%m/%Y %H:%M').strftime(
"%Y-%m-%dT%H:%M")
new_event['event_end'] = datetime.strptime(str(date_heure_fin).strip(), '%d/%m/%Y %H:%M').strftime(
"%Y-%m-%dT%H:%M")
new_event['related_collection_recid'] = str(diction['apprenant_id'])
new_event['related_collection_recid'] = str(diction['employee_id'])
new_event['event_type'] = "autre"
comment = " Responsable : " + str(is_valide_responsable_data['civilite']) + " " + str(
is_valide_responsable_data['prenom']) + " " + str(is_valide_responsable_data['nom']) + " "
comment = comment + "\n Pour : " + str(cible_evaluation_data['civilite']) + " " + str(
cible_evaluation_data['prenom']) + " " + str(cible_evaluation_data['nom']) + " \n "
comment = comment + "\n Unite Enseignement : " + str(local_eu_data['titre'])
if (local_eu_data and "titre" in local_eu_data.keys()):
comment = comment + "\n Unite Enseignement : " + str(local_eu_data['titre'])
new_event['comment'] = comment
new_event['_id'] = ""
@ -333,6 +346,8 @@ def Add_Suivi_Pedagogique(diction):
new_event['linked_collection'] = "suivi_pedagogique"
new_event['linked_collection_recid'] = str(inserted_id)
print(" ### employee_id agenda = ", new_event)
add_agenda_status, add_agenda_retval = agenda.Add_Update_Agenda_Event(new_event)
if (add_agenda_status is False):
@ -343,7 +358,7 @@ def Add_Suivi_Pedagogique(diction):
new_event['token'] = str(my_token)
new_event['related_collection'] = "ressource_humaine"
new_event['related_role'] = "responsable"
new_event['event_title'] = "Suivi Pédagogique"
new_event['event_title'] = "Suivi Pédagogique "+str(my_sujet)
new_event['event_start'] = datetime.strptime(str(date_heure_debut).strip(), '%d/%m/%Y %H:%M').strftime("%Y-%m-%dT%H:%M")
new_event['event_end'] = datetime.strptime(str(date_heure_fin).strip(), '%d/%m/%Y %H:%M').strftime("%Y-%m-%dT%H:%M")
new_event['related_collection_recid'] = str(diction['responsable_id'])
@ -352,15 +367,19 @@ def Add_Suivi_Pedagogique(diction):
comment = " Responsable : " + str(is_valide_responsable_data['civilite']) + " " + str(
is_valide_responsable_data['prenom']) + " " + str(is_valide_responsable_data['nom']) + " "
comment = comment + "\n Pour : " + str(cible_evaluation_data['civilite']) + " " + str( cible_evaluation_data['prenom']) + " " + str(cible_evaluation_data['nom']) + " \n "
comment = comment + "\n Unite Enseignement : " + str(local_eu_data['titre'])
if( local_eu_data and "titre" in local_eu_data.keys() ):
comment = comment + "\n Unite Enseignement : " + str(local_eu_data['titre'])
new_event['comment'] = comment
new_event['_id'] = ""
new_event['linked_collection'] = "suivi_pedagogique"
new_event['linked_collection_recid'] = str(inserted_id)
print(" ### responsible agenda = ", new_event)
add_agenda_status, add_agenda_retval = agenda.Add_Update_Agenda_Event(new_event)
if (add_agenda_status is False):
mycommon.myprint(
" WARNING : Impossible d'ajouter la suivi pédagogique dans l'agenda du responsable ")
@ -386,7 +405,7 @@ def Update_Suivi_Pedagogique(diction):
"""
field_list = ['token', 'apprenant_id', 'class_id', 'session_id', 'class_eu_id', 'responsable_id',
'date_heure_debut', 'date_heure_fin', 'observation',
'commentaire', '_id', 'employee_id']
'commentaire', '_id', 'employee_id', 'sujet']
incom_keys = diction.keys()
for val in incom_keys:
@ -470,10 +489,12 @@ def Update_Suivi_Pedagogique(diction):
str(inspect.stack()[0][3]) + " La formation est invalide ")
return False, " La formation est invalide "
local_eu_data = MYSY_GV.dbname['unite_enseignement'].find_one({'_id': ObjectId(str(diction['class_eu_id'])),
'partner_owner_recid': my_partner['recid'],
'valide': '1',
'locked': '0'})
local_eu_data = None
if( "class_eu_id" in diction.keys() and diction['class_eu_id']):
local_eu_data = MYSY_GV.dbname['unite_enseignement'].find_one({'_id': ObjectId(str(diction['class_eu_id'])),
'partner_owner_recid': my_partner['recid'],
'valide': '1',
'locked': '0'})
"""
Verifier que le l'apprenant est valide
@ -498,6 +519,7 @@ def Update_Suivi_Pedagogique(diction):
'partner_owner_recid': my_partner['recid'],
'valide': '1',
'locked': '0'})
elif (diction["employee_id"]):
is_valide_employee_id = MYSY_GV.dbname['ressource_humaine'].count_documents(
{'_id': ObjectId(str(diction['employee_id'])),
@ -510,8 +532,8 @@ def Update_Suivi_Pedagogique(diction):
str(inspect.stack()[0][3]) + " L'identifiant de l'employé est invalide ")
return False, " L'identifiant de l'employé est invalide "
cible_evaluation_data = MYSY_GV.dbname['apprenant'].find_one(
{'_id': ObjectId(str(diction['apprenant_id'])),
cible_evaluation_data = MYSY_GV.dbname['ressource_humaine'].find_one(
{'_id': ObjectId(str(diction['employee_id'])),
'partner_recid': my_partner['recid'],
'valide': '1',
'locked': '0'})
@ -593,6 +615,11 @@ def Update_Suivi_Pedagogique(diction):
local_suivi_peda_id = diction['_id']
my_token = diction['token']
my_sujet = ""
if( "sujet" in diction.keys() ):
my_sujet = diction['sujet']
new_data = diction
del diction['token']
del diction['_id']
@ -646,7 +673,7 @@ def Update_Suivi_Pedagogique(diction):
new_event['token'] = str(my_token)
new_event['related_collection'] = "apprenant"
new_event['related_role'] = "target"
new_event['event_title'] = "Suivi Pédagogique"
new_event['event_title'] = "Suivi Pédagogique "+str(my_sujet)
new_event['event_start'] = datetime.strptime(str(date_heure_debut).strip(), '%d/%m/%Y %H:%M').strftime(
"%Y-%m-%dT%H:%M")
new_event['event_end'] = datetime.strptime(str(date_heure_fin).strip(), '%d/%m/%Y %H:%M').strftime(
@ -658,7 +685,9 @@ def Update_Suivi_Pedagogique(diction):
is_valide_responsable_data['prenom']) + " " + str(is_valide_responsable_data['nom']) + " "
comment = comment + "\n Pour : " + str(cible_evaluation_data['civilite']) + " " + str(
cible_evaluation_data['prenom']) + " " + str(cible_evaluation_data['nom']) + " \n "
comment = comment + "\n Unite Enseignement : " + str(local_eu_data['titre'])
if( local_eu_data and "titre" in local_eu_data.keys() ):
comment = comment + "\n Unite Enseignement : " + str(local_eu_data['titre'])
new_event['comment'] = comment
new_event['_id'] = str(event_to_update['_id'])
@ -687,19 +716,21 @@ def Update_Suivi_Pedagogique(diction):
new_event['token'] = str(my_token)
new_event['related_collection'] = "ressource_humaine"
new_event['related_role'] = "target"
new_event['event_title'] = "Suivi Pédagogique"
new_event['event_title'] = "Suivi Pédagogique "+str(my_sujet)
new_event['event_start'] = datetime.strptime(str(date_heure_debut).strip(), '%d/%m/%Y %H:%M').strftime(
"%Y-%m-%dT%H:%M")
new_event['event_end'] = datetime.strptime(str(date_heure_fin).strip(), '%d/%m/%Y %H:%M').strftime(
"%Y-%m-%dT%H:%M")
new_event['related_collection_recid'] = str(diction['apprenant_id'])
new_event['related_collection_recid'] = str(diction['employee_id'])
new_event['event_type'] = "autre"
comment = " Responsable : " + str(is_valide_responsable_data['civilite']) + " " + str(
is_valide_responsable_data['prenom']) + " " + str(is_valide_responsable_data['nom']) + " "
comment = comment + "\n Pour : " + str(cible_evaluation_data['civilite']) + " " + str(
cible_evaluation_data['prenom']) + " " + str(cible_evaluation_data['nom']) + " \n "
comment = comment + "\n Unite Enseignement : " + str(local_eu_data['titre'])
if (local_eu_data and "titre" in local_eu_data.keys()):
comment = comment + "\n Unite Enseignement : " + str(local_eu_data['titre'])
new_event['comment'] = comment
new_event['_id'] = str(event_to_update['_id'])
@ -724,12 +755,22 @@ def Update_Suivi_Pedagogique(diction):
'linked_collection': 'suivi_pedagogique',
'linked_collection_recid': str(local_suivi_peda_id)})
print({
'partner_owner_recid': str(my_partner['recid']),
'valide': '1',
'locked': '0',
'related_role': 'responsable',
'related_collection': 'ressource_humaine',
'linked_collection': 'suivi_pedagogique',
'linked_collection_recid': str(local_suivi_peda_id)})
if (event_to_update):
new_event = {}
new_event['token'] = str(my_token)
new_event['related_collection'] = "ressource_humaine"
new_event['event_title'] = "Suivi Pédagogique"
new_event['related_role'] = "responsable"
new_event['event_title'] = "Suivi Pédagogique "+str(my_sujet)
new_event['event_start'] = datetime.strptime(str(date_heure_debut).strip(), '%d/%m/%Y %H:%M').strftime(
"%Y-%m-%dT%H:%M")
new_event['event_end'] = datetime.strptime(str(date_heure_fin).strip(), '%d/%m/%Y %H:%M').strftime(
@ -741,13 +782,16 @@ def Update_Suivi_Pedagogique(diction):
is_valide_responsable_data['prenom']) + " " + str(is_valide_responsable_data['nom']) + " "
comment = comment + "\n Pour : " + str(cible_evaluation_data['civilite']) + " " + str(
cible_evaluation_data['prenom']) + " " + str(cible_evaluation_data['nom']) + " \n "
comment = comment + "\n Unite Enseignement : " + str(local_eu_data['titre'])
if( local_eu_data and "titre" in local_eu_data.keys() ):
comment = comment + "\n Unite Enseignement : " + str(local_eu_data['titre'])
new_event['comment'] = comment
new_event['_id'] = str(event_to_update['_id'])
new_event['linked_collection'] = "suivi_pedagogique"
new_event['linked_collection_recid'] = str(local_suivi_peda_id)
print(" ### new_event update repon = ", new_event)
add_agenda_status, add_agenda_retval = agenda.Add_Update_Agenda_Event(new_event)
@ -891,6 +935,9 @@ def Get_List_Suivi_Pedagogique_No_Filter(diction):
user['ue_code'] = str(ue_code)
user['ue_titre'] = str(ue_titre)
if ("sujet" not in user.keys()):
user['sujet'] = ""
RetObject.append(mycommon.JSONEncoder().encode(user))
@ -904,6 +951,147 @@ def Get_List_Suivi_Pedagogique_No_Filter(diction):
"""
Recuperation de la liste des suivis pédagoqiques d'un employee
"""
def Get_List_Employee_Suivi_Pedagogique_No_Filter(diction):
try:
diction = mycommon.strip_dictionary(diction)
"""
Verification des input acceptés
"""
field_list = ['token', 'employee_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', 'employee_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 le l'apprenant est valide
"""
is_valide_employee = MYSY_GV.dbname['ressource_humaine'].count_documents(
{'_id': ObjectId(str(diction['employee_id'])),
'partner_recid': my_partner['recid'],
'valide': '1',
'locked': '0'})
if (is_valide_employee != 1):
mycommon.myprint(
str(inspect.stack()[0][3]) + " L'identifiant de l'employé est invalide ")
return False, " L'identifiant de l'employé est invalide "
"""
Clés de mise à jour
"""
data_cle = {}
data_cle['partner_owner_recid'] = str(my_partner['recid'])
data_cle['valide'] = "1"
data_cle['locked'] = "0"
data_cle['employee_id'] = str(diction['employee_id'])
RetObject = []
val_tmp = 0
for retval in MYSY_GV.dbname['suivi_pedagogique'].find(data_cle).sort([("_id", pymongo.DESCENDING), ]):
user = retval
user['id'] = str(val_tmp)
val_tmp = val_tmp + 1
# Recuperer l'internal url de la formation
class_title = ""
if ("class_id" in retval.keys() and retval['class_id']):
class_data = MYSY_GV.dbname['myclass'].find_one({'_id': ObjectId(str(retval['class_id'])),
'partner_owner_recid': str(my_partner['recid'])},
{'title': 1})
if (class_data and 'title' in class_data.keys()):
class_title = class_data['title']
user['class_title'] = str(class_title)
# Recuperer session_code
session_code = ""
if ("session_id" in retval.keys() and retval['session_id']):
session_data = MYSY_GV.dbname['session_formation'].find_one({'_id': ObjectId(str(retval['session_id'])),
'partner_owner_recid': str(
my_partner['recid'])},
{'code_session': 1})
if (session_data and 'code_session' in session_data.keys()):
session_code = session_data['code_session']
user['session_code'] = str(session_code)
# Recuperer ue_code
ue_code = ""
ue_titre = ""
if ("class_eu_id" in retval.keys() and retval['class_eu_id']):
unite_enseignement_data = MYSY_GV.dbname['unite_enseignement'].find_one(
{'_id': ObjectId(str(retval['class_eu_id'])),
'partner_owner_recid': str(
my_partner['recid'])},
{'code': 1, 'titre': 1})
if (unite_enseignement_data and 'code' in unite_enseignement_data.keys()):
ue_code = unite_enseignement_data['code']
if (unite_enseignement_data and 'titre' in unite_enseignement_data.keys()):
ue_titre = unite_enseignement_data['titre']
user['ue_code'] = str(ue_code)
user['ue_titre'] = str(ue_titre)
if("sujet" not in user.keys() ):
user['sujet'] = ""
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 suivis pédagogique "
"""
Recuperer les données d'un Suivi Pedagogique
"""
@ -1009,6 +1197,9 @@ def Get_Given_Suivi_Pedagogique(diction):
user['ue_code'] = str(ue_code)
user['ue_titre'] = str(ue_titre)
if ("sujet" not in user.keys()):
user['sujet'] = ""
RetObject.append(mycommon.JSONEncoder().encode(user))

View File

@ -2714,8 +2714,6 @@ def Export_To_Excel_Survey_with_filter_Tab_Survey_Id(diction):
"""
Creation du fichier PDF
"""
contenu_doc_Template = jinja2.Template(str(courrier_data_retval['contenu_doc']))
sourceHtml = contenu_doc_Template.render(params=body["params"])