12/11/2025 - 22h30

Signed-off-by: Cherif <cbalde@mysy-training.com>
master_Elyos_FI
Cherif 2025-11-12 22:27:18 +01:00
parent 122572d1b3
commit b4c2383456
15 changed files with 37287 additions and 221 deletions

View File

@ -4,29 +4,22 @@
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="29/10/2025 - 22h">
<change afterPath="$PROJECT_DIR$/ent_alert_messages.py" afterDir="false" />
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="04/11/2025 - 12h">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Dashbord_queries/BPF.py" beforeDir="false" afterPath="$PROJECT_DIR$/Dashbord_queries/BPF.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/E_Sign_Document.py" beforeDir="false" afterPath="$PROJECT_DIR$/E_Sign_Document.py" 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$/Job_Cron.py" beforeDir="false" afterPath="$PROJECT_DIR$/Job_Cron.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Job_Cron_Common.py" beforeDir="false" afterPath="$PROJECT_DIR$/Job_Cron_Common.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$/base_class_calcul_note.py" beforeDir="false" afterPath="$PROJECT_DIR$/base_class_calcul_note.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/class_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/class_mgt.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/competence.py" beforeDir="false" afterPath="$PROJECT_DIR$/competence.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/domaine_formation_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/domaine_formation_mgt.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/email_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/email_mgt.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/email_queu/email_queu_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/email_queu/email_queu_mgt.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/emargement.py" beforeDir="false" afterPath="$PROJECT_DIR$/emargement.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/formulaire_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/formulaire_mgt.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$/jury_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/jury_mgt.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/model_planning_sequence_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/model_planning_sequence_mgt.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/survey_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/survey_mgt.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/unite_enseignement_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/unite_enseignement_mgt.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/note_evaluation_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/note_evaluation_mgt.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/prj_common.py" beforeDir="false" afterPath="$PROJECT_DIR$/prj_common.py" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -469,7 +462,7 @@
<option name="project" value="LOCAL" />
<updated>1747251650255</updated>
</task>
<option name="localTasksCounter" value="509" />
<option name="localTasksCounter" value="510" />
<servers />
</component>
<component name="Vcs.Log.Tabs.Properties">
@ -511,7 +504,6 @@
</option>
</component>
<component name="VcsManagerConfiguration">
<MESSAGE value="19/06/2025 -18h" />
<MESSAGE value="20/06/2025 -18h" />
<MESSAGE value="ssqsdqsd" />
<MESSAGE value="25/06/2025 - 18h" />
@ -536,6 +528,7 @@
<MESSAGE value="22/10*2025 - 22h" />
<MESSAGE value="26/10/2025 - 15h" />
<MESSAGE value="29/10/2025 - 22h" />
<option name="LAST_COMMIT_MESSAGE" value="29/10/2025 - 22h" />
<MESSAGE value="04/11/2025 - 12h" />
<option name="LAST_COMMIT_MESSAGE" value="04/11/2025 - 12h" />
</component>
</project>

View File

