23/05/2026 - 20h00

Signed-off-by: Cherif <cbalde@mysy-training.com>
master_Elyos_FI
Cherif 2026-05-23 19:54:14 +02:00
parent c4883ff190
commit 23c7bdb124
9 changed files with 5852 additions and 53 deletions

View File

@ -4,21 +4,16 @@
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="20/05/2026 - 20h30">
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="22/05/2026 - 20h">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/GlobalVariable.py" beforeDir="false" afterPath="$PROJECT_DIR$/GlobalVariable.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$/Session_Formation_Sequence.py" beforeDir="false" afterPath="$PROJECT_DIR$/Session_Formation_Sequence.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$/ela_user_account.py" beforeDir="false" afterPath="$PROJECT_DIR$/ela_user_account.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/agenda.py" beforeDir="false" afterPath="$PROJECT_DIR$/agenda.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/ent_student_common.py" beforeDir="false" afterPath="$PROJECT_DIR$/ent_student_common.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/groupe_inscrit_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/groupe_inscrit_mgt.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/partners.py" beforeDir="false" afterPath="$PROJECT_DIR$/partners.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/prj_common.py" beforeDir="false" afterPath="$PROJECT_DIR$/prj_common.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/ressources_humaines.py" beforeDir="false" afterPath="$PROJECT_DIR$/ressources_humaines.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/unite_enseignement_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/unite_enseignement_mgt.py" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -462,7 +457,7 @@
<option name="project" value="LOCAL" />
<updated>1747251650255</updated>
</task>
<option name="localTasksCounter" value="586" />
<option name="localTasksCounter" value="587" />
<servers />
</component>
<component name="Vcs.Log.Tabs.Properties">
@ -504,7 +499,6 @@
</option>
</component>
<component name="VcsManagerConfiguration">
<MESSAGE value="18/04/2026 -19h" />
<MESSAGE value="19/04/2026 - 20h30" />
<MESSAGE value="20/04/2026 - 20h30" />
<MESSAGE value="21/04/2026 - 11h30" />
@ -529,6 +523,7 @@
<MESSAGE value="19/05/2026 - 20h30" />
<MESSAGE value="20/05/2026 - 12h30" />
<MESSAGE value="20/05/2026 - 20h30" />
<option name="LAST_COMMIT_MESSAGE" value="20/05/2026 - 20h30" />
<MESSAGE value="22/05/2026 - 20h" />
<option name="LAST_COMMIT_MESSAGE" value="22/05/2026 - 20h" />
</component>
</project>

View File