@ -111,7 +111,8 @@ def Create_E_Document(diction):
Verification des input acceptés
"""
field_list = ['token', 'file_name', 'related_collection', 'related_collection_id',
'email_destinataire', 'source_document', 'type', 'file_cononical_name']
'email_destinataire', 'source_document', 'type', 'file_cononical_name',
'class_id', 'session_d']
incom_keys = diction.keys()
for val in incom_keys:
@ -177,6 +178,17 @@ def Create_E_Document(diction):
new_diction['statut'] = '0'
new_diction['valide'] = '1'
new_diction['locked'] = "0"
if( 'class_id' in diction.keys()):
new_diction['class_id'] = diction['class_id']
else:
new_diction['class_id'] = ""
if ('session_d' in diction.keys()):
new_diction['session_d'] = diction['session_d']
else:
new_diction['session_d'] = ""
new_diction['secret_key_open'] = str(secret_key)
new_diction['email_destinataire'] = str(diction['email_destinataire'])
new_diction['source_document'] = str(diction['source_document'])
@ -229,7 +241,8 @@ def Create_E_Invoice(diction):
Verification des input acceptés
"""
field_list = ['token', 'file_name', 'related_collection', 'related_collection_id',
'email_destinataire', 'source_document', 'type', 'file_cononical_name']
'email_destinataire', 'source_document', 'type', 'file_cononical_name',
'class_id', 'session_d']
incom_keys = diction.keys()
for val in incom_keys:
@ -295,6 +308,17 @@ def Create_E_Invoice(diction):
new_diction['statut'] = '0'
new_diction['valide'] = '1'
new_diction['locked'] = "0"
if ('class_id' in diction.keys()):
new_diction['class_id'] = diction['class_id']
else:
new_diction['class_id'] = ""
if ('session_d' in diction.keys()):
new_diction['session_d'] = diction['session_d']
else:
new_diction['session_d'] = ""
new_diction['secret_key_open'] = str(secret_key)
new_diction['email_destinataire'] = str(diction['email_destinataire'])
new_diction['source_document'] = str(diction['source_document'])
@ -920,8 +944,8 @@ def Create_E_Signature_For_E_Document(file_img=None, Folder=None, diction=None):
with open(qr_code_img_file, "rb") as image2string:
qr_code_converted_string = base64.b64encode(image2string.read()).decode()
outputFilename = ""
orig_file_name = ""
"""
On est sur une fonction sans token, mais pour recuperer des infos en mode connecté comme le dictionnaire
je vais aller prendre le token du compte admin
@ -1314,8 +1338,38 @@ def Create_E_Signature_For_E_Document(file_img=None, Folder=None, diction=None):
new_file['file_name_to_store'] = outputFilename
tab_key_word = ""
if("type" in e_document_data.keys() and e_document_data['type']) :
tab_key_word = str(tab_key_word).strip()+","
else:
tab_key_word = "e-document,"
if ("file_cononical_name" in e_document_data.keys() and e_document_data['file_cononical_name'] ):
tab_key_word = tab_key_word +str(e_document_data['file_cononical_name']).strip()
if ("signed_email" in e_document_data.keys() and e_document_data['signed_email'] ):
tab_key_word = tab_key_word +str(e_document_data['signed_email']).strip()
new_file['tab_key_word'] = tab_key_word
tab_related_collection = []
if ("class_id" in e_document_data.keys() and e_document_data['class_id'] ):
node_class = {}
node_class['related_collection'] = 'myclass'
node_class['related_collection_id'] = str(e_document_data['class_id'])
tab_related_collection.append(node_class)
if ("session_d" in e_document_data.keys() and e_document_data['session_d']):
node_session = {}
node_session['related_collection'] = 'session_formation'
node_session['related_collection_id'] = str(e_document_data['session_d'])
tab_related_collection.append(node_session)
print(" ### new_file new_file = ", new_file)
local_status, local_retval = attached_file_mgt.Internal_Usage_Store_User_Downloaded_File(MYSY_GV.upload_folder, new_file)
local_status, local_retval = attached_file_mgt.Internal_Usage_Store_User_Downloaded_File(MYSY_GV.upload_folder, new_file, tab_related_collection)
if( local_status is False ):
print(" ## WARNONGGG Impossible de stocker le fichier")

View File

@ -3,6 +3,7 @@ Ce fichier contient les variables globales du systeme
'''
from pymongo import MongoClient
from spellchecker import SpellChecker
from nltk.stem.snowball import SnowballStemmer
import spacy
import logging

View File

@ -585,7 +585,7 @@ def AddStagiairetoClass(diction):
else:
local_diction['tab_ue_ids'] = ""
#print(" ### Init_AcceptAttendeeInscription_For_Initial_Formation 11 local_diction = ",local_diction )
print(" ### Init_AcceptAttendeeInscription_For_Initial_Formation 11 local_diction = ",local_diction )
local_inscription_liste_ue_status, local_inscription_liste_ue_retval = Init_AcceptAttendeeInscription_For_Initial_Formation(
local_diction)
@ -6081,6 +6081,8 @@ cette fonction prend en entrée :
- inscription_id
- class_id
Important : on fait l'inscription que pour les UE qui sont marquées sur la session. Verifier la cohérence, que ces
UE soient bien sur la formation aussi.
"""
def Init_AcceptAttendeeInscription_For_Initial_Formation(diction):
@ -6145,7 +6147,7 @@ def Init_AcceptAttendeeInscription_For_Initial_Formation(diction):
"""
Suppression des données existe dans les collections : inscription_liste_ue et inscription_liste_ue_type_eval
pour l'inscrit et la formation conernée
pour l'inscrit et la formation concernée
"""
clean_inscription_liste_ue = MYSY_GV.dbname['inscription_liste_ue'].delete_many({"partner_owner_recid": str(my_partner['recid']),
@ -6167,7 +6169,7 @@ def Init_AcceptAttendeeInscription_For_Initial_Formation(diction):
tab_ue_ids.append(tmp)
"""
Recuperer les UE de la formation
Recuperer les UE de la promotion, en s'assurant qu'elle est bien configurée sur la formationformation
"""
tab_class_ue_id = []
@ -6182,9 +6184,26 @@ def Init_AcceptAttendeeInscription_For_Initial_Formation(diction):
if( "list_unite_enseignement" in New_retVal.keys() ):
for local_val in New_retVal['list_unite_enseignement'] :
if( "tab_ue_ids" not in diction.keys() ):
# Verifier que l'UE est presente sur la session / promo
print(" ### local_val = ", local_val)
print(" ### QRYY local_val = ", {"partner_owner_recid": str(my_partner['recid']),
'valide': '1',
'class_id': str(diction['class_id']),
'list_unite_enseignement._id':str(local_val['_id'])})
is_ue_in_session = MYSY_GV.dbname['session_formation'].count_documents({"partner_owner_recid": str(my_partner['recid']),
'valide': '1',
'class_id': str(diction['class_id']),
'list_unite_enseignement._id':str(local_val['_id'])})
print(" ## A INSCRIPTIONNN is_ue_in_session = ", is_ue_in_session)
if( ("tab_ue_ids" not in diction.keys() or str(diction['tab_ue_ids']).strip() == "") and is_ue_in_session > 0 ):
tab_class_ue_id.append(str(local_val['_id']))
print(" ## A INSCRIPTIONNN2222 is_us_in_session = ", is_ue_in_session)
new_data = {}
new_data['inscription_id'] = str(diction['inscription_id'])
new_data['class_id'] = str(diction['class_id'])
@ -6203,6 +6222,7 @@ def Init_AcceptAttendeeInscription_For_Initial_Formation(diction):
key_data['valide'] = "1"
key_data['partner_owner_recid'] = str(my_partner['recid'])
print(" ### key_data = ", key_data)
result = MYSY_GV.dbname['inscription_liste_ue'].find_one_and_update(
key_data,
@ -6215,7 +6235,7 @@ def Init_AcceptAttendeeInscription_For_Initial_Formation(diction):
" Impossible de valider l'inscription pour la formation initiale (2) ")
return False, "Impossible de valider l'inscription pour la formation initiale (2) "
elif ("tab_ue_ids" in diction.keys() and str(local_val['_id']) in tab_ue_ids ):
elif ( "tab_ue_ids" in diction.keys() and str(diction['tab_ue_ids']).strip() != "" and str(local_val['_id']) in tab_ue_ids and is_ue_in_session > 0):
print(" ### traitement inscription PARTIEL UEEE ", str(local_val['_id']))
tab_class_ue_id.append(str(local_val['_id']))
@ -9800,6 +9820,8 @@ def Sent_Convention_Stagiaire_By_Email(tab_files, Folder, diction):
"params": convention_dictionnary_data,
}
orig_file_name = ""
outputFilename = ""
# Verifier s'il s'agit d'un document à envoyer avec une version de pièce jointe.
if ("joint_pdf" in courrier_template_data.keys() and str(courrier_template_data['joint_pdf']) == "1"):
@ -9881,6 +9903,9 @@ def Sent_Convention_Stagiaire_By_Email(tab_files, Folder, diction):
new_e_document_diction['related_collection'] = "inscription"
new_e_document_diction['related_collection_id'] = str(inscription_data['_id'])
new_e_document_diction['class_id'] = str(session_data['class_id'])
new_e_document_diction['session_d'] = str(session_data['_id'])
todays_date = str(date.today().strftime("%d/%m/%Y"))
ts = datetime.now().timestamp()
@ -10083,6 +10108,46 @@ def Sent_Convention_Stagiaire_By_Email(tab_files, Folder, diction):
mycommon.myprint(
" WARNING : Impossible de logguer l'historique pour l'évènement : " + str(history_event_dict))
if (orig_file_name and outputFilename):
new_file = {}
new_file['token'] = diction['token']
type_document = "Convention"
new_file['file_business_object'] = str(orig_file_name)
new_file['file_name'] = str(orig_file_name)
new_file['status'] = "1"
new_file['type_document'] = str(type_document)
new_file['object_owner_collection'] = "inscription"
new_file['object_owner_id'] = str(diction['inscription_id'])
new_file['file_name_to_store'] = outputFilename
tab_key_word = "convention," + str(class_data['external_code']) + "," + str(
session_data['code_session'])
new_file['tab_key_word'] = tab_key_word
tab_related_collection = []
if (class_data):
node_class = {}
node_class['related_collection'] = 'myclass'
node_class['related_collection_id'] = str(class_data['_id'])
tab_related_collection.append(node_class)
if (session_data):
node_session = {}
node_session['related_collection'] = 'session_formation'
node_session['related_collection_id'] = str(session_data['_id'])
tab_related_collection.append(node_session)
# print(" ### new_file new_file = ", new_file)
local_status, local_retval = attached_file_mgt.Internal_Usage_Store_User_Downloaded_File(
MYSY_GV.upload_folder, new_file, tab_related_collection)
if (local_status is False):
print(" ## WARINNGGG Impossible de stocker le fichier de Convocation ")
return True, "L'email a été correctement envoyé "
@ -11703,14 +11768,14 @@ def Sent_Convention_Stagiaire_By_Email_By_Partner_client(tab_files_name_full_pat
# Recuperation du titre de la formation
class_data = MYSY_GV.dbname['myclass'].find({'internal_url': str(session_data['class_internal_url']),
class_data = MYSY_GV.dbname['myclass'].find_one({'internal_url': str(session_data['class_internal_url']),
'valide': '1',
'partner_owner_recid': str(my_partner['recid']),
'locked': '0'})
tab_class = []
for val in class_data:
tab_class.append(val['_id'])
if class_data:
tab_class.append(class_data['_id'])
# Recuperer les données du client
client_data = MYSY_GV.dbname['partner_client'].find_one({'_id':ObjectId(str(diction['partner_client_id'])),
@ -11748,6 +11813,8 @@ def Sent_Convention_Stagiaire_By_Email_By_Partner_client(tab_files_name_full_pat
"params": convention_dictionnary_data,
}
outputFilename = ""
orig_file_name = ""
# ---
sujetHtml = ""
# Verifier s'il s'agit d'un document à envoyer avec une version de pièce jointe.
@ -11834,6 +11901,9 @@ def Sent_Convention_Stagiaire_By_Email_By_Partner_client(tab_files_name_full_pat
new_e_document_diction['related_collection'] = "partner_client"
new_e_document_diction['related_collection_id'] = str(client_data['_id'])
new_e_document_diction['class_id'] = str(session_data['class_id'])
new_e_document_diction['session_d'] = str(session_data['_id'])
todays_date = str(date.today().strftime("%d/%m/%Y"))
ts = datetime.now().timestamp()
ts = str(ts).replace(".", "").replace(",", "")[-2:]
@ -12033,7 +12103,6 @@ def Sent_Convention_Stagiaire_By_Email_By_Partner_client(tab_files_name_full_pat
diction['partner_client_id'])})
for inscription in inscription_data:
# Pour la collection inscription
history_event_dict = {}
history_event_dict['token'] = diction['token']
@ -12080,9 +12149,72 @@ def Sent_Convention_Stagiaire_By_Email_By_Partner_client(tab_files_name_full_pat
mycommon.myprint(
" WARNING : Impossible de logguer l'historique pour l'évènement : " + str(history_event_dict))
"""
On va aller stocker le document
"""
# Recuperation des données du stagiaire
inscription_data = MYSY_GV.dbname['inscription'].find({'session_id': str(diction['session_id']),
'status': '1',
'partner_owner_recid': str(my_partner['recid']),
'client_rattachement_id': str(
diction['partner_client_id'])})
if (orig_file_name and outputFilename):
new_file = {}
new_file['token'] = diction['token']
type_document = "Convention"
new_file['file_business_object'] = str(orig_file_name)
new_file['file_name'] = str(orig_file_name)
new_file['status'] = "1"
new_file['type_document'] = str(type_document)
new_file['object_owner_collection'] = "partner_client"
new_file['object_owner_id'] = str(diction['partner_client_id'])
new_file['file_name_to_store'] = outputFilename
tab_key_word = "convention," + str(class_data['external_code']) + "," + str(
session_data['code_session'])
new_file['tab_key_word'] = tab_key_word
tab_related_collection = []
if (class_data):
node_class = {}
node_class['related_collection'] = 'myclass'
node_class['related_collection_id'] = str(class_data['_id'])
tab_related_collection.append(node_class)
if (session_data):
node_session = {}
node_session['related_collection'] = 'session_formation'
node_session['related_collection_id'] = str(session_data['_id'])
tab_related_collection.append(node_session)
if (inscription_data):
node_inscrit = {}
node_inscrit['related_collection'] = 'inscription'
tab_inscrit = []
for local_inscrit in inscription_data:
tab_inscrit.append(str(local_inscrit['_id']))
node_inscrit['related_collection_id'] = tab_inscrit
tab_related_collection.append(node_inscrit)
# print(" ### new_file new_file = ", new_file)
local_status, local_retval = attached_file_mgt.Internal_Usage_Store_User_Downloaded_File(
MYSY_GV.upload_folder, new_file, tab_related_collection)
if (local_status is False):
print(" ## WARINNGGG Impossible de stocker le fichier de Convocation ")
"""
Gestion des emails via mail_queu et internal email
"""
Gestion des emails via mail_queu et internal email
"""
# Recuperation des donnes smtp
(local_stpm_status, local_SMTP_COUNT_smtpsrv, local_own_smtp_value, local_SMTP_COUNT_password,
local_SMTP_COUNT_user, local_SMTP_COUNT_From_User,

View File

@ -225,7 +225,7 @@ def Prepare_and_Send_Convocation_From_Session_By_Email(tab_files, Folder, dictio
else:
print(" EMAIL DE CONVOCATION DEJA ENVOYEEEE ")
return True, " Les convocations ont été correctement envoyées par emails"
return True, " Les convocations ont été correctement envoyées par email"
except Exception as e:
exc_type, exc_obj, exc_tb = sys.exc_info()
@ -2050,7 +2050,7 @@ def Cron_Send_Attestation_From_Session_By_Email_for_not_sent(Folder, diction):
return False, " L'identifiant de la session est invalide "
is_warning_message = "0"
warning_message = "Les attestation ont été correctement envoyées par emails avec l'attention suivante : "
warning_message = "Les attestation ont été correctement envoyées par email avec l'attention suivante : "
for attestation_formation_data in MYSY_GV.dbname['attestation_formation'].find({"session_id":str(diction['session_id']),
'partner_owner_recid':str(my_partner['recid']),
@ -2132,7 +2132,7 @@ def Cron_Send_Attestation_From_Session_By_Email_for_not_sent(Folder, diction):
if (is_warning_message == "1"):
return True, str(warning_message)
return True, " Les attestation ont été correctement envoyées par emails"
return True, " Les attestation ont été correctement envoyées par email"
except Exception as e:
exc_type, exc_obj, exc_tb = sys.exc_info()
@ -3045,7 +3045,7 @@ def Cron_Send_Emargement_By_Date_By_Email_for_not_sent(Folder, diction):
tab_emargement_ids = []
is_warning_message = "0"
warning_message = "Les demandes d'émargement ont été correctement envoyées par emails avec l'attention suivante : "
warning_message = "Les demandes d'émargement ont été correctement envoyées par email avec l'attention suivante : "
# Recuperer la liste des emargement à envoyer pour le jour = str(todays_date)
@ -3076,7 +3076,7 @@ def Cron_Send_Emargement_By_Date_By_Email_for_not_sent(Folder, diction):
if (is_warning_message == "1"):
return True, str(warning_message), str(len(tab_emargement_ids))
return True, "Les demandes d'émargement envoyées par emails", str(len(tab_emargement_ids))
return True, "Les demandes d'émargement envoyées par email", str(len(tab_emargement_ids))
except Exception as e:
exc_type, exc_obj, exc_tb = sys.exc_info()

File diff suppressed because one or more lines are too long

View File

@ -6174,7 +6174,7 @@ def Prepare_and_Send_Convention_From_Session_By_Email(tab_files, Folder, diction
return True, " Les conventions ont été correctement envoyées par emails"
return True, " Les conventions ont été correctement envoyées par email"
except Exception as e:
exc_type, exc_obj, exc_tb = sys.exc_info()
@ -6370,7 +6370,7 @@ def Prepare_and_Send_Convention_From_Session_For_Selected_Inscrit_By_Email(tab_f
return True, " Les conventions ont été correctement envoyées par emails"
return True, " Les conventions ont été correctement envoyées par email"
except Exception as e:
exc_type, exc_obj, exc_tb = sys.exc_info()
@ -6694,7 +6694,7 @@ def Prepare_and_Send_Default_Convention_From_Session_By_Email(tab_files, Folder,
tab_files_to_attache_to_mail = []
return True, " Les conventions ont été correctement envoyées par emails"
return True, " Les conventions ont été correctement envoyées par email"
except Exception as e:
exc_type, exc_obj, exc_tb = sys.exc_info()
@ -8038,7 +8038,7 @@ def Prepare_and_Send_Attestation_From_Session_By_PDF( diction):
is_warning_message = "0"
warning_message = "Les attestation ont été correctement envoyées par emails avec l'attention suivante : "
warning_message = "Les attestation ont été correctement envoyées par email avec l'attention suivante : "
for attestation_formation_data in MYSY_GV.dbname['attestation_formation'].find({
'partner_owner_recid':str(my_partner['recid']),
'valide':"1",
@ -8608,7 +8608,7 @@ def Prepare_and_Send_Convocation_From_Session_By_Email(tab_files, Folder, dictio
str(str(courrier_template_data['_id'])))
return True, " Les convocations ont été correctement envoyées par emails"
return True, " Les convocations ont été correctement envoyées par email"
except Exception as e:
exc_type, exc_obj, exc_tb = sys.exc_info()
@ -8748,7 +8748,7 @@ def Prepare_and_Send_Convocation_From_Session_For_Selected_Inscrit_By_Email(tab_
str(str(courrier_template_data['_id'])))
return True, " Les convocations ont été correctement envoyées par emails"
return True, " Les convocations ont été correctement envoyées par email"
except Exception as e:
exc_type, exc_obj, exc_tb = sys.exc_info()
@ -9005,7 +9005,7 @@ def Sent_Convocation_Stagiaire_By_Email(tab_files, Folder, diction):
new_diction['list_class_id'] = tab_class
new_diction['list_client_id'] = []
new_diction['list_apprenant_id'] = tab_apprenant
new_diction['list_sequence_session_id'] = tab_sequence_session # zzzzzz
new_diction['list_sequence_session_id'] = tab_sequence_session
local_status, local_retval = mycommon.Get_Dictionnary_data_For_Template(new_diction)
@ -9224,9 +9224,32 @@ def Sent_Convocation_Stagiaire_By_Email(tab_files, Folder, diction):
new_file['file_name_to_store'] = outputFilename
tab_key_word = "convocation,"+str(class_data['external_code'])+","+str(session_data['code_session'])
new_file['tab_key_word'] = tab_key_word
tab_related_collection = []
if( class_data):
node_class = {}
node_class['related_collection'] = 'myclass'
node_class['related_collection_id'] = str(class_data['_id'])
tab_related_collection.append(node_class)
if (session_data):
node_session = {}
node_session['related_collection'] = 'session_formation'
node_session['related_collection_id'] = str(session_data['_id'])
tab_related_collection.append(node_session)
if (inscription_data):
node_inscrit = {}
node_inscrit['related_collection'] = 'inscription'
node_inscrit['related_collection_id'] = str(inscription_data['_id'])
tab_related_collection.append(node_inscrit)
#print(" ### new_file new_file = ", new_file)
local_status, local_retval = attached_file_mgt.Internal_Usage_Store_User_Downloaded_File(
MYSY_GV.upload_folder, new_file)
MYSY_GV.upload_folder, new_file, tab_related_collection)
if (local_status is False):
print(" ## WARINNGGG Impossible de stocker le fichier de Convocation ")
@ -9345,7 +9368,7 @@ def Prepare_and_Send_Attestation_From_Session_By_Email(tab_files, Folder, dictio
is_warning_message = "0"
warning_message = "Les attestation ont été correctement envoyées par emails avec l'attention suivante : "
warning_message = "Les attestation ont été correctement envoyées par email avec l'attention suivante : "
for attestation_formation_data in MYSY_GV.dbname['attestation_formation'].find({"session_id":str(diction['session_id']),
'partner_owner_recid':str(my_partner['recid']),
'valide':"1",
@ -9421,7 +9444,7 @@ def Prepare_and_Send_Attestation_From_Session_By_Email(tab_files, Folder, dictio
if( is_warning_message == "1"):
return True, str(warning_message)
return True, " Les attestations ont été correctement envoyées par emails"
return True, " Les attestations ont été correctement envoyées par email"
except Exception as e:
exc_type, exc_obj, exc_tb = sys.exc_info()
@ -9901,9 +9924,28 @@ def Sent_Attestation_Stagiaire_By_Email(tab_files, Folder, diction):
new_file['file_name_to_store'] = outputFilename
tab_related_collection = []
if (class_data):
node_class = {}
node_class['related_collection'] = 'myclass'
node_class['related_collection_id'] = str(class_data['_id'])
tab_related_collection.append(node_class)
if (session_data):
node_session = {}
node_session['related_collection'] = 'session_formation'
node_session['related_collection_id'] = str(session_data['_id'])
tab_related_collection.append(node_session)
if (inscription_data):
node_inscrit = {}
node_inscrit['related_collection'] = 'inscription'
node_inscrit['related_collection_id'] = str(inscription_data['_id'])
tab_related_collection.append(node_inscrit)
# print(" ### new_file new_file = ", new_file)
local_status, local_retval = attached_file_mgt.Internal_Usage_Store_User_Downloaded_File(
MYSY_GV.upload_folder, new_file)
MYSY_GV.upload_folder, new_file, tab_related_collection)
if (local_status is False):
print(" ## WARNINGGG Impossible de stocker le fichier d'attestation")

View File

@ -86,7 +86,7 @@ def Store_User_Downloaded_File(file=None, Folder=None, diction=None):
Verification des input acceptés
"""
field_list = ['token', 'file_business_object', 'file_name', 'status','object_owner_collection',
'object_owner_id', 'type_document', 'metadata_field']
'object_owner_id', 'type_document', 'metadata_field', 'tab_key_word']
incom_keys = diction.keys()
for val in incom_keys:
if val not in field_list and val.startswith('my_') is False:
@ -159,6 +159,33 @@ def Store_User_Downloaded_File(file=None, Folder=None, diction=None):
elif ( diction['metadata_field'] and str( diction['metadata_field'] ) <= 500 ) :
metadata_field = diction['metadata_field']
"""
La table des mots clés contient au max 5 mots, chanque mot ne doit pas faire plus 50 caracactères
"""
tab_key_word = []
if ("tab_key_word" in diction.keys() and diction['tab_key_word']):
tab_tmp = str(diction['tab_key_word']).replace(";", ",").split(",")
if (len(tab_tmp) > 5):
mycommon.myprint(str(inspect.stack()[0][3]) + " Il y a plus de 5 mots clés de recherche ")
return False, " Il y a plus de 5 mots clés de recherche "
for tmp in tab_tmp:
if (tmp):
if (len(tmp) > 50):
mycommon.myprint(
str(inspect.stack()[0][3]) + "Le mot clé " + str(tmp) + " fait plus de 50 caractères")
return False, " Le mot clé " + str(tmp) + " fait plus de 50 caractères "
tab_key_word.append(str(tmp))
tab_related_collection = []
local_node = {}
local_node['related_collection'] = diction['object_owner_collection']
local_node['related_collection_id'] = diction['object_owner_id']
tab_related_collection.append(local_node)
object_owner_id = ""
if ("object_owner_id" in diction.keys()):
@ -185,6 +212,8 @@ def Store_User_Downloaded_File(file=None, Folder=None, diction=None):
mydata['file_name'] = file.filename
mydata['type_document'] = type_document
mydata['metadata_field'] = metadata_field
mydata['tab_key_word'] = tab_key_word
mydata['tab_related_collection'] = tab_related_collection
mydata['full_path'] = Global_file_name
mydata['file_extention'] = file_extention
mydata['object_owner_collection'] = object_owner_collection
@ -225,7 +254,7 @@ Important : : 24/12/2024
- metadata_field : est un champs de texte qui prends au maximum 500 caractère pour stocker des metadata pour effectuer des recherches
"""
def Internal_Usage_Store_User_Downloaded_File(Folder=None, diction=None):
def Internal_Usage_Store_User_Downloaded_File(Folder=None, diction=None, tab_related_collection=None):
try:
full_file_path = ""
@ -235,7 +264,7 @@ def Internal_Usage_Store_User_Downloaded_File(Folder=None, diction=None):
Verification des input acceptés
"""
field_list = ['token', 'file_business_object', 'file_name', 'status','object_owner_collection', 'object_owner_id',
'file_name_to_store', 'type_document', 'metadata_field']
'file_name_to_store', 'type_document', 'metadata_field', 'tab_key_word']
incom_keys = diction.keys()
for val in incom_keys:
if val not in field_list and val.startswith('my_') is False:
@ -324,6 +353,35 @@ def Internal_Usage_Store_User_Downloaded_File(Folder=None, diction=None):
if diction['document_display_order']:
document_display_order = diction['document_display_order']
"""
La table des mots clés contient au max 5 mots, chanque mot ne doit pas faire plus 50 caracactères
"""
tab_key_word = []
if ("tab_key_word" in diction.keys() and diction['tab_key_word']):
tab_tmp = str(diction['tab_key_word']).replace(";", ",").split(",")
if (len(tab_tmp) > 5):
mycommon.myprint(str(inspect.stack()[0][3]) + " Il y a plus de 5 mots clés de recherche ")
return False, " Il y a plus de 5 mots clés de recherche "
for tmp in tab_tmp:
if (tmp):
if (len(tmp) > 50):
mycommon.myprint(
str(inspect.stack()[0][3]) + "Le mot clé " + str(tmp) + " fait plus de 50 caractères")
return False, " Le mot clé " + str(tmp) + " fait plus de 50 caractères "
tab_key_word.append(str(tmp))
local_node = {}
local_node['related_collection'] = diction['object_owner_collection']
local_node['related_collection_id'] = diction['object_owner_id']
tab_related_collection.append(local_node)
mydata = {}
mydata['file_business_object'] = file_business_object
mydata['date_update'] = str(datetime.now())
@ -331,6 +389,11 @@ def Internal_Usage_Store_User_Downloaded_File(Folder=None, diction=None):
mydata['full_path'] = Global_file_name
mydata['type_document'] = type_document
mydata['metadata_field'] = metadata_field
mydata['tab_key_word'] = tab_key_word
mydata['tab_related_collection'] = tab_related_collection
mydata['file_extention'] = file_extention
mydata['object_owner_collection'] = object_owner_collection
mydata['object_owner_id'] = object_owner_id
@ -512,7 +575,10 @@ def Get_Stored_Downloaded_File_From_Id(diction):
if diction['file_name']:
file_name = diction['file_name']
if( not str(diction['_id']) ):
mycommon.myprint(
str(inspect.stack()[0][3]) + " L'identifiant du fichier est invalide ")
return False, " L'identifiant du fichier est invalide ",
"""
Verifier la validité de l'identifiant
@ -807,6 +873,11 @@ def Get_List_object_owner_collection_Stored_Files(diction):
else:
ret_file['file_extention'] = "file_extention"
if ("tab_key_word" in retval.keys()):
ret_file['tab_key_word'] = retval['tab_key_word']
else:
ret_file['tab_key_word'] = []
"""
Recuperation du nom du client
@ -826,8 +897,87 @@ def Get_List_object_owner_collection_Stored_Files(diction):
ret_file['client_raison_sociale'] = client_raison_sociale
ret_file['client_nom'] = client_nom
tab_related_collection = []
"""
09/11/2025 - Traitement du contenu de la 'tab_related_collection'
- aller y chercher si on a un apprenant ou client ou un RH (les tuteurs par exemple)
"""
if ("tab_related_collection" in retval.keys() and retval['tab_related_collection']):
for tmp_data in retval['tab_related_collection']:
if ('related_collection' in tmp_data.keys() and tmp_data['related_collection'] and
'related_collection_id' in tmp_data.keys() and tmp_data['related_collection_id']):
if (tmp_data['related_collection'] == "partner_client" and tmp_data['related_collection_id']):
# Aller chercher les données du client
local_client_data = MYSY_GV.dbname['partner_client'].find_one(
{'_id': ObjectId(str(tmp_data['related_collection_id'])),
'valide': '1', 'locked': '0',
'partner_owner_recid': str(my_partner['recid'])},
{'raison_sociale': 1, 'nom': 1, 'email': 1, '_id': 1})
local_node = {}
local_node['related_collection'] = 'partner_client'
local_node['related_collection_data'] = local_client_data
tab_related_collection.append(local_node)
ret_file['related_client_nom'] = client_raison_sociale
elif (tmp_data['related_collection'] == "inscription" and tmp_data['related_collection_id']):
# Aller chercher les données de l'inscrit
local_id = ""
if type(tmp_data['related_collection_id']) == list:
local_id = tmp_data['related_collection_id'][0]
else:
local_id = tmp_data['related_collection_id']
local_inscrit_data = MYSY_GV.dbname['inscription'].find_one(
{'_id': ObjectId(str(local_id)),
'valide': '1', 'locked': '0',
'partner_owner_recid': str(my_partner['recid'])},
{'prenom': 1, 'nom': 1, 'email': 1, '_id': 1})
local_node = {}
local_node['related_collection'] = 'inscription'
local_node['related_collection_data'] = local_inscrit_data
tab_related_collection.append(local_node)
ret_file['related_inscrit_email'] = local_inscrit_data['email']
elif (tmp_data['related_collection'] == "session_formation" and tmp_data['related_collection_id']):
# Aller chercher les données de la session
local_session_data = MYSY_GV.dbname['session_formation'].find_one(
{'_id': ObjectId(str(tmp_data['related_collection_id'])),
'valide': '1',
'partner_owner_recid': str(my_partner['recid'])},
{'_id': 1, 'titre': 1, 'code_session': 1})
local_node = {}
local_node['related_collection'] = 'session_formation'
local_node['related_collection_data'] = local_session_data
tab_related_collection.append(local_node)
ret_file['related_code_session'] = local_session_data['code_session']
elif (tmp_data['related_collection'] == "myclass" and tmp_data['related_collection_id']):
# Aller chercher les données de la formation
local_myclass_data = MYSY_GV.dbname['myclass'].find_one(
{'_id': ObjectId(str(tmp_data['related_collection_id'])),
'valide': '1', 'locked': '0',
'partner_owner_recid': str(my_partner['recid'])},
{'_id': 1, 'external_code': 1, 'title': 1})
local_node = {}
local_node['related_collection'] = 'myclass'
local_node['related_collection_data'] = local_myclass_data
tab_related_collection.append(local_node)
ret_file['related_ftion_external_code'] = local_myclass_data['external_code']
ret_file['tab_related_collection'] = tab_related_collection
RetObject.append(mycommon.JSONEncoder().encode(ret_file))
nb_val = nb_val + 1
@ -1028,7 +1178,7 @@ def Get_List_object_owner_collection_Stored_Files_With_Filter(diction):
field_list = ['token', 'filter_object_owner_collection', 'filter_object_owner_id',
'filter_file_business_object', 'date_create_start_date', 'date_create_end_date', 'filter_type_document',
'filter_nom_client', 'filter_formation_external_code', 'filter_session_code',
'filter_class_external_code']
'filter_class_external_code', 'filter_nom_prenom_mail_inscrit']
incom_keys = diction.keys()
for val in incom_keys:
@ -1068,7 +1218,55 @@ def Get_List_object_owner_collection_Stored_Files_With_Filter(diction):
filt_file_business_object = {}
if ("filter_file_business_object" in diction.keys() and diction['filter_file_business_object']):
filt_file_business_object = {
'file_business_object': {'$regex': str(diction['filter_file_business_object']) , "$options": 'i'}}
'file_business_object': {'$regex': mycommon.regex_replace_cartere(str(diction['filter_file_business_object'])) , "$options": 'i'}}
# Gestion du filtre sur le nom, prenom ou mail de l'inscrit
filt_nom_prenom_mail_inscrit = {}
tab_inscrit = []
if( "filter_nom_prenom_mail_inscrit" in diction.keys() and diction['filter_nom_prenom_mail_inscrit']):
# Filtre sur le nom de l'inscrit
tmp_filt_inscrit_nom = {
'nom': {'$regex': mycommon.regex_replace_cartere(str(diction['filter_nom_prenom_mail_inscrit'])) , "$options": 'i'},
'valide': '1',
'locked': '0',
'partner_owner_recid': str(my_partner['recid'])
}
tmp_filt_inscrit_prenom = {
'prenom': {'$regex': mycommon.regex_replace_cartere(str(diction['filter_nom_prenom_mail_inscrit'])),
"$options": 'i'},
'valide': '1',
'locked': '0',
'partner_owner_recid': str(my_partner['recid'])
}
tmp_filt_inscrit_email = {
'email': {'$regex': mycommon.regex_replace_cartere(str(diction['filter_nom_prenom_mail_inscrit'])),
"$options": 'i',},
'valide': '1',
'locked': '0',
'partner_owner_recid': str(my_partner['recid'])
}
qry_inscrit = {"$or": [
tmp_filt_inscrit_nom,
tmp_filt_inscrit_prenom,
tmp_filt_inscrit_email]}
for inscrit_data in MYSY_GV.dbname['inscription'].find(qry_inscrit, {'_id':1}):
tab_inscrit.append(str(inscrit_data['_id']))
if(len(tab_inscrit) > 0 ):
filt_nom_prenom_mail_inscrit = {'tab_related_collection.related_collection':'inscription',
'tab_related_collection.related_collection_id':{'$in': tab_inscrit }}
print(" QEYYY = ", filt_nom_prenom_mail_inscrit)
else:
# Aucun inscrit trouvé avec ce filtre de nom/prenom/mail, don on retourne vide
return True, []
filt_object_owner_collection = {}
@ -1137,14 +1335,22 @@ def Get_List_object_owner_collection_Stored_Files_With_Filter(diction):
filt_session_code = {}
Lists_session_id = []
if ("filter_session_code" in diction.keys() and diction['filter_session_code']):
sub_filt_session_code = {'code_session': {'$regex': str(diction['filter_session_code']), "$options": "i"},
sub_filt_session_code = {'code_session': {'$regex': mycommon.regex_replace_cartere(str(diction['filter_session_code'])), "$options": "i"},
'partner_owner_recid': str(my_partner['recid']), 'valide': '1'}
# Recuperation des '_id' des session dont le nom match en regexp
for List_session_Data in MYSY_GV.dbname['session_formation'].find(sub_filt_session_code, {'_id': 1}):
Lists_session_id.append(str(List_session_Data['_id']))
filt_session_code = {'object_owner_id': {'$in': Lists_session_id, }}
if (len(Lists_session_id) <= 0):
# Aucun inscrit trouvé avec ce filtre, donc on retourne vide
return True, []
filt_session_code = {"$or": [{'object_owner_id': {'$in': Lists_session_id, }},
{'tab_related_collection.related_collection':'session_formation',
'tab_related_collection.related_collection_id':{'$in': Lists_session_id }}
]}
"""
@ -1157,15 +1363,26 @@ def Get_List_object_owner_collection_Stored_Files_With_Filter(diction):
"""
filt_class_external_code = {}
Lists_class_id = []
if ("filter_class_external_code" in diction.keys() and diction['filter_class_external_code']):
sub_filt_class_external_code = {'external_code': {'$regex': str(diction['filter_class_external_code']), "$options": "i"},
if ("filter_formation_external_code" in diction.keys() and diction['filter_formation_external_code']):
sub_filt_class_external_code = {'external_code': {'$regex': mycommon.regex_replace_cartere(str(diction['filter_formation_external_code'])), "$options": "i"},
'partner_owner_recid': str(my_partner['recid']), 'valide': '1', 'locked':'0'}
# Recuperation des '_id' des session dont le nom match en regexp
for List_class_Data in MYSY_GV.dbname['myclass'].find(sub_filt_class_external_code, {'_id': 1}):
Lists_class_id.append(str(List_class_Data['_id']))
filt_class_external_code = {'object_owner_id': {'$in': Lists_class_id, }}
if( len(Lists_class_id) <= 0 ):
# Aucun inscrit trouvé avec ce filtre, donc on retourne vide
return True, []
filt_class_external_code = {"$or": [{'object_owner_id': {'$in': Lists_class_id, }},
{'tab_related_collection.related_collection': 'myclass',
'tab_related_collection.related_collection_id': {'$in': Lists_class_id}}
]}
print(" ## filt_class_external_code = ", filt_class_external_code)
"""
Gestion du filtre nom client.
@ -1174,7 +1391,7 @@ def Get_List_object_owner_collection_Stored_Files_With_Filter(diction):
Lists_partner_client_id = []
if ("filter_nom_client" in diction.keys() and diction['filter_nom_client']):
sub_filt_partner_client_nom = {
'nom': {'$regex': str(diction['filter_nom_client']), "$options": "i"},
'nom': {'$regex': mycommon.regex_replace_cartere(str(diction['filter_nom_client'])), "$options": "i"},
'partner_owner_recid': str(my_partner['recid']), 'valide': '1', 'locked': '0'}
# Recuperation des '_id' des session dont le nom match en regexp
@ -1183,7 +1400,16 @@ def Get_List_object_owner_collection_Stored_Files_With_Filter(diction):
for List_partner_client_Data in MYSY_GV.dbname['partner_client'].find(sub_filt_partner_client_nom, {'_id': 1}):
Lists_partner_client_id.append(str(List_partner_client_Data['_id']))
filt_partner_client_nom = {'object_owner_id': {'$in': Lists_partner_client_id, }}
if (len(Lists_partner_client_id) <= 0):
# Aucun inscrit trouvé avec ce filtre, donc on retourne vide
return True, []
filt_partner_client_nom = {"$or": [{'object_owner_id': {'$in': Lists_partner_client_id, }},
{'tab_related_collection.related_collection': 'partner_client',
'tab_related_collection.related_collection_id': {
'$in': Lists_partner_client_id}}
]}
"""
@ -1217,7 +1443,7 @@ def Get_List_object_owner_collection_Stored_Files_With_Filter(diction):
my_query = {'$and': [ filt_object_owner_collection, filt_filter_object_owner_id, filt_date_creation,
filt_type_document, filt_session_code,filt_partner_client_nom, filt_file_business_object,
filt_class_external_code, {'partner_owner_recid': str(my_partner['recid']),
filt_class_external_code, filt_nom_prenom_mail_inscrit, {'partner_owner_recid': str(my_partner['recid']),
'valide':'1'}]}
new_query = ([ {"$addFields": {
@ -1292,6 +1518,11 @@ def Get_List_object_owner_collection_Stored_Files_With_Filter(diction):
else:
ret_file['file_extention'] = "file_extention"
if ("tab_key_word" in retval.keys()):
ret_file['tab_key_word'] = retval['tab_key_word']
else:
ret_file['tab_key_word'] = []
"""
Recuperation du nom du client
"""
@ -1311,6 +1542,88 @@ def Get_List_object_owner_collection_Stored_Files_With_Filter(diction):
ret_file['client_raison_sociale'] = client_raison_sociale
ret_file['client_nom'] = client_nom
tab_related_collection = []
"""
09/11/2025 - Traitement du contenu de la 'tab_related_collection'
- aller y chercher si on a un apprenant ou client ou un RH (les tuteurs par exemple)
"""
if( "tab_related_collection" in retval.keys() and retval['tab_related_collection']):
for tmp_data in retval['tab_related_collection']:
if( 'related_collection' in tmp_data.keys() and tmp_data['related_collection'] and
'related_collection_id' in tmp_data.keys() and tmp_data['related_collection_id']):
if( tmp_data['related_collection'] == "partner_client" and tmp_data['related_collection_id']):
# Aller chercher les données du client
local_client_data = MYSY_GV.dbname['partner_client'].find_one({'_id':ObjectId(str(tmp_data['related_collection_id'])),
'valide':'1', 'locked':'0',
'partner_owner_recid':str(my_partner['recid'])},
{'raison_sociale':1, 'nom':1, 'email':1, '_id':1})
local_node = {}
local_node['related_collection'] = 'partner_client'
local_node['related_collection_data'] = local_client_data
tab_related_collection.append(local_node)
ret_file['related_client_nom'] = client_raison_sociale
elif( tmp_data['related_collection'] == "inscription" and tmp_data['related_collection_id']):
local_id = ""
if type(tmp_data['related_collection_id']) == list:
local_id = tmp_data['related_collection_id'][0]
else:
local_id = tmp_data['related_collection_id']
# Aller chercher les données de l'inscrit
local_inscrit_data = MYSY_GV.dbname['inscription'].find_one(
{'_id': ObjectId(str(local_id)),
'valide': '1', 'locked': '0',
'partner_owner_recid': str(my_partner['recid'])},
{'prenom': 1, 'nom': 1, 'email': 1, '_id':1})
local_node = {}
local_node['related_collection'] = 'inscription'
local_node['related_collection_data'] = local_inscrit_data
tab_related_collection.append(local_node)
ret_file['related_inscrit_email'] = local_inscrit_data['email']
elif (tmp_data['related_collection'] == "session_formation" and tmp_data['related_collection_id']):
# Aller chercher les données de la session
local_session_data = MYSY_GV.dbname['session_formation'].find_one(
{'_id': ObjectId(str(tmp_data['related_collection_id'])),
'valide': '1',
'partner_owner_recid': str(my_partner['recid'])},
{'_id': 1, 'titre': 1, 'code_session': 1})
local_node = {}
local_node['related_collection'] = 'session_formation'
local_node['related_collection_data'] = local_session_data
tab_related_collection.append(local_node)
ret_file['related_code_session'] = local_session_data['code_session']
elif (tmp_data['related_collection'] == "myclass" and tmp_data['related_collection_id']):
# Aller chercher les données de la formation
local_myclass_data = MYSY_GV.dbname['myclass'].find_one(
{'_id': ObjectId(str(tmp_data['related_collection_id'])),
'valide': '1', 'locked':'0',
'partner_owner_recid': str(my_partner['recid'])},
{'_id': 1, 'external_code': 1, 'title': 1})
local_node = {}
local_node['related_collection'] = 'myclass'
local_node['related_collection_data'] = local_myclass_data
tab_related_collection.append(local_node)
ret_file['related_ftion_external_code'] = local_myclass_data['external_code']
ret_file['tab_related_collection'] = tab_related_collection
RetObject.append(mycommon.JSONEncoder().encode(ret_file))
nb_val = nb_val + 1
@ -1329,7 +1642,6 @@ Cette fonction permet de recuperer une liste de documents
avec plusieurs filtre
"""
def Get_List_object_owner_collection_Stored_Files_With_Filter_No_Token(diction):
try:
@ -1464,6 +1776,12 @@ def Get_List_object_owner_collection_Stored_Files_With_Filter_No_Token(diction):
else:
ret_file['file_extention'] = "file_extention"
if ("tab_key_word" in retval.keys()):
ret_file['tab_key_word'] = retval['tab_key_word']
else:
ret_file['tab_key_word'] = []
"""
Recuperation du nom du client
"""
@ -1483,6 +1801,88 @@ def Get_List_object_owner_collection_Stored_Files_With_Filter_No_Token(diction):
ret_file['client_raison_sociale'] = client_raison_sociale
ret_file['client_nom'] = client_nom
tab_related_collection = []
"""
09/11/2025 - Traitement du contenu de la 'tab_related_collection'
- aller y chercher si on a un apprenant ou client ou un RH (les tuteurs par exemple)
"""
if ("tab_related_collection" in retval.keys() and retval['tab_related_collection']):
for tmp_data in retval['tab_related_collection']:
if ('related_collection' in tmp_data.keys() and tmp_data['related_collection'] and
'related_collection_id' in tmp_data.keys() and tmp_data['related_collection_id']):
if (tmp_data['related_collection'] == "partner_client" and tmp_data['related_collection_id']):
# Aller chercher les données du client
local_client_data = MYSY_GV.dbname['partner_client'].find_one(
{'_id': ObjectId(str(tmp_data['related_collection_id'])),
'valide': '1', 'locked': '0',
'partner_owner_recid': str(ret_file['partner_owner_recid'])},
{'raison_sociale': 1, 'nom': 1, 'email': 1, '_id': 1})
local_node = {}
local_node['related_collection'] = 'partner_client'
local_node['related_collection_data'] = local_client_data
tab_related_collection.append(local_node)
ret_file['related_client_nom'] = client_raison_sociale
elif (tmp_data['related_collection'] == "inscription" and tmp_data['related_collection_id']):
# Aller chercher les données de l'inscrit
local_id = ""
if type(tmp_data['related_collection_id']) == list:
local_id = tmp_data['related_collection_id'][0]
else:
local_id = tmp_data['related_collection_id']
local_inscrit_data = MYSY_GV.dbname['inscription'].find_one(
{'_id': ObjectId(str(local_id)),
'valide': '1', 'locked': '0',
'partner_owner_recid': str(ret_file['partner_owner_recid'])},
{'prenom': 1, 'nom': 1, 'email': 1, '_id': 1})
local_node = {}
local_node['related_collection'] = 'inscription'
local_node['related_collection_data'] = local_inscrit_data
tab_related_collection.append(local_node)
ret_file['related_inscrit_email'] = local_inscrit_data['email']
elif (tmp_data['related_collection'] == "session_formation" and tmp_data['related_collection_id']):
# Aller chercher les données de la session
local_session_data = MYSY_GV.dbname['session_formation'].find_one(
{'_id': ObjectId(str(tmp_data['related_collection_id'])),
'valide': '1',
'partner_owner_recid': str(ret_file['partner_owner_recid'])},
{'_id': 1, 'titre': 1, 'code_session': 1})
local_node = {}
local_node['related_collection'] = 'session_formation'
local_node['related_collection_data'] = local_session_data
tab_related_collection.append(local_node)
ret_file['related_code_session'] = local_session_data['code_session']
elif (tmp_data['related_collection'] == "myclass" and tmp_data['related_collection_id']):
# Aller chercher les données de la formation
local_myclass_data = MYSY_GV.dbname['myclass'].find_one(
{'_id': ObjectId(str(tmp_data['related_collection_id'])),
'valide': '1', 'locked': '0',
'partner_owner_recid': str(ret_file['partner_owner_recid'])},
{'_id': 1, 'external_code': 1, 'title': 1})
local_node = {}
local_node['related_collection'] = 'myclass'
local_node['related_collection_data'] = local_myclass_data
tab_related_collection.append(local_node)
ret_file['related_ftion_external_code'] = local_myclass_data['external_code']
ret_file['tab_related_collection'] = tab_related_collection
RetObject.append(mycommon.JSONEncoder().encode(ret_file))
nb_val = nb_val + 1

View File

@ -431,6 +431,7 @@ def Cacul_UE_Note_By_Evaluation_Type(diction):
print(" QRYY = ", {'partner_owner_recid': str(my_partner['recid']),
'valide': '1',
'locked': '0',
'session_id': str(diction['session_id']),
'class_id': str(diction['class_id']),
'class_eu_id': str(diction['ue_id']),
'type_eval_id': str(evaluation_type_id)} )
@ -439,6 +440,7 @@ def Cacul_UE_Note_By_Evaluation_Type(diction):
for val in MYSY_GV.dbname['note_evaluation'].find({'partner_owner_recid': str(my_partner['recid']),
'valide': '1',
'locked': '0',
'session_id': str(diction['session_id']),
'class_id': str(diction['class_id']),
'class_eu_id': str(diction['ue_id']),
'type_eval_id': str(evaluation_type_id)}):
@ -492,8 +494,6 @@ def Cacul_UE_Note_By_Evaluation_Type(diction):
moyenne_note = round(somme_note / nb_eval, 2)
else :
moyenne_note = "-"
somme_note = "-"
@ -806,14 +806,14 @@ def Cacul_UE_Note_Finale_For_calcul_mode_1(diction):
classement = 0
note_precedente = ""
for sorted_data in MYSY_GV.dbname['session_formation_final_note_classement'].find(basic_qry).sort([("note_finale", pymongo.DESCENDING), ]):
for sorted_data in MYSY_GV.dbname['session_formation_final_note_classement'].find(basic_qry).sort([("note_finale", pymongo.DESCENDING), ]).collation({'locale': "fr", 'numericOrdering': True}):
# Gestion des Execo
if( str(note_precedente) != str(sorted_data['note_finale'])):
classement = classement + 1
note_precedente = str(sorted_data['note_finale'])
#MAJ du rang
#print(" MAJJ classement = ", classement)
#print(" MAJJ classement 0222 = ", classement)
MYSY_GV.dbname['session_formation_final_note_classement'].find_one_and_update(
{'_id':ObjectId(str(sorted_data['_id'])),
'partner_owner_recid':str(sorted_data['partner_owner_recid']),
@ -1258,9 +1258,9 @@ def Get_List_Evaluation_Inscriptio_Note_Classement_With_Filter(diction):
"""
Cette fonction va calculer moyenne par session (formation)
Cette fonction va calculer la moyenne par session (formation)
Précedemment les calculs se faisaient pas UE, a présent nous allons faire le calcul par formation.
Précedemment les calculs se faisaient par UE, a présent nous allons faire le calcul par formation.
Calcul selon la règle :
- [ UE * Coef (UE) ] / nb_coef
@ -1343,16 +1343,31 @@ def Cacul_Session_Note_Finale_For_calcul_mode_1(diction):
'partner_owner_recid': str(my_partner['recid'])})
"""
Recuperer la liste des UE de la formation, avec leur credit et coeff.*
Recuperer la liste des UE qui sont sur la session / promotion, avec leur credit et coeff.*
"""
tab_class_ue = []
if( "list_unite_enseignement" in is_myclass_valide_data.keys() ):
tab_class_ue = is_myclass_valide_data['list_unite_enseignement']
if( "list_unite_enseignement" in is_session_valide_data.keys() ):
for tmp_tab_session_ue in is_session_valide_data['list_unite_enseignement']:
if( tmp_tab_session_ue and '_id' in tmp_tab_session_ue.keys() ):
local_class_eu = MYSY_GV.dbname['myclass'].find_one(
{'_id': ObjectId(str(diction['class_id'])),
'valide': '1',
'locked': '0',
'partner_owner_recid': str(my_partner['recid']),
'list_unite_enseignement._id': str(tmp_tab_session_ue['_id'])},
{ 'list_unite_enseignement.$': 1})
tab_class_ue.append(local_class_eu['list_unite_enseignement'][0])
if(len(tab_class_ue) <= 0 ):
mycommon.myprint(
str(inspect.stack()[0][3]) + " Aucune unité d'enseignement pour cette formation ")
return False, " Aucune unité d'enseignement pour cette formation "
str(inspect.stack()[0][3]) + " Aucune unité d'enseignement pour cette promotion / session ")
return False, " Aucune unité d'enseignement pour cette promotion / session "
# Verifier la validité de la liste des inscrits fournie
@ -1393,6 +1408,7 @@ def Cacul_Session_Note_Finale_For_calcul_mode_1(diction):
session_somme_credit_acquis = 0
for class_ue in tab_class_ue :
for tmps_data in MYSY_GV.dbname['session_formation_final_note_classement'].find({'partner_owner_recid':str(my_partner['recid']),
'ue_id':str(class_ue['_id']),
'inscription_id':str(my_inscription),
@ -1450,7 +1466,7 @@ def Cacul_Session_Note_Finale_For_calcul_mode_1(diction):
'session_id':str(is_session_valide_data['_id']),
'valide': '1',
'locked': '0' }).sort(
[("note_finale", pymongo.DESCENDING), ]):
[("note_finale", pymongo.DESCENDING), ]).collation({'locale': "fr", 'numericOrdering': True}):
if( sorted_data and "note_finale" in sorted_data.keys() ):
# Gestion des Execo
@ -1624,7 +1640,6 @@ def Calcul_Note_Classement_Session(diction):
'session_id':str(is_session_valide_data['_id'])}):
tab_inscrit_id.append(str(inscrit['_id']))
print(" ### str(is_session_valide_data['class_internal_url']) = ", str(is_session_valide_data['class_internal_url']))
is_class_data = MYSY_GV.dbname['myclass'].find_one({'internal_url':str(is_session_valide_data['class_internal_url']),
'valide':'1',
@ -1635,12 +1650,15 @@ def Calcul_Note_Classement_Session(diction):
Preparation des calculs
"""
# On recupere la liste des ue_id de la formation
# On recupere la liste des ue_id de la promotion
tab_ue_id = []
for class_class_ue_data in is_class_data['list_unite_enseignement'] :
for class_class_ue_data in is_session_valide_data['list_unite_enseignement'] :
tab_ue_id.append( str(class_class_ue_data['_id']))
print(" ### ooooo tab_ue_id = ", tab_ue_id)
local_diction = {}
local_diction['token'] = str(diction['token'])
local_diction['class_id'] = str(is_class_data['_id'])
@ -1668,75 +1686,88 @@ def Calcul_Note_Classement_Session(diction):
"""
for class_class_ue_data in is_class_data['list_unite_enseignement'] :
unite_enseignement_data = MYSY_GV.dbname['unite_enseignement'].find_one(
{'_id': ObjectId(str(class_class_ue_data['_id'])),
'valide': '1',
'locked': '0',
})
"""
Verifier si cette UE est sur la session / promotion
"""
is_ue_in_session_count = MYSY_GV.dbname['session_formation'].count_documents({'_id':ObjectId(str(diction['session_id'])),
'valide':'1',
'partner_owner_recid':str(my_partner['recid']),
'list_unite_enseignement._id':str(class_class_ue_data['_id'])})
note_ue_calculation_rule_id = ""
if( "note_ue_calculation_rule_id" in unite_enseignement_data.keys() and unite_enseignement_data['note_ue_calculation_rule_id']):
note_ue_calculation_rule_id = unite_enseignement_data['note_ue_calculation_rule_id']
if( note_ue_calculation_rule_id == ""):
mycommon.myprint(
str(inspect.stack()[0][3]) + " L'unité d'enseignement "+str(unite_enseignement_data['code'])+" n'a pas de règle de calcul de la note")
return False, " L'unité d'enseignement "+str(unite_enseignement_data['code'])+" n'a pas de règle de calcul de la note"
base_calcul_note_class_and_ue_data = MYSY_GV.dbname['base_calcul_note_class_and_ue'].find_one({'_id':ObjectId(str(unite_enseignement_data['note_ue_calculation_rule_id'])),
'valide':'1',
'locked':'0',
'related_collection':'unite_enseignement'})
ue_calcul_fonction_name = ""
if ("fonction_name" in base_calcul_note_class_and_ue_data.keys() and base_calcul_note_class_and_ue_data['fonction_name']):
ue_calcul_fonction_name = base_calcul_note_class_and_ue_data['fonction_name']
if (ue_calcul_fonction_name == ""):
mycommon.myprint(
str(inspect.stack()[0][3]) + " L'unité d'enseignement " + str(
unite_enseignement_data['code']) + " n'a pas de règle de calcul de la note (2) ")
return False, " L'unité d'enseignement " + str(
unite_enseignement_data['code']) + " n'a pas de règle de calcul de la note (2) "
local_coef = "1"
if( "coefficient" in class_class_ue_data.keys() and class_class_ue_data['coefficient'] ):
local_coef = class_class_ue_data['coefficient']
local_seuil_validation = "10"
if ("seuil_validation" in class_class_ue_data.keys() and class_class_ue_data['seuil_validation']):
local_seuil_validation = class_class_ue_data['seuil_validation']
print(" ### Pour l'UE : ",str(unite_enseignement_data['code']),
" Coef : ", local_coef,
" seuil validation : ", local_seuil_validation)
print(" ### la formule de calcul est : ", base_calcul_note_class_and_ue_data['fonction_name'])
#field_list = ['token', 'class_id', 'session_id', 'ue_id', 'tab_inscriptions_ids',]
local_node = {}
local_node['token'] = str(diction['token'])
local_node['class_id'] = str(is_class_data['_id'])
local_node['session_id'] = str(diction['session_id'])
local_node['tab_ue_ids'] = str(unite_enseignement_data['_id'])
list_inscrit_id = ",".join(tab_inscrit_id)
local_node['tab_inscriptions_ids'] = str(list_inscrit_id)
if( is_ue_in_session_count > 0 ):
unite_enseignement_data = MYSY_GV.dbname['unite_enseignement'].find_one(
{'_id': ObjectId(str(class_class_ue_data['_id'])),
'valide': '1',
'locked': '0',
})
possibles = globals().copy()
possibles.update(locals())
cron_function = possibles.get(base_calcul_note_class_and_ue_data['fonction_name'])
note_ue_calculation_rule_id = ""
if( "note_ue_calculation_rule_id" in unite_enseignement_data.keys() and unite_enseignement_data['note_ue_calculation_rule_id']):
if not cron_function:
mycommon.myprint(str(
inspect.stack()[0][3]) + " Fonction '" + str(base_calcul_note_class_and_ue_data['fonction_name']) + "' est introuvable")
note_ue_calculation_rule_id = unite_enseignement_data['note_ue_calculation_rule_id']
print(" Exécution de la fonction : UE de Session = ", base_calcul_note_class_and_ue_data['fonction_name'])
local_status, local_retval = cron_function(local_node)
if( note_ue_calculation_rule_id == ""):
mycommon.myprint(
str(inspect.stack()[0][3]) + " L'unité d'enseignement "+str(unite_enseignement_data['code'])+" n'a pas de règle de calcul de la note")
return False, " L'unité d'enseignement "+str(unite_enseignement_data['code'])+" n'a pas de règle de calcul de la note"
base_calcul_note_class_and_ue_data = MYSY_GV.dbname['base_calcul_note_class_and_ue'].find_one({'_id':ObjectId(str(unite_enseignement_data['note_ue_calculation_rule_id'])),
'valide':'1',
'locked':'0',
'related_collection':'unite_enseignement'})
ue_calcul_fonction_name = ""
if ("fonction_name" in base_calcul_note_class_and_ue_data.keys() and base_calcul_note_class_and_ue_data['fonction_name']):
ue_calcul_fonction_name = base_calcul_note_class_and_ue_data['fonction_name']
if (ue_calcul_fonction_name == ""):
mycommon.myprint(
str(inspect.stack()[0][3]) + " L'unité d'enseignement " + str(
unite_enseignement_data['code']) + " n'a pas de règle de calcul de la note (2) ")
return False, " L'unité d'enseignement " + str(
unite_enseignement_data['code']) + " n'a pas de règle de calcul de la note (2) "
local_coef = "1"
if( "coefficient" in class_class_ue_data.keys() and class_class_ue_data['coefficient'] ):
local_coef = class_class_ue_data['coefficient']
local_seuil_validation = "10"
if ("seuil_validation" in class_class_ue_data.keys() and class_class_ue_data['seuil_validation']):
local_seuil_validation = class_class_ue_data['seuil_validation']
print(" ### Pour l'UE : ",str(unite_enseignement_data['code']),
" Coef : ", local_coef,
" seuil validation : ", local_seuil_validation)
print(" ### la formule de calcul est : ", base_calcul_note_class_and_ue_data['fonction_name'])
#field_list = ['token', 'class_id', 'session_id', 'ue_id', 'tab_inscriptions_ids',]
local_node = {}
local_node['token'] = str(diction['token'])
local_node['class_id'] = str(is_class_data['_id'])
local_node['session_id'] = str(diction['session_id'])
local_node['tab_ue_ids'] = str(unite_enseignement_data['_id'])
list_inscrit_id = ",".join(tab_inscrit_id)
local_node['tab_inscriptions_ids'] = str(list_inscrit_id)
possibles = globals().copy()
possibles.update(locals())
cron_function = possibles.get(base_calcul_note_class_and_ue_data['fonction_name'])
if not cron_function:
mycommon.myprint(str(
inspect.stack()[0][3]) + " Fonction '" + str(base_calcul_note_class_and_ue_data['fonction_name']) + "' est introuvable")
print(" Exécution de la fonction : UE de Session = ", base_calcul_note_class_and_ue_data['fonction_name'])
local_status, local_retval = cron_function(local_node)
class_function_note_calcul_rule = ""
@ -1823,6 +1854,8 @@ def Cacul_UE_Note_Finale_Standard(diction):
str(inspect.stack()[0][3]) + " - La valeur '" + val + "' n'est pas presente dans la liste des arguments ")
return False, " Les informations fournies sont incorrectes"
print(" ## diction ) diction = ", diction)
"""
Verification de l'identité et autorisation de l'entité qui
appelle cette API
@ -2145,7 +2178,7 @@ def Cacul_UE_Note_Finale_Standard(diction):
note_precedente = ""
for sorted_data in MYSY_GV.dbname['session_formation_final_note_classement'].find(basic_qry).sort(
[("note_finale", pymongo.DESCENDING), ]):
[("note_finale", pymongo.DESCENDING), ]).collation({'locale': "fr", 'numericOrdering': True}):
#print(" ### sorted_data = ", sorted_data)
# Gestion des Execo
@ -2230,7 +2263,6 @@ def Cacul_UE_Note_Finale_Standard(diction):
node_note_categorie_session_ue['note_categorie_code'] = val['code']
node_note_categorie_session_ue['pourcentage'] = "0"
print(" ### node_note_categorie_session_ue = ", node_note_categorie_session_ue)
data_key = {}
data_key['ue_id'] = str(local_ue)
@ -2252,13 +2284,12 @@ def Cacul_UE_Note_Finale_Standard(diction):
tab_data = []
for retval in MYSY_GV.dbname['session_formation_final_note_classement'].aggregate(pipe_qry):
print(" ### retval ici pipe_qry = ", retval)
## Calcul du nombre total d'inscrit pour cette UE
total_personne = MYSY_GV.dbname['session_formation_final_note_classement'].count_documents({'partner_owner_recid':str(my_partner['recid']),
'session_id':str(retval['_id']['session_id']),
'ue_id':str(retval['_id']['ue_id'])})
print(" ### total_personne pour UE ("+str(str(retval['_id']['ue_id']))+") = ", total_personne)
node_note_categorie_session_ue = {}
node_note_categorie_session_ue['partner_owner_recid'] = str(my_partner['recid'])
@ -2446,21 +2477,55 @@ def run_ue_pre_calcul_moyenne_somme_v2(diction):
for my_ue_id in tab_ue_ids_splited:
my_ue_id = str(my_ue_id).strip()
print(" ## TGGT my_ue_id = ", my_ue_id)
my_ue_id_data = MYSY_GV.dbname['unite_enseignement'].find_one(
{'_id': ObjectId(str(my_ue_id)),
'valide': '1',
'locked': '0',
'partner_owner_recid': str(my_partner['recid'])})
"""
08/11/2025
Enveler de cette liste, les type d'evaluation qui sont pas configurée sur la formation.
"""
Class_UE_type_eval = MYSY_GV.dbname['class_unite_enseignement_type_evaluation'].distinct(
"type_evaluation_id",
{'class_ue_id': str(my_ue_id),
'valide': '1',
'locked': '0',
'class_id': str(
diction['class_id']),
'partner_owner_recid': str(
my_partner['recid'])
}
)
print(" ### la liste Class_UE_type_eval = ", Class_UE_type_eval)
print(" ### QRYYY = ", {'class_eu_id': str(my_ue_id),
'valide': '1',
'locked': '0',
'session_id':str(diction['session_id']),
'partner_owner_recid': str(my_partner['recid']),
'type_eval_id':{'$in':Class_UE_type_eval}
})
evaluation_distinc_type_eval = MYSY_GV.dbname['note_evaluation'].distinct("type_eval_id",
{'class_eu_id': str(my_ue_id),
'valide': '1',
'locked': '0',
'partner_owner_recid': str(my_partner['recid'])
'session_id':str(diction['session_id']),
'partner_owner_recid': str(my_partner['recid']),
'type_eval_id':{'$in':Class_UE_type_eval}
}
)
#print(" ### la liste evaluation_distinc_type_eval = ", evaluation_distinc_type_eval)
print(" ### la liste evaluation_distinc_type_eval = ", evaluation_distinc_type_eval)
@ -2488,7 +2553,7 @@ def run_ue_pre_calcul_moyenne_somme_v2(diction):
############
"""
Traitement des Types d'evaluation
Traitement des Types d'évaluation
"""
for eval_type_id in evaluation_distinc_type_eval :
@ -2529,6 +2594,11 @@ def run_ue_pre_calcul_moyenne_somme_v2(diction):
new_node['nb_evaluation'] = str(local_retval_nb_eval_TD)
# Recuperer la ponderation associé à ce type d'evaluation
print(" ## QRY class_unite_enseignement_type_evaluation_data = ", {'class_id':str(diction['class_id']),
'type_evaluation_id': str(eval_type_id_data["_id"]),
'class_ue_id': str(my_ue_id),
})
class_unite_enseignement_type_evaluation_data = MYSY_GV.dbname['class_unite_enseignement_type_evaluation'].find_one({'class_id':str(diction['class_id']),
'type_evaluation_id': str(eval_type_id_data["_id"]),
'class_ue_id': str(my_ue_id),
@ -2671,16 +2741,29 @@ def Cacul_Session_Note_Finale_For_calcul_Stanard(diction):
'partner_owner_recid': str(my_partner['recid'])})
"""
Recuperer la liste des UE de la formation, avec leur credit et coeff.*
Recuperer la liste des UE qui sont sur la session / promotion, avec leur credit et coeff.*
"""
tab_class_ue = []
if( "list_unite_enseignement" in is_myclass_valide_data.keys() ):
tab_class_ue = is_myclass_valide_data['list_unite_enseignement']
if( "list_unite_enseignement" in is_session_valide_data.keys() ):
for tmp_tab_session_ue in is_session_valide_data['list_unite_enseignement']:
print(" ## tmp_tab_session_ue = ", tmp_tab_session_ue)
if (tmp_tab_session_ue and '_id' in tmp_tab_session_ue.keys()):
local_class_eu = MYSY_GV.dbname['myclass'].find_one(
{'_id': ObjectId(str(diction['class_id'])),
'valide': '1',
'locked': '0',
'partner_owner_recid': str(my_partner['recid']),
'list_unite_enseignement._id': str(tmp_tab_session_ue['_id'])},
{'list_unite_enseignement.$': 1})
tab_class_ue.append(local_class_eu['list_unite_enseignement'][0])
if(len(tab_class_ue) <= 0 ):
mycommon.myprint(
str(inspect.stack()[0][3]) + " Aucune unité d'enseignement pour cette formation ")
return False, " Aucune unité d'enseignement pour cette formation "
str(inspect.stack()[0][3]) + " Aucune unité d'enseignement pour cette promotion / session formation ")
return False, " Aucune unité d'enseignement pour cette promotion / session formation "
# Verifier la validité de la liste des inscrits fournie
@ -2767,7 +2850,6 @@ def Cacul_Session_Note_Finale_For_calcul_Stanard(diction):
upsert=False,
)
"""
Apres avoir saisi la note finale sur l'inscription, on va mettre à jour le rang
"""
@ -2778,16 +2860,17 @@ def Cacul_Session_Note_Finale_For_calcul_Stanard(diction):
'session_id':str(is_session_valide_data['_id']),
'valide': '1',
'locked': '0' }).sort(
[("note_finale", pymongo.DESCENDING), ]):
[("note_finale", pymongo.DESCENDING), ]).collation({'locale': "fr", 'numericOrdering': True}):
if( sorted_data and "note_finale" in sorted_data.keys() ):
# Gestion des Execo
if (str(note_precedente) != str(sorted_data['note_finale'])):
classement = classement + 1
note_precedente = str(sorted_data['note_finale'])
# MAJ du rang
#print(" MAJJ classement = ", classement)
MYSY_GV.dbname['inscription'].find_one_and_update(
{'_id': ObjectId(str(sorted_data['_id'])),
'partner_owner_recid': str(sorted_data['partner_owner_recid']),
@ -2795,7 +2878,7 @@ def Cacul_Session_Note_Finale_For_calcul_Stanard(diction):
'locked': '0'
},
{"$set": {'rang': str(classement), 'rang_calculation_date':str(datetime.now())}},
{"$set": {'rang': str("classement"), 'rang_calculation_date':str(datetime.now())}},
return_document=ReturnDocument.AFTER,
upsert=False,
)
@ -3103,7 +3186,28 @@ def Create_Bulletin_By_Inscrit_PDF(diction):
"""
Creation du ficier PDF
"""
contenu_doc_Template = jinja2.Template(str(template_courrier_data['contenu_doc']))
header_html = """<html>
<head>
<style>
@page {
size: a4 portrait;
@frame content_frame { /* Content Frame */
left: 50pt; width: 512pt; top: 25pt; height: 700pt;
}
@frame footer_frame { /* Another static Frame */
-pdf-frame-content: footer_content;
left: 50pt; width: 512pt; top: 772pt; height: 20pt;
}
}
</style>
</head>
<body>
"""
content_with_header = str(header_html)+str(template_courrier_data['contenu_doc'])+str("</body> </html>")
#print(" ### content_with_header = ", content_with_header)
contenu_doc_Template = jinja2.Template(str(content_with_header))
sourceHtml = contenu_doc_Template.render(params=body["params"])
@ -3125,36 +3229,15 @@ def Create_Bulletin_By_Inscrit_PDF(diction):
# close output file
resultFile.close()
"""
# Create a PdfDocument object
doc = PdfDocument()
# Load a PDF file
doc.LoadFromFile(outputFilename)
# Create font and brush
font = PdfTrueTypeFont("DM Sans", 24.0, PdfFontStyle.Bold, True)
brush = PdfBrushes.get_DarkBlue()
# Specify text to add to header
headerText = "ABC INC."
# Iterate through the pages in the document
for i in range(doc.Pages.Count):
# Get a specific page
page = doc.Pages[i]
# Draw a string at the specified position
page.Canvas.DrawString(headerText, font, brush, 54.0, 25.0)
print(" iiii ")
# Save the changes to a different PDF file
doc.SaveToFile(str(MYSY_GV.TEMPORARY_DIRECTORY) + "/iiiiiii.pdf")
# Dispose resources
doc.Dispose()
"""
####
pied_page = ""
if( "company_data" in convention_dictionnary_data.keys()):
if("societe_nom" in convention_dictionnary_data['company_data'].keys() ):
pied_page = convention_dictionnary_data['company_data']['societe_nom']+ ", Num NDA "+convention_dictionnary_data['company_data']['societe_num_nda']
pied_page = pied_page + ", Siret : " + convention_dictionnary_data['company_data']['societe_siret']
pied_page = pied_page + ", Adresse "+ convention_dictionnary_data['company_data']['societe_adr_street'] + " "+convention_dictionnary_data['company_data']['societe_adr_zip']
pied_page = pied_page + " " + convention_dictionnary_data['company_data']['societe_adr_city']
pied_page = pied_page + " Tel : " + convention_dictionnary_data['company_data']['societe_telephone']
pied_page = pied_page + " Email : " + convention_dictionnary_data['company_data']['societe_email']
input_file = outputFilename
@ -3171,21 +3254,20 @@ def Create_Bulletin_By_Inscrit_PDF(diction):
canvas.doForm(makerl(canvas, page))
# Dessiner le pied de page
pied_page_html = """
Votre société bla bla bla bla
Page %s sur %s </p>
"""% (page_num, len(pages))
print(" ## pied_page_html = ", pied_page_html)
pied_page_html = pied_page
pied_page_num_page_html = """%s/%s """ % (page_num, len(pages))
footer_text = "Page %s sur %s" % (page_num, len(pages))
x = 128
x = 500
canvas.saveState()
canvas.setStrokeColorRGB(0, 0, 0)
canvas.setLineWidth(0.5)
canvas.line(66, 78, page.BBox[2] - 66, 78)
canvas.setFont('Times-Roman', 10)
canvas.drawString(page.BBox[2] - x, 65, pied_page_html)
canvas.line(0, 50, 700, 50)
canvas.setFont('Times-Roman', 8)
canvas.drawString(50, 35, pied_page_html)
canvas.drawString(550, 20, pied_page_num_page_html)
canvas.restoreState()
canvas.showPage()
@ -3260,10 +3342,10 @@ def Create_Bar_Chart_And_Save_Ok(diction):
padding=4)"""
labels = ax.bar_label(ax.containers[0], color='black', fontsize=10)
print(ax.legend())
for label in labels:
label.set_ha('right')
print(" ### label.get_text() = ", label.get_text())
if label.get_text() == '40':
label.set_color('b')
label.set_text("Eleve")

View File

@ -2706,9 +2706,9 @@ def ManualSendInvoiceEmailRIB_CIC_BureauVallee(diction):
"params": {"order_id": "N/A",
"date_order": ": 12/08/2025",
"periode":"01/10/2025 au 31/10/2025",
"total_ht": "12 650",
"tva": "2 530",
"total_ttc": "15 279",
"total_ht": "12 749",
"tva": "2 549,8",
"total_ttc": "15 298,8",
"client_name": "BVD Fr (Bureau Vallée)",
"client_address": "25 rue du Gros Caillou",
"client_zip_ville": "78340 Les Clayes-sous-Bois",

View File

@ -1073,6 +1073,7 @@ def Get_Ent_Student_Participant_Notes(diction):
nb_val = 0
query = [{'$match': {'inscription_id': {'$in':tab_my_inscription_ids}, 'partner_owner_recid': str(apprenant_data['partner_owner_recid']),
'publish':'1'
}},
{'$sort': {'_id': -1}},
{'$lookup':

View File

@ -5047,13 +5047,13 @@ def Send_Jury_Apprenant_Soutenance_Convocation_By_Email(tab_files, Folder, dicti
return True, " Les convocations au jury ont été correctement envoyées par emails"
return True, " Les convocations au jury ont été correctement envoyées par email"
except Exception as e:
exc_type, exc_obj, exc_tb = sys.exc_info()
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - Line : " + str(exc_tb.tb_lineno))
return False, " Impossible d'envoyer les convocations au jury par emails"
return False, " Impossible d'envoyer les convocations au jury par email"

26
main.py
View File

@ -3165,10 +3165,6 @@ def ManualSendInvoiceEmailRIB_CIC_BureauVallee():
"""
API de recuperation au formation CSV de la liste des inscrits à une formation
avec les statuts (validé ou pas)
@ -7404,7 +7400,7 @@ avec plusieurs filtres
def Get_List_object_owner_collection_Stored_Files_With_Filter():
# On recupere le corps (payload) de la requete
payload = mycommon.strip_dictionary (request.form.to_dict())
print(" ### Get_List_object_owner_collection_Stored_Files_With_Filter : payload = ",)
print(" ### Get_List_object_owner_collection_Stored_Files_With_Filter : payload = ",payload)
status, retval = attached_file_mgt.Get_List_object_owner_collection_Stored_Files_With_Filter(payload)
return jsonify(status=status, message=retval)
@ -11276,6 +11272,23 @@ def Update_Participant_Evaluation_Note():
return jsonify(status=status, message=retval)
"""
API pour publier ou dépublieres note evaluation
à une évaluation
"""
@app.route('/myclass/api/Publish_Unpublish_Participant_Evaluation_Note/', methods=['POST','GET'])
@crossdomain(origin='*')
def Publish_Unpublish_Participant_Evaluation_Note():
# On recupere le corps (payload) de la requete
payload = mycommon.strip_dictionary (request.form.to_dict())
print(" ### Publish_Unpublish_Participant_Evaluation_Note payload = ",payload)
status, retval = note_evaluation_mgt.Publish_Unpublish_Participant_Evaluation_Note(payload)
return jsonify(status=status, message=retval)
"""
API pour Recuperer la liste des inscrits et groupe inscrit à une
evaluation
@ -14702,6 +14715,7 @@ if __name__ == '__main__':
mycommon.myprint("++ FLASK PORT " + str(MYSY_GV.MYSY_PORT_REC) + " ++")
mycommon.myprint("++ LMS_BAS_URL " + str(MYSY_GV.LMS_BAS_URL) + " ++")
"""
scheduler = BackgroundScheduler()
scheduler.start()
@ -14715,7 +14729,7 @@ if __name__ == '__main__':
# WARNING IMPORTANT WARNING : Shut down the scheduler when exiting the app
atexit.register(lambda: scheduler.shutdown())
"""
app.run(host='localhost', port=MYSY_GV.MYSY_PORT_REC, debug=True, threaded=True)

View File

@ -198,9 +198,8 @@ def Add_Evaluation_Planification(diction):
local_mode_animation = diction['mode_animation']
new_data = diction
mytoken = diction['token']
del diction['token']
if( "mode_animation" in diction.keys() ):
@ -226,6 +225,25 @@ def Add_Evaluation_Planification(diction):
" Impossible de créer l'évaluation (2) ")
return False, " Impossible de créer l'évaluation (2) "
"""
# Ajout de l'evenement dans l'historique
"""
now = str(datetime.now().strftime("%d/%m/%Y %H:%M:%S"))
# print(" ####### laaaa diction = ", diction)
history_event_dict = {}
history_event_dict['token'] = mytoken
history_event_dict['related_collection'] = "note_evaluation"
history_event_dict['related_collection_recid'] = str(inserted_id)
history_event_dict['action_date'] = str(now)
history_event_dict['action_description'] = "Planification de l'évaluation "
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'évènement : " + str(history_event_dict))
return True, " L'évaluation a été correctement ajoutée"
@ -398,6 +416,9 @@ def Update_Evaluation_Planification(diction):
local_evaluation_id = diction['evaluation_id']
new_data = diction
mytoken = diction['token']
myevaluation_id = diction['evaluation_id']
del diction['token']
del diction['evaluation_id']
@ -428,7 +449,23 @@ def Update_Evaluation_Planification(diction):
" Impossible de mettre à jour l'évaluation (2) ")
return False, " Impossible de mettre à jour l'évaluation (2) "
"""
# Ajout de l'evenement dans l'historique
"""
now = str(datetime.now().strftime("%d/%m/%Y %H:%M:%S"))
# print(" ####### laaaa diction = ", diction)
history_event_dict = {}
history_event_dict['token'] = mytoken
history_event_dict['related_collection'] = "note_evaluation"
history_event_dict['related_collection_recid'] = str(myevaluation_id)
history_event_dict['action_date'] = str(now)
history_event_dict['action_description'] = "Mise à jour "
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'évènement : " + str(history_event_dict))
return True, " L'évaluation a été correctement mise à jour"
@ -565,7 +602,7 @@ def Duplicate_Evaluation_Planification(diction):
new_data = evaluation_id_data
del new_data['_id']
new_data['code'] = "Dup_"+str(evaluation_id_data['code'])
new_data['code'] = str(evaluation_id_data['code'])+"_dup"
new_data['valide'] = "1"
new_data['locked'] = "0"
@ -574,18 +611,30 @@ def Duplicate_Evaluation_Planification(diction):
new_data['creation_by'] = str(my_partner['_id'])
new_data['partner_owner_recid'] = str(my_partner['recid'])
result = MYSY_GV.dbname['note_evaluation'].insert_one(new_data).inserted_id
if (result is None ):
mycommon.myprint(
" Impossible de dupliquer l'évaluation (2) ")
return False, " Impossible de mettre à jour l'évaluation (2) "
"""
# Ajout de l'evenement dans l'historique
"""
now = str(datetime.now().strftime("%d/%m/%Y %H:%M:%S"))
# print(" ####### laaaa diction = ", diction)
history_event_dict = {}
history_event_dict['token'] = token
history_event_dict['related_collection'] = "note_evaluation"
history_event_dict['related_collection_recid'] = str(result)
history_event_dict['action_date'] = str(now)
history_event_dict['action_description'] = "Planification par duplication de "+str(evaluation_id_data['code'])
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'évènement : " + str(history_event_dict))
return True, " L'évaluation a été correctement dupliquée"
@ -990,6 +1039,21 @@ def Delete_Evaluation_Planification(diction):
str(inspect.stack()[0][3]) + " Il y a "+str(note_evaluation_participant_count)+" inscription(s) pour cette evaluation. Suppression annulée ")
return False, " Il y a "+str(note_evaluation_participant_count)+" inscription(s) pour cette evaluation. Suppression annulée "
eval_data = MYSY_GV.dbname['note_evaluation'].find_one({'_id': ObjectId(str(diction['evaluation_id'])),
'partner_owner_recid': my_partner['recid'],
'valide': '1',
'locked': '0'
}, {'_id':1, 'code':1, 'titre':1})
deleted_id = ""
deleted_code = ""
deleted_titre = ""
if( eval_data and 'code' in eval_data.keys()):
deleted_id = str(eval_data['_id'])
deleted_code = str(eval_data['code'])
if (eval_data and 'titre' in eval_data.keys()):
deleted_titre = str(eval_data['titre'])
delete = MYSY_GV.dbname['note_evaluation'].delete_one({ '_id':ObjectId(str(diction['evaluation_id'])),
'partner_owner_recid':my_partner['recid'],
@ -997,7 +1061,23 @@ def Delete_Evaluation_Planification(diction):
'locked': '0'
} )
"""
# Ajout de l'evenement dans l'historique
"""
now = str(datetime.now().strftime("%d/%m/%Y %H:%M:%S"))
# print(" ####### laaaa diction = ", diction)
history_event_dict = {}
history_event_dict['token'] = token
history_event_dict['related_collection'] = "note_evaluation"
history_event_dict['related_collection_recid'] = str(deleted_id)
history_event_dict['action_date'] = str(now)
history_event_dict['action_description'] = "Suppresion de l'évaluation " + str(deleted_id)+ " code:"+str(deleted_code)+" titre:"+str(deleted_titre)
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'évènement : " + str(history_event_dict))
return True, " La évaluation a été correctement supprimée"
@ -1921,8 +2001,8 @@ Mise à jour note evaluation
Cette fonction met à jour la note d'un inscrit ou groupe d'inscrit.
{note_evaluation_participant_id:'kjdskjkdj',
tab_participant_note [
{note_evaluation_participant_id:'4444', note:'33'},
{note_evaluation_participant_id:'4444', note:'33'}
{note_evaluation_participant_id:'4444', note:'10', publish:'0'},
{note_evaluation_participant_id:'4444', note:'17', publish:'1'}
]
}
"""
@ -1992,6 +2072,12 @@ def Update_Participant_Evaluation_Note(diction):
else:
new_data['note'] = "-1"
if ("publish" in val.keys()):
new_data['publish'] = str(val['publish'])
else:
new_data['publish'] = "0"
new_data['valide'] = "1"
new_data['locked'] = "0"
new_data['date_update'] = str(datetime.now())
@ -2015,6 +2101,123 @@ def Update_Participant_Evaluation_Note(diction):
return False, "Impossible de mettre à jour les notes "
"""
Cette fonction permet de publier et dépublier des notes
"""
def Publish_Unpublish_Participant_Evaluation_Note(diction):
try:
diction = mycommon.strip_dictionary(diction)
"""
Verification des input acceptés
"""
field_list = ['token', 'evaluation_id', 'tab_inscription_id', 'publish_status']
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', 'evaluation_id', 'tab_inscription_id', 'publish_status']
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']
if( diction['publish_status'] not in ['0', '1']):
mycommon.myprint(
str(inspect.stack()[0][
3]) + "Le statut de publication est invalide ")
return False, "Le statut de publication est invalide"
local_status, my_partner = mycommon.Check_Connexion_And_Return_Partner_Data(diction)
if (local_status is not True):
return local_status, my_partner
"""
Verifier que l'evaluation est valide
"""
is_evaluation_valide = MYSY_GV.dbname['note_evaluation'].count_documents(
{"_id": ObjectId(str(diction['evaluation_id'])),
'valide': '1',
'locked': '0',
'partner_owner_recid': str(my_partner['recid'])})
if (is_evaluation_valide != 1):
mycommon.myprint(
str(inspect.stack()[0][3]) + " L'identifiant de l'évaluation n'est pas valide ")
return False, " L'identifiant de l'évaluation n'est pas valide "
tab_id_to_update = []
tab_inscription_id = str(diction['tab_inscription_id']).split(",")
for inscription_id in tab_inscription_id:
if( inscription_id ):
# Verifier que le stagiaire est bien inscrit. Le statut de l'inscription doit etre "1"
is_inscription_valide = MYSY_GV.dbname['note_evaluation_participant'].count_documents(
{'_id': ObjectId(str(inscription_id)),
'partner_owner_recid': str(my_partner['recid'])})
if (is_inscription_valide != 1):
mycommon.myprint(
str(inspect.stack()[0][
3]) + " L'identifiant de l'inscription " + str(inscription_id) + " est invalide ")
return False, " L'identifiant de l'inscription " + str(inscription_id) + " est invalide "
tab_id_to_update.append(ObjectId(str(inscription_id)))
warning_msg = ""
is_warning = ""
new_data = {}
new_data['date_update'] = str(datetime.now())
new_data['update_by'] = str(my_partner['_id'])
new_data['publish'] = str(diction['publish_status'])
# Suppression des inscription
if( len(tab_id_to_update) > 0 and tab_id_to_update[0]):
qry_update_inscription = {'partner_owner_recid': str(my_partner['recid']),
"_id": {"$in": tab_id_to_update},
}
print(" ### qry_update_inscription = ", qry_update_inscription )
MYSY_GV.dbname['note_evaluation_participant'].update_many(
qry_update_inscription,
{'$set': new_data}
)
return True, " La mise à jour correctement faite"
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 les données"
"""
Recuperer la liste des inscrits et groupe inscrit à une
evaluation
@ -2109,6 +2312,15 @@ def Get_List_Participant_To_Evaluation(diction):
if( "note" not in retval.keys() ):
user['note'] = "-1"
if ("publish" not in retval.keys()):
user['publish'] = False
if ("publish" in retval.keys() and retval['publish'] == "1"):
user['publish'] = True
elif ("publish" in retval.keys() and retval['publish'] != "1"):
user['publish'] = False
if( "convocation_send_date" not in user.keys() ):
user['convocation_send_date'] = ""
@ -2273,6 +2485,14 @@ def Get_List_Participant_Notes(diction):
user['inscription_id'] = str(retval['inscription_id'])
user['note'] = str(retval['note'])
if ("publish" not in retval.keys()):
user['publish'] = False
if ("publish" in retval.keys() and retval['publish'] == "1"):
user['publish'] = True
elif ("publish" in retval.keys() and retval['publish'] != "1"):
user['publish'] = False
user['note_evaluation_id'] = str(retval['note_evaluation_collection'][0]['_id'])
user['note_evaluation_code'] = str(retval['note_evaluation_collection'][0]['code'])
@ -2452,7 +2672,7 @@ def Export_Excel_List_Participant_Notes(diction):
outputFilename = str(MYSY_GV.TEMPORARY_DIRECTORY) + "/" + str(orig_file_name)
tab_exported_fields_header = ["Formation", "Classe", "Nom", "Prenom", "Email", "UE Code", "UE Titre",
"Evaluation", "Début Evaluation", "Fin Evaluation", "Note"
"Evaluation", "Début Evaluation", "Fin Evaluation", "Note", "Publié"
]
# Create a workbook and add a worksheet.
@ -2495,6 +2715,8 @@ def Export_Excel_List_Participant_Notes(diction):
user['inscription_id'] = str(retval['inscription_id'])
user['note'] = str(retval['note'])
user['note_evaluation_id'] = str(retval['note_evaluation_collection'][0]['_id'])
user['note_evaluation_code'] = str(retval['note_evaluation_collection'][0]['code'])
@ -2538,6 +2760,9 @@ def Export_Excel_List_Participant_Notes(diction):
if( "note" not in retval.keys() ):
user['note'] = "-1"
if ("publish" not in retval.keys()):
user['publish'] = "0"
user['class_id'] = str(retval['note_evaluation_collection'][0]['class_id'])
myclass_data = MYSY_GV.dbname['myclass'].find_one({'_id':ObjectId(str(user['class_id'])),
'valide':'1',
@ -2607,6 +2832,10 @@ def Export_Excel_List_Participant_Notes(diction):
worksheet.write(row, column, user['note'])
column += 1
# Champ : user['publish']
worksheet.write(row, column, user['publish'])
column += 1
nb_val = nb_val + 1

View File

@ -8044,9 +8044,6 @@ def Get_total_Ponderation_Class_UE_Type_Eval( class_id, ue_id):
somme_ponderation = 0
print(" ### QRY Get_total_Ponderation_Class_UE_Type_Eval = ", {'class_id':class_id,
'class_ue_id':ue_id,
})
for tmp in MYSY_GV.dbname['class_unite_enseignement_type_evaluation'].find({'class_id':class_id,
'class_ue_id':ue_id,