@ -775,7 +775,7 @@ PARTNER_BASE_CONFIG_NAME = ['tva', 'smtp_server', 'smtp_user', 'smtp_user_pwd',
'preinscription_notification_email', 'inscription_notification_email','nb_heure_par_jour',
'nb_heure_par_mois', 'nb_heure_par_annee', 'nb_heure_par_semaine',
'annulation_inscription_notification_email', 'partner_devise',
'sequence_code_couleur']
'sequence_code_couleur', 'absence_recever_mail']
"""

File diff suppressed because one or more lines are too long

View File

@ -1671,7 +1671,7 @@ def Get_Partner_Session_Ftion_Reduice_Fields(diction):
'valide':'1',},filt_scope_class_id, filt_scope_session_id, filt_archive, filt_type_session, filt_class_id]},
{'_id':1, 'code_session':1, 'titre':1,
'class_internal_url':1, 'date_debut':1, 'class_id':1,
'date_fin':1}).sort([("_id", pymongo.ASCENDING), ]):
'date_fin':1}).sort([("_id", pymongo.DESCENDING), ]):
user = retval
user['id'] = str(val_tmp)

View File

@ -258,7 +258,7 @@ def Add_Update_Agenda_Event_Stagiaire(diction):
Verification des input acceptés
"""
field_list = ['token', '_id', 'related_collection', 'event_title', 'event_start', 'event_end', 'comment',
'event_type', 'justified', 'related_collection_email', 'inscription_id', 'session_id']
'event_type', 'justified', 'related_collection_email', 'inscription_id', 'session_id', 'apprenant_id']
incom_keys = diction.keys()
for val in incom_keys:
@ -305,10 +305,11 @@ def Add_Update_Agenda_Event_Stagiaire(diction):
Quand on est sur une inscription, on travail avec l'adresse emai. Cela devra bientot changé
une fois que le module 'apprenant' est ok, alors on pourra tout basculer sur l'apprenant et travailler avec l'_id
"""
if( str(str(diction['related_collection'])) == "inscription") :
if( str(str(diction['related_collection'])) == "inscription" and "inscription_id" in diction.keys()) :
is_existe_valide_related_collection_recid = MYSY_GV.dbname[str(diction['related_collection'])].count_documents({'email':str(diction['related_collection_email']),
'partner_owner_recid':str(my_partner['recid']),
'status':'1'
'status':'1',
'_id':ObjectId(str(diction['inscription_id']))
})
if( is_existe_valide_related_collection_recid <= 0):
@ -318,7 +319,7 @@ def Add_Update_Agenda_Event_Stagiaire(diction):
else:
is_existe_valide_related_collection_recid = MYSY_GV.dbname[
str(diction['related_collection'])].count_documents({'_id': ObjectId(str(diction['inscription_id'])),
str(diction['related_collection'])].count_documents({'_id': ObjectId(str(diction['apprenant_id'])),
'partner_owner_recid': str(my_partner['recid']),
'valide': '1',
'locked':'0'
@ -365,6 +366,20 @@ def Add_Update_Agenda_Event_Stagiaire(diction):
session_id = str(diction['session_id'])
mydata['session_id'] = session_id
inscription_id = ""
if ("inscription_id" in diction.keys() and diction['inscription_id']):
is_valide_inscription_id = MYSY_GV.dbname['inscription'].count_documents(
{'_id': ObjectId(diction['inscription_id']),
'partner_owner_recid': str(my_partner['recid'])})
if (is_valide_inscription_id != 1):
mycommon.myprint(
str(inspect.stack()[0][3]) + " - L'inscription est invalide ")
return False, " L'inscription est invalide "
inscription_id = str(diction['inscription_id'])
mydata['inscription_id'] = inscription_id
event_type = ""
if ("event_type" in diction.keys()):
@ -413,14 +428,20 @@ def Add_Update_Agenda_Event_Stagiaire(diction):
# Recup de l'id de l'apprenant
inscription_id = ""
if( "inscription_id" in diction.keys() ):
if( "inscription_id" in diction.keys() and diction['inscription_id']):
inscription_id = str(diction['inscription_id'])
now = str(datetime.now().strftime("%d/%m/%Y %H:%M:%S"))
history_event_dict = {}
history_event_dict['token'] = diction['token']
history_event_dict['related_collection'] = "inscription"
history_event_dict['related_collection_recid'] = str(inscription_id)
if ("inscription_id" in diction.keys() and diction['inscription_id']):
history_event_dict['related_collection'] = "inscription"
history_event_dict['related_collection_recid'] = str(diction['inscription_id'])
else:
history_event_dict['related_collection'] = "apprenant"
history_event_dict['related_collection_recid'] = str(diction['apprenant_id'])
history_event_dict['action_date'] = str(now)
history_event_dict['action_description'] = "Absence du "+str( mydata['event_start'] )+" au "+str(mydata['event_end'])+" "
local_status, local_retval = mycommon.Collection_Historique.Add_Historique_Event(history_event_dict)
@ -652,6 +673,8 @@ def get_Agenda_Event_List_Stagiaire(diction):
val_tmp = 1
total_heure_absence = 0
for New_retVal in MYSY_GV.dbname['agenda'].find({'related_collection':str(diction['related_collection']), 'related_collection_email':str(diction['related_collection_email']),
'partner_owner_recid':str(my_partner['recid']), 'valide':'1', 'locked':'0'}):
@ -738,6 +761,9 @@ def get_Agenda_Event_List_Stagiaire_Total_Nb_Heure(diction):
val_tmp = 1
total_heure_absence = 0
total_heure_absence_justifie = 0
total_heure_absence_non_justifie = 0
for New_retVal in MYSY_GV.dbname['agenda'].find({'related_collection':str(diction['related_collection']), 'related_collection_email':str(diction['related_collection_email']),
'partner_owner_recid':str(my_partner['recid']), 'valide':'1', 'locked':'0'}):
@ -749,7 +775,17 @@ def get_Agenda_Event_List_Stagiaire_Total_Nb_Heure(diction):
total_heure_absence = total_heure_absence + total.total_seconds()/3600
node_total_absence = {'total_heure':str(total_heure_absence)}
if ("justified" in New_retVal.keys() and New_retVal['justified'] == "true"):
total_heure_absence_justifie = total_heure_absence_justifie + total.total_seconds() / 3600
else:
total_heure_absence_non_justifie = total_heure_absence_non_justifie + total.total_seconds() / 3600
total_heure_absence = round(total_heure_absence, 2)
total_heure_absence_justifie = round(total_heure_absence_justifie, 2)
total_heure_absence_non_justifie = round(total_heure_absence_non_justifie, 2)
node_total_absence = {'total_heure':str(total_heure_absence), 'total_heure_absence_justifie':str(total_heure_absence_justifie),
'total_heure_absence_non_justifie':str(total_heure_absence_non_justifie)}
RetObject.append(mycommon.JSONEncoder().encode(node_total_absence))
@ -949,6 +985,8 @@ def Delete_Agenda_Event(diction):
'valide': '1',
'locked': '0'})
print(" ## is_event_exist_data = ", is_event_exist_data)
# L'eventement existe est valide, on autorise la suppression
update = MYSY_GV.dbname['agenda'].delete_one({'_id':ObjectId(str(diction['_id'])),
'partner_owner_recid':str(my_partner['recid']),
@ -961,18 +999,26 @@ def Delete_Agenda_Event(diction):
# Ajout de l'evenement dans l'historique
Important : ici on le fait pour l'objet concerné par l'agenda
"""
now = str(datetime.now().strftime("%d/%m/%Y %H:%M:%S"))
history_event_dict = {}
history_event_dict['token'] = str(diction['token'])
history_event_dict['related_collection'] = str(is_event_exist_data['related_collection'])
history_event_dict['related_collection_recid'] = str(is_event_exist_data['related_collection_recid'])
history_event_dict['action_date'] = str(now)
history_event_dict['action_description'] = " Suppression entrée Agenda Titre : '" + str(
is_event_exist_data['event_title']) + "', Debut : '"+str(is_event_exist_data['event_start'])+"', Fin : '"+str(is_event_exist_data['event_end'])+"' "
local_status, local_retval = mycommon.Collection_Historique.Add_Historique_Event(history_event_dict)
if (local_status is False):
mycommon.myprint(
" WARNING : Impossible de logguer l'historique pour l'entrée Agenda: " + str(diction['_id']))
if( "related_collection_recid" in is_event_exist_data.keys() and is_event_exist_data['related_collection_recid'] and
"related_collection" in is_event_exist_data.keys() and is_event_exist_data[
'related_collection']
):
now = str(datetime.now().strftime("%d/%m/%Y %H:%M:%S"))
history_event_dict = {}
history_event_dict['token'] = str(diction['token'])
history_event_dict['related_collection'] = str(is_event_exist_data['related_collection'])
history_event_dict['related_collection_recid'] = str(is_event_exist_data['related_collection_recid'])
history_event_dict['action_date'] = str(now)
history_event_dict['action_description'] = " Suppression entrée Agenda Titre : '" + str(
is_event_exist_data['event_title']) + "', Debut : '"+str(is_event_exist_data['event_start'])+"', Fin : '"+str(is_event_exist_data['event_end'])+"' "
local_status, local_retval = mycommon.Collection_Historique.Add_Historique_Event(history_event_dict)
if (local_status is False):
mycommon.myprint(
" WARNING : Impossible de logguer l'historique pour l'entrée Agenda: " + str(diction['_id']))
return True, " L'événement a été supprimé"

View File

@ -34,6 +34,8 @@ from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.mime.base import MIMEBase
from email import encoders
from datetime import datetime
from zoneinfo import ZoneInfo
"""
Important : Seules session avec 'session_status'= '1' (actif sont pris en compte)
@ -656,6 +658,7 @@ def Get_Ent_Student_Session_Sequence_List(diction):
RetObject = []
val_tmp = 0
nb_sequence = 0
for New_retVal in MYSY_GV.dbname['session_formation_sequence'].find({'$and':[
{'partner_owner_recid':str(apprenant_data['partner_owner_recid']), 'valide':'1', 'locked':'0'},
filt_session]}):
@ -727,9 +730,13 @@ def Get_Ent_Student_Session_Sequence_List(diction):
if (domaine_competence_id_data and 'couleur' in domaine_competence_id_data.keys()):
domaine_competence_color = domaine_competence_id_data['couleur']
user['domaine_competence_color'] = domaine_competence_color
user['sequence_code_couleur_setup'] = sequence_code_couleur_setup
tab_grp_apprenant_ids = []
if ("tab_grp_apprenant_ids" in user.keys() and user['tab_grp_apprenant_ids']):
for local_grp_apprenant in user['tab_grp_apprenant_ids']:
@ -763,7 +770,7 @@ def Get_Ent_Student_Session_Sequence_List(diction):
if ("ue_id" not in user.keys()):
user['ue_id'] = ""
elif ("ue_id" in user.keys() and user['ue_id']):
elif ("ue_id" in user.keys() and user['ue_id'] and "session_id" in diction.keys()):
"""
16/05/2026 - Verifier que cette UE est toujours rattachée à la session concernée
@ -1038,7 +1045,7 @@ def Get_Ent_Student_Inscrit_List_EU(diction):
except Exception as e:
exc_type, exc_obj, exc_tb = sys.exc_info()
print(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
return False, " Impossible de recuperer les UE associées à l'inscription"
@ -1181,7 +1188,7 @@ def Get_Ent_Student_Inscrit_List_EU_Type_Evaluation(diction):
except Exception as e:
exc_type, exc_obj, exc_tb = sys.exc_info()
print(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
return False, " Impossible de recuperer la liste des évaluation par UE "
@ -1483,7 +1490,7 @@ def Get_Ent_Student_Participant_Notes(diction):
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))
mycommon.mymycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
return False, "Impossible de récupérer les notes de l'apprenant"
@ -1870,16 +1877,11 @@ def Get_Ent_Student_List_object_owner_collection_Stored_Files(diction):
my_query['valide'] = "1"
my_query['partner_owner_recid'] = str(apprenant_data['partner_owner_recid'])
filt_class_id = {}
if( "class_id" in diction.keys()):
filt_class_id = {'tab_related_collection.related_collection':'myclass',
'tab_related_collection.related_collection_id':diction['class_id']}
query = {'$and': [my_query, filt_class_id] }
else:
query = my_query
query = my_query
print(" ### query = ", query)
RetObject = []
nb_val = 0
@ -2030,7 +2032,7 @@ def Get_Ent_Student_List_object_owner_collection_Stored_Files(diction):
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))
mycommon.mymycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
return False, False
"""
@ -2148,7 +2150,7 @@ def Get_Ent_Student_Stored_Downloaded_File(diction):
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))
mycommon.mymycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
return False, False
@ -2558,7 +2560,7 @@ def Get_Ent_Student_update_user_account(diction):
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))
mycommon.mymycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
return False, "Impossible de mettre à jour le compte utilisateur"
@ -2672,7 +2674,7 @@ def Get_Ent_Student_change_user_pwd(diction):
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))
mycommon.mymycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
return False, "Impossible de mettre à jour le mot de passe"
@ -2791,7 +2793,7 @@ def Get_Ent_Student_Stored_Downloaded_File(diction):
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))
mycommon.mymycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
return False, False
@ -2992,7 +2994,7 @@ def Get_Ent_Student_Absence(diction):
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))
mycommon.mymycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
return False, " Impossible de récupérer les absences "
@ -3062,6 +3064,8 @@ def Get_Ent_Student_total_Heure_Absence(diction):
RetObject = []
val_tmp = 1
total_heure_absence = 0
total_heure_absence_justifie = 0
total_heure_absence_non_justifie = 0
for New_retVal in MYSY_GV.dbname['agenda'].find({'related_collection': "apprenant",
'related_collection_email': str(apprenant_data['email']),
@ -3076,8 +3080,17 @@ def Get_Ent_Student_total_Heure_Absence(diction):
total = (b - a)
total_heure_absence = total_heure_absence + total.total_seconds() / 3600
if( "justified" in New_retVal.keys() and New_retVal['justified'] == "true"):
total_heure_absence_justifie = total_heure_absence_justifie + total.total_seconds() / 3600
else:
total_heure_absence_non_justifie = total_heure_absence_non_justifie + total.total_seconds() / 3600
node_total_absence = {'total_heure_absence':str(total_heure_absence)}
total_heure_absence = round(total_heure_absence, 2 )
total_heure_absence_justifie = round(total_heure_absence_justifie, 2)
total_heure_absence_non_justifie = round(total_heure_absence_non_justifie, 2)
node_total_absence = {'total_heure_absence':str(total_heure_absence), 'total_heure_absence_justifie':str(total_heure_absence_justifie),
'total_heure_absence_non_justifie':str(total_heure_absence_non_justifie)}
RetObject.append(mycommon.JSONEncoder().encode(node_total_absence))
@ -3085,7 +3098,7 @@ def Get_Ent_Student_total_Heure_Absence(diction):
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))
mycommon.mymycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
return False, " Impossible de récupérer le total des heures d'absences "
"""
@ -3144,6 +3157,517 @@ def Get_Ent_Student_Apprenant_IMG_Profil(diction):
except Exception as e:
exc_type, exc_obj, exc_tb = sys.exc_info()
print(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
return False, " Impossible de recuperer l'image de profil de l'apprenant"
"""
Cette fonction permet a un étudiant de declarer une absence depuis son ENT
Important : Pour une séquence, un inscrit ne peut demander qu'une seule demande d'absence
"""
def Create_Ent_Student_Absence(tab_files, Folder, diction):
try:
full_file_path = ""
diction = mycommon.strip_dictionary(diction)
"""
Verification des input acceptés
"""
field_list = ['token', 'apprenant_id', 'session_id', 'sequence_id', 'inscription_id',
'raison', 'comment']
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', 'apprenant_id', 'session_id', 'sequence_id', 'inscription_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 la liste des arguments ")
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é de l'apprenant
"""
is_apprenant_valide_count = MYSY_GV.dbname['apprenant'].count_documents(
{'_id': ObjectId(str(diction['apprenant_id'])),
'valide': '1',
'locked': '0',
'partner_owner_recid':str(my_partner['partner_owner_recid'])})
if (is_apprenant_valide_count != 1):
mycommon.myprint(
str(inspect.stack()[0][
3]) + " L'identifiant de l'apprenant est invalide ")
return False, " L'identifiant de l'apprenant est invalide ",
"""
Verifier la validité de l'inscritpion (en liaison avec l'apprenant)
"""
is_valide_inscription_count = MYSY_GV.dbname['inscription'].count_documents({'_id':ObjectId(str(diction['inscription_id'])),
'apprenant_id':str(diction['apprenant_id']),
'session_id':str(diction['session_id']),
'partner_owner_recid':str(my_partner['partner_owner_recid'])})
if (is_valide_inscription_count != 1):
mycommon.myprint(
str(inspect.stack()[0][
3]) + " L'identifiant de l'inscrit est invalide ")
return False, " L'identifiant de l'inscrit est invalide ",
inscription_data = MYSY_GV.dbname['inscription'].find_one(
{'_id': ObjectId(str(diction['inscription_id'])),
'apprenant_id': str(diction['apprenant_id']),
'session_id': str(diction['session_id']),
'partner_owner_recid': str(my_partner['partner_owner_recid'])}, {'email':1, '_id':1})
"""
Verifier la validité de la séquence, en liaison avec la sequence
"""
is_valide_sequence_count = MYSY_GV.dbname['session_formation_sequence'].count_documents(
{'_id': ObjectId(str(diction['sequence_id'])),
'session_id': str(diction['session_id']),
'partner_owner_recid':str(my_partner['partner_owner_recid'])})
if (is_valide_sequence_count != 1):
mycommon.myprint(
str(inspect.stack()[0][
3]) + " L'identifiant de la séquence est invalide ")
return False, " L'identifiant de la séquence est invalide ",
sequence_data = MYSY_GV.dbname['session_formation_sequence'].find_one(
{'_id': ObjectId(str(diction['sequence_id'])),
'session_id': str(diction['session_id']),
'partner_owner_recid':str(my_partner['partner_owner_recid'])})
"""
Verifier qu'il n'y pas déja une demande d'absence pour cette sequence
pour cet inscrit
"""
exist_demande_absene_inscrit_sequence = MYSY_GV.dbname['agenda'].count_documents({ 'partner_owner_recid':str(my_partner['partner_owner_recid']),
'related_collection':'apprenant',
'inscription_id':diction['inscription_id'],
'sequence_session_id':str(diction['sequence_id'])})
if( exist_demande_absene_inscrit_sequence > 0 ):
mycommon.myprint(
str(inspect.stack()[0][
3]) + " Vous avez déjà une demande dabsence pour cette séquence de formation. ")
return False, "Vous avez déjà une demande dabsence pour cette séquence de formation. ",
"""
Verifier la validité de la session de formation
"""
is_valide_session_count = MYSY_GV.dbname['session_formation'].count_documents(
{'_id': ObjectId(str(diction['session_id'])),
'partner_owner_recid': str(my_partner['partner_owner_recid'])})
if (is_valide_session_count != 1):
mycommon.myprint(
str(inspect.stack()[0][
3]) + " L'identifiant de la promotion est invalide ")
return False, " L'identifiant de la promotion est invalide ",
session_date = MYSY_GV.dbname['session_formation'].find_one(
{'_id': ObjectId(str(diction['session_id'])),
'partner_owner_recid': str(my_partner['partner_owner_recid'])}, {'formateur_id':1, '_id':1})
tab_destinataire_email = []
if(session_date and "formateur_id" in diction.keys() and diction['formateur_id'] ):
formateur_data = MYSY_GV.dbname['ressource_humaine'].find_one({'_id':ObjectId(diction['formateur_id'] ),
'partner_recid': str(my_partner['partner_owner_recid'])}, {'email':1, 'nom':1, 'prenom':1})
if( formateur_data and 'email' in formateur_data.keys() and formateur_data['email']):
tab_destinataire_email.append(formateur_data['email'])
# Aller chercher la boite mail qui admin qui traite ces demandes
base_partner_setup_data = MYSY_GV.dbname['base_partner_setup'].find_one({'config_name':'absence_recever_mail',
'partner_owner_recid': str(
my_partner['partner_owner_recid'])
})
if(base_partner_setup_data and "config_value" in base_partner_setup_data.keys() and base_partner_setup_data['config_value']):
list_tmp_adr = str(base_partner_setup_data['config_value']).strip().replace(";", ",").split(",")
for tmp in list_tmp_adr:
if( tmp ):
tab_destinataire_email.append(tmp)
"""
Sauvegarde des pièce justificative
"""
# 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)
# Traitement de l'eventuel fichier joint
tab_files_to_attache_to_mail = []
tab_list_file_for_queu_mail_and_internal_mail = []
for file_name_full_path in tab_saved_file_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(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(file_name_full_path)))
new_node = {"attached_file": file_to_attache_to_mail}
tab_files_to_attache_to_mail.append(new_node)
tab_list_file_for_queu_mail_and_internal_mail.append(file_name_full_path)
"""
Recuperer le modèle de document
"""
courrier_data_retval = MYSY_GV.dbname['courrier_template'].find_one(
{'ref_interne': "ENT_ABSENCE_CREATION",
'valide': '1',
'locked': '0',
'type_doc':'email',
'partner_owner_recid': str(my_partner['partner_owner_recid'])}
)
if( not courrier_data_retval or "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 'ENT_ABSENCE_CREATION' n'est pas correctement configuré ")
return False, " Le modèle de courrier 'ENT_ABSENCE_CREATION' n'est pas correctement configuré "
"""
Recuperation du dictionnaire des info
"""
new_diction = {}
new_diction['token'] = diction['token']
new_diction['list_stagiaire_id'] = [ObjectId(str(diction['inscription_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.From_ENT_Get_Dictionnary_data_For_Template(new_diction, my_partner)
if (local_status is False):
return local_status, local_retval
absence_dictionnary_data = local_retval
"""
Aller créer l'absence a proprement dit
"""
absence_data = {}
absence_data['related_collection'] = "apprenant"
absence_data['related_collection_recid'] = str(diction['apprenant_id'])
absence_data['related_collection_email'] = str(inscription_data['email'])
absence_data['inscription_id'] = str(inscription_data['_id'])
absence_data['session_id'] = str(diction['session_id'])
absence_data['sequence_session_id'] = str(diction['sequence_id'])
absence_data['event_type'] = "absence"
absence_data['justified'] = "false"
absence_data['partner_owner_recid'] = str(my_partner['partner_owner_recid'])
absence_data['valide'] = "1"
absence_data['locked'] = "0"
absence_data['event_title'] = str(sequence_data['sequence_title'])
abs_from = str(sequence_data['sequence_start'])
abs_from_fromated = datetime.strptime(abs_from, "%d/%m/%Y %H:%M").replace(tzinfo=ZoneInfo("Europe/Paris")).isoformat()
abs_to = str(sequence_data['sequence_end'])
abs_to_fromated = datetime.strptime(abs_to, "%d/%m/%Y %H:%M").replace(tzinfo=ZoneInfo("Europe/Paris")).isoformat()
absence_data['event_start'] = str(abs_from_fromated)
absence_data['event_end'] = str(abs_to_fromated)
if( "comment" in diction.keys() ):
absence_data['comment'] = str(diction['comment'])[0:320]
else:
absence_data['comment'] = ""
if ("raison" in diction.keys()):
absence_data['raison'] = str(diction['raison'])
else:
absence_data['raison'] = ""
if( "ue_id" in sequence_data.keys() ):
absence_data['ue_id'] = sequence_data['ue_id']
else:
absence_data['ue_id'] = ""
if ("obligatoire" in sequence_data.keys()):
absence_data['obligatoire'] = sequence_data['obligatoire']
else:
absence_data['obligatoire'] = ""
if ("mode_animation" in sequence_data.keys()):
absence_data['obligatoire'] = sequence_data['mode_animation']
else:
absence_data['mode_animation'] = ""
insert = MYSY_GV.dbname['agenda'].insert_one(absence_data)
absence_data['event_start_converted'] = datetime.fromisoformat(absence_data['event_start']).strftime("%d/%m/%Y %H:%M")
absence_data['event_end_converted'] = datetime.fromisoformat(absence_data['event_end']).strftime("%d/%m/%Y %H:%M")
if ("raison" in absence_data.keys() and absence_data['raison']):
absence_data['raison'] = str(diction['raison']).capitalize()
absence_data['accept_button'] = MYSY_GV.CLIENT_URL_BASE + "absence/accept/" + str(my_partner['partner_owner_recid']) + "/" + str(insert.inserted_id) + "/"
absence_data['refuse_button'] = MYSY_GV.CLIENT_URL_BASE + "absence/refuse/" + str(my_partner['partner_owner_recid']) + "/" + str(insert.inserted_id) + "/"
absence_dictionnary_data['absence_data'] = absence_data
company_data = {
"params": absence_dictionnary_data,
}
#print(" ### company_data = ", company_data)
"""
1 - Creation du PDF
"""
contenu_doc_Template = jinja2.Template(str(courrier_data_retval['contenu_doc']))
sourceHtml = contenu_doc_Template.render(params=company_data["params"])
html_mime = MIMEText(sourceHtml, 'html')
# Creation de l'email à enoyer
msg = MIMEMultipart("alternative")
# Creation de l'email à enoyer
msg = MIMEMultipart("alternative")
# Attacher l'eventuelle pièces jointes
for myfile in tab_files_to_attache_to_mail:
msg.attach(myfile['attached_file'])
# Traitement du sujet du mail
sujet_mail_Template = jinja2.Template(str(courrier_data_retval['sujet']))
sujetHtml = sujet_mail_Template.render(params=company_data["params"])
# Recuperation des donnes smpt
local_stpm_status, partner_SMTP_COUNT_smtpsrv, partner_own_smtp_value, partner_SMTP_COUNT_password, partner_SMTP_COUNT_user, partner_SMTP_COUNT_From_User, partner_SMTP_COUNT_port = mycommon.Get_Partner_SMTP_Param(
my_partner['partner_owner_recid'])
if (local_stpm_status is False):
return local_stpm_status, partner_SMTP_COUNT_smtpsrv
msg.attach(html_mime)
if (str(partner_own_smtp_value) == "1"):
msg['From'] = partner_SMTP_COUNT_From_User
else:
msg['From'] = str(partner_SMTP_COUNT_From_User)
msg['Bcc'] = 'contact@mysy-training.com'
msg['Subject'] = sujetHtml
toaddrs = ",".join(tab_destinataire_email)
msg['to'] = toaddrs
#msg['cc'] = str(responsable_compte_email)
smtpserver = smtplib.SMTP(partner_SMTP_COUNT_smtpsrv, partner_SMTP_COUNT_port)
smtpserver.ehlo()
smtpserver.starttls()
smtpserver.login(partner_SMTP_COUNT_user, partner_SMTP_COUNT_password)
val = smtpserver.send_message(msg)
smtpserver.close()
print(" Email envoyé icii" + str(val))
return True, "L'absence a été enregistré"
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 d'enregistrer l'absence"
"""
Cette fonction sur le clic d'un bouton d'accepter le motif d'une absence
important : il n'est pas possible de faire cette action plusieurs fois sur
un document.
on va donc introduire une notion 'decided':'1'
"""
def Absence_Accept_Motif_From_Mail_No_Token(diction):
try:
diction = mycommon.strip_dictionary(diction)
"""
Verification des input acceptés
"""
field_list = ['agenda_id', 'partner_owner_recid' ]
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 = ['agenda_id', 'partner_owner_recid' ]
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 la liste des arguments ")
return False, " Les informations fournies sont incorrectes"
"""
Verifier la validité de l'absence
"""
is_valide_absence_count = MYSY_GV.dbname['agenda'].count_documents({'_id':ObjectId(diction['agenda_id']),
'partner_owner_recid':str(diction['partner_owner_recid']),
'decision_done':{'$ne':'1'}})
if( is_valide_absence_count != 1 ):
mycommon.myprint(
str(inspect.stack()[0][
3]) + " L'identifiant de l'absence est invalide ")
return False, " Document invalide "
update_data = {}
update_data['update_date'] = str(datetime.now())
update_data['update_by'] = "web_button"
update_data['justified'] = "true"
update_data['decision_done'] = "1"
ret_val2 = MYSY_GV.dbname['agenda'].find_one_and_update(
{'_id': ObjectId(diction['agenda_id']),
'partner_owner_recid': str(diction['partner_owner_recid']),
'decision_done': {'$ne': '1'}},
{"$set": update_data},
return_document=ReturnDocument.AFTER,
upsert=False,
)
return True, "L'absence a été correctement mises à jour"
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 mettre à jour l'absence "
def Absence_Refuse_Motif_From_Mail_No_Token(diction):
try:
diction = mycommon.strip_dictionary(diction)
"""
Verification des input acceptés
"""
field_list = ['agenda_id', 'partner_owner_recid']
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 = ['agenda_id', 'partner_owner_recid']
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 la liste des arguments ")
return False, " Les informations fournies sont incorrectes"
"""
Verifier la validité de l'absence
"""
is_valide_absence_count = MYSY_GV.dbname['agenda'].count_documents({'_id': ObjectId(diction['agenda_id']),
'partner_owner_recid': str(
diction['partner_owner_recid']),
'decision_done': {'$ne': '1'}})
if (is_valide_absence_count != 1):
mycommon.myprint(
str(inspect.stack()[0][
3]) + " L'identifiant de l'absence est invalide ")
return False, " Document invalide "
update_data = {}
update_data['update_date'] = str(datetime.now())
update_data['update_by'] = "web_button"
update_data['justified'] = "false"
update_data['decision_done'] = "1"
ret_val2 = MYSY_GV.dbname['agenda'].find_one_and_update(
{'_id': ObjectId(diction['agenda_id']),
'partner_owner_recid': str(diction['partner_owner_recid']),
'decision_done': {'$ne': '1'}},
{"$set": update_data},
return_document=ReturnDocument.AFTER,
upsert=False,
)
return True, "L'absence a été correctement mises à jour"
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 mettre à jour l'absence "

45
main.py
View File

@ -15401,6 +15401,51 @@ def Get_Ent_Student_Apprenant_IMG_Profil():
return jsonify(status=status, message=retval)
"""
API pour declarer une absence par un étudiant depuis l'ENT
"""
@app.route('/myclass/api/Create_Ent_Student_Absence/', methods=['POST','GET'])
@crossdomain(origin='*')
def Create_Ent_Student_Absence():
# On recupere le corps (payload) de la requete
payload = mycommon.strip_dictionary (request.form.to_dict())
print(" ### Create_Ent_Student_Absence : payload = ",str(payload))
tab_files = []
if request.method == 'POST':
# Create variable for uploaded file
for tmp in request.files.getlist("File"):
tab_files.append(tmp)
status, retval = ent_student_common.Create_Ent_Student_Absence(tab_files, MYSY_GV.TEMPORARY_DIRECTORY_V2, payload)
return jsonify(status=status, message=retval)
"""
API pour accepter le motif d'absence en cliquant sur un bouton mail
"""
@app.route('/myclass/api/Absence_Accept_Motif_From_Mail_No_Token/', methods=['POST','GET'])
@crossdomain(origin='*')
def Absence_Accept_Motif_From_Mail_No_Token():
# On recupere le corps (payload) de la requete
payload = mycommon.strip_dictionary (request.form.to_dict())
print(" ### Absence_Accept_Motif_From_Mail_No_Token : payload = ",str(payload))
status, retval = ent_student_common.Absence_Accept_Motif_From_Mail_No_Token( payload)
return jsonify(status=status, message=retval)
"""
API pour refuser le motif d'absence en cliquant sur un bouton mail
"""
@app.route('/myclass/api/Absence_Refuse_Motif_From_Mail_No_Token/', methods=['POST','GET'])
@crossdomain(origin='*')
def Absence_Refuse_Motif_From_Mail_No_Token():
# On recupere le corps (payload) de la requete
payload = mycommon.strip_dictionary (request.form.to_dict())
print(" ### Absence_Refuse_Motif_From_Mail_No_Token : payload = ",str(payload))
status, retval = ent_student_common.Absence_Refuse_Motif_From_Mail_No_Token( payload)
return jsonify(status=status, message=retval)

View File

@ -1862,6 +1862,49 @@ def getRecodedParnterImage_from_front(diction=None):
return False, " Impossible de recupérer les images/médias du partenaire"
def ENT_getRecodedParnterImage_from_front(ent_my_partner=None):
try:
my_partner = ent_my_partner
qery_images = {'locked': '0', 'valide': '1', 'related_collection': 'partnair_account',
'related_collection_recid': str(my_partner['partner_owner_recid'])}
#print(" ### qery_images = ", qery_images)
RetObject = []
partner_images = {}
cpt = 0
# Recuperation des image 'logo' et 'cachet' si le partenaire en a
for retVal in MYSY_GV.dbname['mysy_images'].find(qery_images):
if ('type_img' in retVal.keys()):
if (retVal['type_img'] == "logo"):
partner_images['logo_img'] = retVal['img'].decode()
partner_images['logo_img_recid'] = retVal['recid']
cpt = cpt + 1
if (retVal['type_img'] == "cachet"):
partner_images['cachet_img'] = retVal['img'].decode()
partner_images['cachet_img_recid'] = retVal['recid']
cpt = cpt + 1
if( cpt > 0):
RetObject.append(JSONEncoder().encode(partner_images))
#print(" ### getRecodedParnterImage_from_front RetObject = ", RetObject)
return True, RetObject
else:
mycommon.myprint(
str(inspect.stack()[0][3]) + " Aucune image (Logo ou Cachet trouvé) ")
return False, "Aucune image (Logo ou Cachet trouvé) "
except Exception as e:
exc_type, exc_obj, exc_tb = sys.exc_info()
print(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
return False, " Impossible de recupérer les images/médias du partenaire"
'''

View File

@ -5400,6 +5400,362 @@ def Get_Dictionnary_data_For_Template(diction):
return False, " Impossible de récupérer le dictionnaire pour les template"
"""
Recuperation des données quand c'est une connexion depuis l'ENT"""
def From_ENT_Get_Dictionnary_data_For_Template(diction, ent_my_partner):
try:
diction = strip_dictionary(diction)
"""
Verification des input acceptés
"""
field_list = ['token', 'list_stagiaire_id', 'list_session_id', 'list_class_id', 'list_client_id',
'list_apprenant_id', 'list_sequence_session_id', 'list_jury_soutenance_id', 'list_candidat_admission_id',
]
incom_keys = diction.keys()
for val in incom_keys:
if val not in field_list and val.startswith('my_') is False:
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', 'list_stagiaire_id', 'list_session_id', 'list_class_id', 'list_client_id']
for val in field_list_obligatoire:
if val not in diction:
myprint(
str(inspect.stack()[0][3]) + " - La valeur '" + val + "' n'est pas presente dans la liste des arguments ")
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']
my_partner = ent_my_partner
dictionnary_data = {}
connected_user_data = {}
"""
Traitement des données du : connected_user_data
"""
connected_user_liste_champ = ['email', 'nom', 'prenom', ]
for champ in connected_user_liste_champ:
if (champ in my_partner):
new_champ_name = "connected_user_" + str(champ)
new_field = {new_champ_name: str(my_partner[champ])}
connected_user_data.update(new_field)
else:
new_champ_name = "connected_user_" + str(champ)
new_field = {new_champ_name: ""}
connected_user_data.update(new_field)
dictionnary_data['connected_user_data'] = connected_user_data
"""
Recuperartion des champs de la société à laquelle est rattaché l'utilisateur
"""
# Recuperation des données du partenaire associé à l'utilisateur connecté
local_status, local_retval = Get_Connected_User_Partner_Data_From_RecID(my_partner['partner_owner_recid'])
if (local_status is False):
return local_status, local_retval
local_company_data = local_retval
company_data = {}
company_liste_champ = ['nom', 'email', 'telephone', 'num_nda', 'website', 'adr_street', 'adr_zip', 'adr_city',
'adr_country', 'siret', 'contact_nom', 'contact_prenom', 'contact_tel', 'contact_mail']
for champ in company_liste_champ:
if (champ in local_company_data):
new_champ_name = "societe_" + str(champ)
new_field = {new_champ_name: str(local_company_data[champ])}
company_data.update(new_field)
else:
new_champ_name = "societe_" + str(champ)
new_field = {new_champ_name: ""}
company_data.update(new_field)
# Recuperation du logo et du cachet de la société si il y en a
local_part_status, local_part_imgs = partners.ENT_getRecodedParnterImage_from_front(my_partner)
if(local_part_status is False ):
myprint(str(inspect.stack()[0][3]) + " WARNING : Impossible de récuperer le logo et le cachet du partenaire ")
new_field_logo = {'societe_logo':'data:image/png;base64,'}
new_field_cachet = {'societe_cachet': 'data:image/png;base64,'}
company_data.update(new_field_logo)
company_data.update(new_field_cachet)
else:
local_JSON = ast.literal_eval(local_part_imgs[0])
new_field_logo = {'societe_logo': "data:image/png;base64,"+local_JSON['logo_img']}
new_field_cachet = {'societe_cachet': "data:image/png;base64,"+local_JSON['cachet_img']}
if ("logo_img" in local_JSON.keys() and local_JSON['logo_img']):
new_field_logo = {'societe_logo': "data:image/png;base64," + local_JSON['logo_img']}
else:
new_field_logo = {'societe_logo': "data:image/png;base64,"}
if ("cachet_img" in local_JSON.keys() and local_JSON['cachet_img']):
new_field_cachet = {'societe_cachet': "data:image/png;base64," + local_JSON['cachet_img']}
else:
new_field_cachet = {'societe_cachet': "data:image/png;base64,"}
company_data.update(new_field_logo)
company_data.update(new_field_cachet)
"""
Recuperer les données bancaire
"""
bank_data_node = {}
for bank_data in MYSY_GV.dbname['partnair_account_bank'].find({'partner_owner_recid': str(my_partner['partner_owner_recid'])}):
if( "code_banque" in bank_data.keys()):
bank_data_node['bank_code_banque'] = bank_data['code_banque']
else:
bank_data_node['bank_code_banque'] = ""
if ("code_guichet" in bank_data.keys()):
bank_data_node['bank_code_guichet'] = bank_data['code_guichet']
else:
bank_data_node['bank_code_guichet'] = ""
if ("compte_bancaire" in bank_data.keys()):
bank_data_node['bank_compte_bancaire'] = bank_data['compte_bancaire']
else:
bank_data_node['bank_compte_bancaire'] = ""
if ("code_cle" in bank_data.keys()):
bank_data_node['bank_code_cle'] = bank_data['code_cle']
else:
bank_data_node['bank_code_cle'] = ""
if ("code_iban" in bank_data.keys()):
bank_data_node['bank_code_iban'] = bank_data['code_iban']
else:
bank_data_node['bank_code_iban'] = ""
if ("code_bic" in bank_data.keys()):
bank_data_node['bank_code_bic'] = bank_data['code_bic']
else:
bank_data_node['bank_code_bic'] = ""
company_data['bank_data'] = bank_data_node
dictionnary_data['company_data'] = company_data
"""
Recuperartion des champs des apprenants
"""
list_apprenant_data = []
if( "list_apprenant_id" in diction.keys()):
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',
'date_naissance', 'naissance_departement', 'naissance_lieu', 'naissance_pays', 'nationalite', 'num_secu',
'piece_identite_num', 'situation_famille', 'matricule']
qry_apprenant = {'_id': {'$in': tab_apprenant_id, },
'valide': '1',
'locked':'0',
'partner_owner_recid': str(my_partner['partner_owner_recid'])
}
#print(" #### qry_apprenant = ", qry_apprenant)
for apprenant_data in MYSY_GV.dbname['apprenant'].find({'_id': {'$in': tab_apprenant_id, },
'valide': '1',
'locked':'0',
'partner_owner_recid': str(my_partner['partner_owner_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:
#print(" ## traitement du champ : ", 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_owner_recid':str(my_partner['partner_owner_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)
# ----
if (champ == "financeur_rattachement_id"):
financeur_rattachement_nom = "";
if ("financeur_rattachement_id" in apprenant_data.keys() and apprenant_data[
'financeur_rattachement_id']):
client_rattachement_id_data = MYSY_GV.dbname['partner_client'].find_one(
{'_id': ObjectId(str(apprenant_data['financeur_rattachement_id'])),
'valide': '1',
'locked': '0',
'partner_owner_recid': str(my_partner['partner_owner_recid'])},
{'nom': 1})
if (client_rattachement_id_data and "nom" in client_rattachement_id_data.keys()):
financeur_rattachement_nom = str(client_rattachement_id_data["nom"])
new_champ_name = "apprenant_financeur_rattachement_nom"
new_field = {new_champ_name: str(financeur_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)
#print(" ### APPEND new_apprenant_data = ", new_apprenant_data)
dictionnary_data['list_apprenant_data'] = list_apprenant_data
"""
Recuperartion des champs des stagiaires
"""
list_stagiaire_data = []
tab_stagiaire_id = diction['list_stagiaire_id']
stagiaire_liste_champ = ['email', 'nom', 'prenom', 'telephone', 'client_rattachement_id', 'employeur',
'modefinancement', 'tuteur1_adresse', 'tuteur1_cp', 'tuteur1_email', 'tuteur1_nom',
'tuteur1_pays', 'tuteur1_telephone', 'tuteur1_ville', 'tuteur1_prenom',
'tuteur2_adresse', 'tuteur2_cp', 'tuteur2_email', 'tuteur2_nom', 'tuteur2_pays',
'tuteur2_prenom','civilite',
'tuteur2_telephone', 'tuteur2_ville','adresse', 'code_postal', 'ville', 'pays',
'memo', 'comment', 'date_naissance', 'num_secu', 'naissance_lieu']
for stagiaire_data in MYSY_GV.dbname['inscription'].find({'_id': {'$in': tab_stagiaire_id, },
'partner_owner_recid': str(my_partner['partner_owner_recid'])
}):
new_stagiaire_data = {}
for champ in stagiaire_liste_champ:
if (champ in stagiaire_data):
new_champ_name = "stagiaire_" + str(champ)
new_field = {new_champ_name: str(stagiaire_data[champ])}
new_stagiaire_data.update(new_field)
else:
new_champ_name = "stagiaire_" + str(champ)
new_field = {new_champ_name: ""}
new_stagiaire_data.update(new_field)
list_stagiaire_data.append(new_stagiaire_data)
dictionnary_data['list_stagiaire_data'] = list_stagiaire_data
"""
Recuperartion des champs des formations
"""
list_myclass_data = []
tab_myclass_id = diction['list_class_id']
myclass_liste_champ = ['certif', 'cpf', 'metier', 'objectif', 'title', 'duration', 'duration_unit',
'methode_pedagogique' , 'suivi_eval']
for myclass_data in MYSY_GV.dbname['myclass'].find({'_id': {'$in': tab_myclass_id, },
'valide': '1',
'partner_owner_recid': str(my_partner['partner_owner_recid'])
}):
new_myclass_data = {}
for champ in myclass_liste_champ:
if (champ in myclass_data):
new_champ_name = "formation_" + str(champ)
new_field = {new_champ_name: str(myclass_data[champ])}
new_myclass_data.update(new_field)
else:
new_champ_name = "formation_" + str(champ)
new_field = {new_champ_name: ""}
new_myclass_data.update(new_field)
list_myclass_data.append(new_myclass_data)
dictionnary_data['list_class_data'] = list_myclass_data
# Recuperation des données système
# Ajout des champs système comme la date du jour
systeme_data = {}
ct = datetime.now()
ts = ct.timestamp()
date_jour = ct.strftime("%d/%m/%Y")
new_field = {"date_jour": str(date_jour)}
systeme_data.update(new_field)
dictionnary_data['systeme_data'] = systeme_data
json_formatted_str = json.dumps(dictionnary_data, indent=2)
#print(" ### AFFICHAGE dU data dictionnary ")
#print(json_formatted_str)
return True, dictionnary_data
except Exception as e:
exc_type, exc_obj, exc_tb = sys.exc_info()
myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - Line : " + str(exc_tb.tb_lineno))
return False, " Impossible de récupérer le dictionnaire pour les template"
"""
Recuperation du nombre d'heure par jour depuis la confif du partner
"""