02/05/2025 - 20h

Signed-off-by: cherif <cherif.balde@yahoo.fr>
master
cherif 2025-05-02 20:47:04 +02:00
parent 198b6c8fd6
commit c871574e6a
7 changed files with 4865 additions and 63 deletions

View File

@ -1,12 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="25/04/2025 - 15h">
<change afterPath="$PROJECT_DIR$/equipe_team_mgt.py" afterDir="false" />
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="30/04/2025 - 15h">
<change afterPath="$PROJECT_DIR$/base_class_calcul_note.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Collection_Historique.py" beforeDir="false" afterPath="$PROJECT_DIR$/Collection_Historique.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/GlobalVariable.py" beforeDir="false" afterPath="$PROJECT_DIR$/GlobalVariable.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$/domaine_formation_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/domaine_formation_mgt.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/equipe_team_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/equipe_team_mgt.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
@ -84,13 +85,6 @@
<option name="presentableId" value="Default" />
<updated>1680804787304</updated>
</task>
<task id="LOCAL-00400" summary="25/09/2024 - 15h">
<created>1727271830872</created>
<option name="number" value="00400" />
<option name="presentableId" value="LOCAL-00400" />
<option name="project" value="LOCAL" />
<updated>1727271830872</updated>
</task>
<task id="LOCAL-00401" summary="sdfsd">
<created>1727693258457</created>
<option name="number" value="00401" />
@ -427,7 +421,14 @@
<option name="project" value="LOCAL" />
<updated>1745587733831</updated>
</task>
<option name="localTasksCounter" value="449" />
<task id="LOCAL-00449" summary="30/04/2025 - 15h">
<created>1746039183867</created>
<option name="number" value="00449" />
<option name="presentableId" value="LOCAL-00449" />
<option name="project" value="LOCAL" />
<updated>1746039183867</updated>
</task>
<option name="localTasksCounter" value="450" />
<servers />
</component>
<component name="Vcs.Log.Tabs.Properties">
@ -469,7 +470,6 @@
</option>
</component>
<component name="VcsManagerConfiguration">
<MESSAGE value="sdf" />
<MESSAGE value="sdfd" />
<MESSAGE value="sdfdd" />
<MESSAGE value="31/12/2024 - 12h30" />
@ -494,6 +494,7 @@
<MESSAGE value="29/03/2025 - 9h" />
<MESSAGE value="29/03/2025 - 21h" />
<MESSAGE value="25/04/2025 - 15h" />
<option name="LAST_COMMIT_MESSAGE" value="25/04/2025 - 15h" />
<MESSAGE value="30/04/2025 - 15h" />
<option name="LAST_COMMIT_MESSAGE" value="30/04/2025 - 15h" />
</component>
</project>

View File

@ -148,16 +148,20 @@ def Add_Historique_Event(diction):
if('action_description' in diction.keys() and diction['action_description']):
action_description = diction['action_description']
if(len(str(action_description)) > 255 ):
mycommon.myprint(
str(inspect.stack()[0][3]) + " - La description de l'historique d'évènement fait plus de 255 caractères ")
return False, " La description de l'historique d'évènement fait plus de 255 caractères "
if(len(str(action_description)) > MYSY_GV.HISTORIQUE_DESCRIPTION_LEN ):
action_description = str(diction['action_description'])[0:MYSY_GV.HISTORIQUE_DESCRIPTION_LEN]
mydata = diction
if 'token' in mydata:
del mydata['token']
if 'action_description' in mydata:
del mydata['action_description']
mydata['action_description'] = action_description
mydata['partner_owner_recid'] = my_partner['recid']
mydata['connected_user_id'] = str(my_partner['_id'])
mydata['valide'] = "1"

View File

@ -323,18 +323,20 @@ if (MYSY_ENV == "DEV"):
"""
# Tester le relay smtp perso (maison - DIRTY MAIL)
"""O365_SMTP_COUNT_password = 'cherif'
O365_SMTP_COUNT_password = 'cherif'
O365_SMTP_COUNT_smtpsrv = "srvdmz.iexercice.com"
O365_SMTP_COUNT_user = "clientmail-vm2"
O365_SMTP_COUNT_From_User = "clientmail-vm2@iexercice.com"
O365_SMTP_COUNT_port = 587"""
O365_SMTP_COUNT_port = 587
"""
# Tester le relay smtp perso (maison - mysy-training.fr)
O365_SMTP_COUNT_password = 'cherif'
O365_SMTP_COUNT_smtpsrv = "srvdmz.mysy-training.fr"
O365_SMTP_COUNT_user = "cbalde"
O365_SMTP_COUNT_From_User = "cbalde@mysy-training.fr"
O365_SMTP_COUNT_port = 587
"""
@ -912,4 +914,10 @@ Gestion du context de connexion d'un partenaire
"""
PARTNER_ACCOUNT_CONNEXION_CONTEXT_VALUES = ['mysy_session_display_view',
'mysy_menu_gauche_reduit',
'mysy_catalog_data_row_grouped_by']
'mysy_catalog_data_row_grouped_by']
"""
Longueur maximale d'un commentaire dans l'historique
"""
HISTORIQUE_DESCRIPTION_LEN = 500

File diff suppressed because one or more lines are too long

364
base_class_calcul_note.py Normal file
View File

@ -0,0 +1,364 @@
"""
FORMATION INITIALE :
A limage de la gestion des admissions, le système sera paramétrable par un utilisateur pour définir les règles de calcul.
En attendant de mettre en le module de règle dynamique, une liste de règles statiques seront codées en dure le dans le système.
Ainsi ladministrateur pourra choisir la règle adaptée à sa formation.
Pour les cas particuliers, les équipes de MTT feront des développements spécifiques pour les clients qui le souhaite.
Par defaut, les regles de calcul implémentées :
Nom : calcul_mode_1
Detail : ( (Moyenne Art. (TD) + Moyenne Art(TP) * 2)/3 + Examen Final ) / 2
Nom : calcul_mode_2
Detail : ( Note Stage + Examen Final ) / 2
Nom : calcul_mode_2
Detail : (Moyenne Art.(TD) + Moyenne Art.(Contrôle Continue) + Examen Final*1.5 ) / 3
/!\ Important :
La collection : "note_evaluation" :
- Elle contient toutes les evaluations (pas les note mais les evaluation).
- Elle contient les informations : class_id, class_eu_id, type_eval_id, session_id, eval_date_heure_debut, eval_date_heure_fin
La collection : "note_evaluation_participant" :
- Elle contient les notes attribuées à un apprenant sur une evaluation.
- Elle contient les informations :evaluation_id, inscription_id, group_inscription_id, note (la note obtenue par l'apprenant)
"""
import bson
import pymongo
from pymongo import MongoClient
import json
from bson import ObjectId
import re
from datetime import datetime
import prj_common as mycommon
import secrets
import inspect
import sys, os
import csv
import pandas as pd
from pymongo import ReturnDocument
import GlobalVariable as MYSY_GV
from math import isnan
import GlobalVariable as MYSY_GV
import ela_index_bdd_classes as eibdd
import email_mgt as email
import jinja2
from flask import send_file
from xhtml2pdf import pisa
from email.message import EmailMessage
from email.mime.text import MIMEText
from email import encoders
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.mime.base import MIMEBase
from email import encoders
"""
Cette fonction permet d'appliquer la regle de calcul :
Nom : calcul_mode_1
Detail : ( (Moyenne Art. (TD) + Moyenne Art(TP) * 2)/3 + Examen Final ) / 2
Les données en entrée :
- La formation,
- La session
- Liste des inscrit
"""
def run_calcul_mode_1(diction):
try:
diction = mycommon.strip_dictionary(diction)
"""
Verification des input acceptés
"""
field_list = ['token', 'class_id', 'session_id', 'eu_id', 'tab_inscriptions_ids' ]
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', 'class_id', 'session_id', 'eu_id', 'tab_inscriptions_ids' ]
for val in field_list_obligatoire:
if val not in diction:
mycommon.myprint(
str(inspect.stack()[0][3]) + " - La valeur '" + val + "' n'est pas presente dans liste ")
return False, " Les informations fournies sont incorrectes"
"""
Verification de l'identité et autorisation de l'entité qui
appelle cette API
"""
token = ""
if ("token" in diction.keys()):
if diction['token']:
token = diction['token']
local_status, my_partner = mycommon.Check_Connexion_And_Return_Partner_Data(diction)
if (local_status is not True):
return local_status, my_partner
# Verifier la validité de la session
is_session_valide_count = MYSY_GV.dbname['session_formation'].count_documents({'_id':ObjectId(str(diction['session_id'])),
'valide':'1',
'partner_owner_recid':str(my_partner['recid'])})
if( is_session_valide_count != 1 ):
mycommon.myprint(
str(inspect.stack()[0][3]) + " L'identifiant de la session est invalide ")
return False, " L'identifiant de la session est invalide"
is_session_valide_data = MYSY_GV.dbname['session_formation'].find_one(
{'_id': ObjectId(str(diction['session_id'])),
'valide': '1',
'partner_owner_recid': str(my_partner['recid'])})
# Verifier la validité de l'unité d'enseignement
is_ue_valide_count = MYSY_GV.dbname['unite_enseignement'].count_documents(
{'_id': ObjectId(str(diction['eu_id'])),
'valide': '1',
'locked':'0',
'partner_owner_recid': str(my_partner['recid'])})
if (is_ue_valide_count != 1):
mycommon.myprint(
str(inspect.stack()[0][3]) + " L'identifiant de l'unité d'enseignement est invalide ")
return False, " L'identifiant de l'unité d'enseignement est invalide"
is_ue_valide_data = MYSY_GV.dbname['unite_enseignement'].find_one(
{'_id': ObjectId(str(diction['eu_id'])),
'valide': '1',
'locked': '0',
'partner_owner_recid': str(my_partner['recid'])})
# Verifier si la formartion est valide
is_myclass_valide_count = MYSY_GV.dbname['myclass'].count_documents(
{'_id': ObjectId(str(diction['class_id'])),
'valide': '1',
'locked': '0',
'partner_owner_recid': str(my_partner['recid'])})
if (is_myclass_valide_count != 1):
mycommon.myprint(
str(inspect.stack()[0][3]) + " L'identifiant de la formation est invalide ")
return False, " L'identifiant de la formation est invalide"
is_myclass_valide_data = MYSY_GV.dbname['myclass'].find_one(
{'_id': ObjectId(str(diction['class_id'])),
'valide': '1',
'locked': '0',
'partner_owner_recid': str(my_partner['recid'])})
# Verifier la validité de la liste des inscrits fournie
tab_inscriptions_ids = ""
if ("tab_inscriptions_ids" in diction.keys()):
if diction['tab_inscriptions_ids']:
tab_inscriptions_ids = diction['tab_inscriptions_ids']
tab_inscriptions_ids_splited = str(tab_inscriptions_ids).split(",")
# Controle de validité de toutes info avant de commencer les traitements
for my_inscription in tab_inscriptions_ids_splited:
my_inscription = str(my_inscription).strip()
# Verifier que l'inscription est valide
my_inscription_is_valide = MYSY_GV.dbname['inscription'].count_documents(
{'_id': ObjectId(str(my_inscription)), 'status': '1',
'partner_owner_recid': str(my_partner['recid'])})
if (my_inscription_is_valide != 1):
mycommon.myprint(
str(inspect.stack()[0][3]) + " L'inscription_id '" + my_inscription + "' n'est pas valide ")
return False, " L'inscription_id '" + my_inscription + "' n'est pas valide "
"""
La formule : ( (Moyenne Art. (TD) + Moyenne Art(TP) * 2)/3 + Examen Final ) / 2
"""
"""
Etape 1 :
Aller cherche la liste des TD et faire la moyenne arithmétique pour chaque apprenant fourni en entrée
0) Recuperer les types d'evaluation associée à une formation / UE
a) Pour chaque apprenant aller chercher les evaluations concernées,
b) Pour chaque evaluation concerné aller cherche les note
"""
"""
TRAITEMENT DES TD
"""
evaluation_type_TD_id = ""
for val in MYSY_GV.dbname['type_evaluation'].find({'partner_owner_recid':str(my_partner['recid']),
'valide':'1',
'locked':'0',
'code': {'$regex': "TD", "$options": "i"}}):
evaluation_type_TD_id = str(val['_id'])
liste_note_evaluation_TD_ids = []
print(" ~#### QTRYYY = ", {'partner_owner_recid':str(my_partner['recid']),
'valide':'1',
'locked':'0',
'class_id':str(diction['class_id']),
'class_eu_id': str(diction['eu_id']),
'type_eval_id':str(evaluation_type_TD_id)}
)
for val in MYSY_GV.dbname['note_evaluation'].find({'partner_owner_recid':str(my_partner['recid']),
'valide':'1',
'locked':'0',
'class_id':str(diction['class_id']),
'class_eu_id': str(diction['eu_id']),
'type_eval_id':str(evaluation_type_TD_id)}):
liste_note_evaluation_TD_ids.append(str(val['_id']))
print(" ### la liste des evaluations de type TD sont : ", liste_note_evaluation_TD_ids)
nb_eval_td = len(liste_note_evaluation_TD_ids)
for my_inscription in tab_inscriptions_ids_splited:
somme_note_td = 0
moyenne_note_td = 0
tab_apprenant_note_td = []
print("###############################################")
for note_evaluation_participant in MYSY_GV.dbname['note_evaluation_participant'].find(
{'partner_owner_recid':str(my_partner['recid']),
'valide':'1',
'locked':'0',
'inscription_id' : str(my_inscription),
'evaluation_id':{'$in':liste_note_evaluation_TD_ids}
}):
inscri_data = MYSY_GV.dbname['inscription'].find_one({'partner_owner_recid':str(my_partner['recid']),
'valide':'1',
'locked':'0',
'_id':ObjectId(str(my_inscription).strip())},
{'nom':1, 'prenom':1, 'email':1}
)
"""
A supprimer après, la c'est juste pour voir les data
"""
evaluation_data = MYSY_GV.dbname['note_evaluation'].find_one({'partner_owner_recid':str(my_partner['recid']),
'valide':'1',
'locked':'0',
'_id':ObjectId(str(note_evaluation_participant['evaluation_id']))})
somme_note_td = somme_note_td + mycommon.tryFloat(str(note_evaluation_participant['note']))
print("$$$$$$$$$$$$$$$$$$$$ ", evaluation_data['code'], " Du ", evaluation_data['eval_date_heure_debut'], " Au ", evaluation_data['eval_date_heure_fin'])
print(" Session : is_session_valide_data = ", is_session_valide_data['code_session'])
print(" Unit. Ensei : is_ue_valide_data = ", is_ue_valide_data['code'])
print(" Apprenant : my_inscription = ", my_inscription, " Nom = ",inscri_data['nom'], " Email = ", str(inscri_data['email']) )
print(" note_evaluation_participant = ", note_evaluation_participant['note'])
tab_apprenant_note_td.append(str(note_evaluation_participant['note']))
moyenne_note_td = somme_note_td / nb_eval_td
print("")
print(" ## Somme_note TD = ", str(somme_note_td), " ## Moyenne TP = ", str(moyenne_note_td))
print("")
print("")
"""
FIN TRAITEMENT DES TD
"""
print(" TPPPPPPPPPPPPPPPPPPPPPP")
"""
TRAITEMENT DES TP
"""
evaluation_type_TP_id = ""
for val in MYSY_GV.dbname['type_evaluation'].find({'partner_owner_recid': str(my_partner['recid']),
'valide': '1',
'locked': '0',
'code': {'$regex': "TP", "$options": "i"}}):
evaluation_type_TP_id = str(val['_id'])
liste_note_evaluation_TP_ids = []
for val in MYSY_GV.dbname['note_evaluation'].find({'partner_owner_recid': str(my_partner['recid']),
'valide': '1',
'locked': '0',
'class_id': str(diction['class_id']),
'class_eu_id': str(diction['eu_id']),
'type_eval_id': str(evaluation_type_TP_id)}):
liste_note_evaluation_TP_ids.append(str(val['_id']))
print(" ### la liste des evaluations de type TPP sont : ", liste_note_evaluation_TP_ids)
nb_eval_tp = len(liste_note_evaluation_TP_ids)
for my_inscription in tab_inscriptions_ids_splited:
somme_note_tp = 0
moyenne_note_tp = 0
tab_apprenant_note_tp = []
print("###############################################")
for note_evaluation_participant in MYSY_GV.dbname['note_evaluation_participant'].find(
{'partner_owner_recid': str(my_partner['recid']),
'valide': '1',
'locked': '0',
'inscription_id': str(my_inscription),
'evaluation_id': {'$in': liste_note_evaluation_TP_ids}
}):
print(" ### note_evaluation_participant TPPP= ", note_evaluation_participant)
inscri_data = MYSY_GV.dbname['inscription'].find_one({'partner_owner_recid': str(my_partner['recid']),
'valide': '1',
'locked': '0',
'_id': ObjectId(str(my_inscription).strip())},
{'nom': 1, 'prenom': 1, 'email': 1}
)
"""
A supprimer après, la c'est juste pour voir les data
"""
evaluation_data = MYSY_GV.dbname['note_evaluation'].find_one(
{'partner_owner_recid': str(my_partner['recid']),
'valide': '1',
'locked': '0',
'_id': ObjectId(str(note_evaluation_participant['evaluation_id']))})
somme_note_tp = somme_note_tp + mycommon.tryFloat(str(note_evaluation_participant['note']))
print("$$$$$$$$$$$$$$$$$$$$ ", evaluation_data['code'], " Du ",
evaluation_data['eval_date_heure_debut'], " Au ", evaluation_data['eval_date_heure_fin'])
print(" Session : is_session_valide_data = ", is_session_valide_data['code_session'])
print(" Unit. Ensei : is_ue_valide_data = ", is_ue_valide_data['code'])
print(" Apprenant : my_inscription = ", my_inscription, " Nom = ", inscri_data['nom'], " Email = ",
str(inscri_data['email']))
print(" note_evaluation_participant = ", note_evaluation_participant['note'])
tab_apprenant_note_tp.append(str(note_evaluation_participant['note']))
moyenne_note_tp = somme_note_tp / nb_eval_tp
print("")
print(" ## Somme_note TP = ", str(somme_note_tp), " ## Moyenne TP= ", str(moyenne_note_tp))
print("")
print("")
return True, " Les notes avec le -calcul_mode_1- ont été correctement calculées"
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 calculer les notes avec le -calcul_mode_1- "

View File

@ -104,7 +104,7 @@ def Add_Equipe_Team(diction):
'locked':'0',
'partner_recid':str(my_partner['recid'])})
if( is_chef_equipe_id_count <= 0 ):
if( is_chef_equipe_id_count != 0 ):
mycommon.myprint(
str(inspect.stack()[0][3]) + " L'identifiant du chef d'équipe est invalide ")
return False, " L'identifiant du chef d'équipe est invalide "
@ -134,9 +134,49 @@ def Add_Equipe_Team(diction):
" Impossible de créer l'équipe (2) ")
return False, " Impossible de créer l'équipe (2) "
"""
## Add to log history
"""
Après la création de l'equipe, on ajoute le chef d'équipe dans liste de membres
"""
if( "chef_equipe_id" in diction.keys() and diction['chef_equipe_id']):
new_data = {}
new_data['equipe_team_id'] = str(inserted_id)
new_data['rh_id'] = str(diction['chef_equipe_id'])
now = str(datetime.now())
mytoday = datetime.today()
new_data['date_ajout_equipe'] = str(mytoday)
new_data['date_update'] = now
new_data['valide'] = "1"
new_data['locked'] = "0"
new_data['partner_owner_recid'] = str(my_partner['recid'])
new_data['update_by'] = str(my_partner['_id'])
new_data['leader'] = "1"
data_cle = {}
data_cle['partner_owner_recid'] = str(my_partner['recid'])
data_cle['equipe_team_id'] = str(diction['_id'])
data_cle['rh_id'] = str(diction['chef_equipe_id'])
data_cle['valide'] = "1"
data_cle['locked'] = "0"
result = MYSY_GV.dbname['equipe_team_membre'].find_one_and_update(
data_cle,
{"$set": new_data},
upsert=True,
return_document=ReturnDocument.AFTER
)
if (result is None or "_id" not in result.keys()):
mycommon.myprint(
" WARNING : Impossible d'ajouter le chef d'équipe")
"""
## Add to log history
"""
now = str(datetime.now().strftime("%d/%m/%Y %H:%M:%S"))
# Pour la collection inscription
@ -171,7 +211,7 @@ def Add_Update_Equipe_Team_Membres(diction):
"""
Verification des input acceptés
"""
field_list = ['token', '_id', 'tab_ressource_humaine_ids']
field_list = ['token', '_id', 'tab_ressource_humaine_ids', 'role']
incom_keys = diction.keys()
for val in incom_keys:
@ -252,6 +292,11 @@ def Add_Update_Equipe_Team_Membres(diction):
new_data['equipe_team_id'] = str(diction['_id'])
new_data['rh_id'] = str(my_ressource_humaine)
if( "role" in diction.keys()):
new_data['role'] = str(diction['role'])[0:255]
else:
new_data['role'] = ""
now = str(datetime.now())
mytoday = datetime.today()
new_data['date_ajout_equipe'] = str(mytoday)
@ -371,30 +416,44 @@ def Delete_Groupe_Equipe_Team_Membre(diction):
str(inspect.stack()[0][3]) + " L'identifiant de l'équipe est invalide ")
return False, " L'identifiant de l'équipe est invalide "
is_existe_groupe = MYSY_GV.dbname['equipe_team'].find_one(
{'_id': ObjectId(str(diction['equipe_id'])),
'valide': '1',
'partner_owner_recid': str(my_partner['recid'])})
update_team_leader = "0"
equipe_team_chef_equipe_id = ""
if(is_existe_groupe and "chef_equipe_id" in is_existe_groupe ):
equipe_team_chef_equipe_id = is_existe_groupe['chef_equipe_id']
tab_equipe_team_membre_ids = ""
if ("tab_ids" in diction.keys()):
if diction['tab_ids']:
tab_inscriptions_ids = diction['tab_ids']
tab_equipe_team_membre_ids = diction['tab_ids']
tab_equipe_team_membre_ids_splited = str(tab_equipe_team_membre_ids).split(",")
tab_equipe_team_membre_ids_splited_ObjectID = []
for tmp in tab_equipe_team_membre_ids_splited :
tab_equipe_team_membre_ids_splited_ObjectID.append(ObjectId(str(tmp)))
qery_delete = {'_id': {'$in': tab_equipe_team_membre_ids_splited_ObjectID},
'equipe_team_id':str(diction['equipe_id']),
'partner_owner_recid': str(my_partner['recid']),
'locked': '0'}
"""
Pour les log d'historique, recuperation des information sur les membres supprimés
- rh_id,
- email
"""
Pour les log d'historique, recuperation des information sur les membres supprimés
- rh_id,
- email
et
Si la personne supprimée est le responsable, il faut alors mettre à vide le champ responsable sur la formation
"""
tab_delete_rh = []
for val in MYSY_GV.dbname['equipe_team_membre'].find(qery_delete):
if( val and "rh_id" in val.keys() ):
@ -415,9 +474,27 @@ def Delete_Groupe_Equipe_Team_Membre(diction):
tab_delete_rh.append(node_delete_rh_id_data)
"""
Si la personne supprimée est le responsable, il faut alors mettre à vide le champ responsable sur la formation
"""
if (str(rh_id_data['_id']) == equipe_team_chef_equipe_id):
result = MYSY_GV.dbname['equipe_team'].find_one_and_update(
{'_id': ObjectId(str(diction['equipe_id'])),
'valide': '1',
'partner_owner_recid': str(my_partner['recid'])},
{"$set": {"chef_equipe_id":""}},
upsert=False,
return_document=ReturnDocument.AFTER
)
history_massage_light = ""
for val in tab_delete_rh :
if("email" in val ):
history_massage_light = str(val['email'])+", "+str(history_massage_light)
#print(" ### qery_delete = ", qery_delete)
delete = MYSY_GV.dbname['equipe_team_membre'].delete_many(qery_delete )
@ -432,11 +509,12 @@ def Delete_Groupe_Equipe_Team_Membre(diction):
history_event_dict = {}
history_event_dict['token'] = diction['token']
history_event_dict['related_collection'] = "equipe_team"
history_event_dict['related_collection_recid'] = str(diction['_id'])
history_event_dict['related_collection_recid'] = str(diction['equipe_id'])
history_event_dict['action_date'] = str(now)
history_event_dict['technical_comment'] = "Suppression membre(s) " + str(tab_delete_rh)
history_event_dict['action_description'] = "Suppression membre(s) " + str(history_massage_light)
history_event_dict['action_description'] = "Suppression membres " + str(tab_delete_rh)
local_status, local_retval = mycommon.Collection_Historique.Add_Historique_Event(history_event_dict)
if (local_status is False):
mycommon.myprint(
@ -573,8 +651,59 @@ def Update_Equipe_Team(diction):
return False, " Impossible de mettre à jour l'équipe (2) "
"""
## Add to log history
"""
Après la création de l'equipe, on ajoute le chef d'équipe dans liste de membres
"""
if ("chef_equipe_id" in diction.keys() and diction['chef_equipe_id']):
new_data = {}
new_data['equipe_team_id'] = str(local_id)
new_data['rh_id'] = str(diction['chef_equipe_id'])
now = str(datetime.now())
mytoday = datetime.today()
new_data['date_ajout_equipe'] = str(mytoday)
new_data['date_update'] = now
new_data['valide'] = "1"
new_data['locked'] = "0"
new_data['partner_owner_recid'] = str(my_partner['recid'])
new_data['update_by'] = str(my_partner['_id'])
new_data['leader'] = "1"
data_cle = {}
data_cle['partner_owner_recid'] = str(my_partner['recid'])
data_cle['equipe_team_id'] = str(local_id)
data_cle['rh_id'] = str(diction['chef_equipe_id'])
data_cle['valide'] = "1"
data_cle['locked'] = "0"
"""
D'abord enlever le statut de leader si qq'un d'autre l'avait
"""
update = MYSY_GV.dbname['equipe_team_membre'].update_many(
{ "partner_owner_recid": str(my_partner['recid']), "equipe_team_id": str(local_id) },
{"$unset": {'leader':''}},
)
"""
A présent mise à jour du leader, avec potentiel ajout s'il n'existe pas
"""
print(" ### mise à jour du leader , data_cle = ", data_cle)
result = MYSY_GV.dbname['equipe_team_membre'].find_one_and_update(
data_cle,
{"$set": new_data},
upsert=True,
return_document=ReturnDocument.AFTER
)
if (result is None or "_id" not in result.keys()):
mycommon.myprint(
" WARNING : Impossible d'ajouter le chef d'équipe")
"""
## Add to log history
"""
now = str(datetime.now().strftime("%d/%m/%Y %H:%M:%S"))
# Pour la collection inscription
@ -604,6 +733,7 @@ Suppression d'une équipe
regles :
Si la condition (_id) n'est pas utiliser dans les collections
- xxxxxx (à préciser)
- pas de suppression si groupe à des membre. L'utilisateur devra supprimer les memebre d'abord
"""
def Delete_Equipe_Team(diction):
@ -658,6 +788,18 @@ def Delete_Equipe_Team(diction):
str(inspect.stack()[0][3]) + " L'identifiant de l'équipe est invalide ")
return False, " L'identifiant de l'équipe est invalide "
nb_membres = MYSY_GV.dbname['equipe_team_membre'].count_documents({'equipe_team_id': str(diction['_id']),
'partner_owner_recid': str(
my_partner['recid']),
}, )
if( nb_membres > 0 ):
mycommon.myprint(
str(inspect.stack()[0][3]) + " Ce groupe à "+str(nb_membres)+" membre(s) actif(s). Vous devez supprimer les membres avant de supprimer l'équipe ")
return False, " Ce groupe à "+str(nb_membres)+" membre(s) actif(s). Vous devez supprimer les membres avant de supprimer l'équipe "
is_existe_equipe_team_date = MYSY_GV.dbname['equipe_team'].find_one(
{'_id': ObjectId(str(diction['_id'])),
'valide': '1',
@ -891,6 +1033,7 @@ def Get_Given_Equipe_Team_With_Members(diction):
if(membre_rh_data and '_id' in membre_rh_data.keys() ):
node_membre = {}
node_membre['_id'] = str(team_membre['_id'])
node_membre['equipe_team_id'] = str(retval['_id'])
node_membre['rh_id'] = str(membre_rh_data['_id'])
@ -919,6 +1062,23 @@ def Get_Given_Equipe_Team_With_Members(diction):
else:
node_membre['telephone'] = ""
if ("comment" in membre_rh_data.keys()):
node_membre['comment'] = str(membre_rh_data['comment'])
else:
node_membre['comment'] = ""
if ("role" in team_membre.keys()):
node_membre['role'] = str(team_membre['role'])
else:
node_membre['role'] = ""
if ("leader" in team_membre.keys()):
node_membre['leader'] = str(team_membre['leader'])
else:
node_membre['leader'] = ""
list_membre.append(node_membre)
user['list_membre'] = list_membre
@ -1002,8 +1162,8 @@ def Get_List_Equipe_Team_With_Filter(diction):
] }
for tmp_val in MYSY_GV.dbname['ressource_humaine'].find({filt_membre_qry}):
list_membre_ressource_humaine_id.append(str([tmp_val['_id']]))
for tmp_val in MYSY_GV.dbname['ressource_humaine'].find(filt_membre_qry):
list_membre_ressource_humaine_id.append(str(tmp_val['_id']))
print(" ### liste des Id des ressources humaine sont = ", list_membre_ressource_humaine_id)
@ -1018,33 +1178,62 @@ def Get_List_Equipe_Team_With_Filter(diction):
find_qry = {
'$and': [{'partner_owner_recid': str(my_partner['recid']), 'valide': '1', 'locked': '0'}, filt_description,
filt_code, ]}
local_new_myquery_find_team = ""
local_new_myquery_find_team = [{'$match': find_qry},
{'$sort': {'_id': -1}},
{"$addFields": {"equipe_team_header_id": {"$toString": "$_id"}}},
{'$lookup':
{
'from': 'equipe_team_membre',
'localField': "equipe_team_header_id",
'foreignField': 'equipe_team_id',
'pipeline': [
{'$match':
{'$and':
[
filt_membre_ressource_humaine_id,
{'partner_owner_recid': str(my_partner['recid']),'valide': '1', 'locked':'0' },
]
if ("membre" in diction.keys()):
local_new_myquery_find_team = [{'$match': find_qry},
{'$sort': {'_id': -1}},
{"$addFields": {"equipe_team_header_id": {"$toString": "$_id"}}},
{'$lookup':
{
'from': 'equipe_team_membre',
'localField': "equipe_team_header_id",
'foreignField': 'equipe_team_id',
'pipeline': [
{'$match':
{'$and':
[
filt_membre_ressource_humaine_id,
{'partner_owner_recid': str(my_partner['recid']),'valide': '1', 'locked':'0' },
]
}
}
}, ],
'as': 'equipe_team_membre_collection'
}
},
{
'$unwind': '$equipe_team_membre_collection'
}
]
}, ],
'as': 'equipe_team_membre_collection'
}
},
{
"$unwind": "$equipe_team_membre_collection"
}
]
else:
local_new_myquery_find_team = [{'$match': find_qry},
{'$sort': {'_id': -1}},
{"$addFields": {"equipe_team_header_id": {"$toString": "$_id"}}},
{'$lookup':
{
'from': 'equipe_team_membre',
'localField': "equipe_team_header_id",
'foreignField': 'equipe_team_id',
'pipeline': [
{'$match':
{'$and':
[
filt_membre_ressource_humaine_id,
{'partner_owner_recid': str(my_partner['recid']),
'valide': '1', 'locked': '0'},
]
}
}, ],
'as': 'equipe_team_membre_collection'
}
},
]
print(" ### local_new_myquery_find_team = ", local_new_myquery_find_team)
@ -1053,6 +1242,8 @@ def Get_List_Equipe_Team_With_Filter(diction):
for local_New_retVal in MYSY_GV.dbname['equipe_team'].aggregate(local_new_myquery_find_team):
user = {}
user['id'] = str(val_tmp)
user['_id'] = str(local_New_retVal['_id'])
if( "code" in local_New_retVal.keys()):
user['code'] = local_New_retVal['code']
else:
@ -1073,6 +1264,29 @@ def Get_List_Equipe_Team_With_Filter(diction):
else:
user['chef_equipe_id'] = ""
nb_membre = "0"
if( "equipe_team_membre_collection" in local_New_retVal.keys() ):
nb_membre = len(local_New_retVal['equipe_team_membre_collection'])
user['nb_membre'] = str(nb_membre)
# Recuperation des nom et prenom du responsable (chef d'equipe)
chef_equipe_nom_prenom = ""
if ("chef_equipe_id" in local_New_retVal.keys() and local_New_retVal['chef_equipe_id']):
chef_equipe_id_data = MYSY_GV.dbname['ressource_humaine'].find_one(
{'partner_recid': str(my_partner['recid']),
'valide': '1',
'locked': '0',
'_id': ObjectId(str(local_New_retVal['chef_equipe_id']))})
if (chef_equipe_id_data and 'nom' in chef_equipe_id_data.keys()):
chef_equipe_nom_prenom = chef_equipe_id_data['nom']
if (chef_equipe_id_data and 'prenom' in chef_equipe_id_data.keys()):
chef_equipe_nom_prenom = chef_equipe_nom_prenom + " " + chef_equipe_id_data['prenom']
user['chef_equipe_nom_prenom'] = str(chef_equipe_nom_prenom)
val_tmp = val_tmp + 1
RetObject.append(mycommon.JSONEncoder().encode(user))

18
main.py
View File

@ -96,6 +96,7 @@ import partner_produit_service_mgt as partner_produit_service_mgt
import model_planning_sequence_mgt as model_planning_sequence_mgt
import base_partner_catalog_config as base_partner_catalog_config
import equipe_team_mgt as equipe_team_mgt
import base_class_calcul_note as base_class_calcul_note
import base_document_automatic_setup as base_document_automatic_setup
@ -12025,7 +12026,6 @@ def Delete_Nicole_Account(token, user_email):
payload = {}
payload['token'] = str(token)
payload['user_email'] = str(user_email)
print(" ### Delete_Nicole_Account : payload = ",payload)
localStatus, message= tools_cherif.Delete_Nicole_Account(payload)
return jsonify(status=localStatus, message=message )
@ -12154,6 +12154,22 @@ def Add_Update_Equipe_Team_Membres():
return jsonify(status=localStatus, message=message )
"""
API de calcul de la note finale d'une formation avec le model : calcul_mode_1
"""
@app.route('/myclass/api/run_calcul_mode_1', methods=['POST','GET'])
@crossdomain(origin='*')
def run_calcul_mode_1():
# On recupere le corps (payload) de la requete
payload = mycommon.strip_dictionary(request.form.to_dict())
print(" ### run_calcul_mode_1 : payload = ",payload)
localStatus, message= base_class_calcul_note.run_calcul_mode_1(payload)
return jsonify(status=localStatus, message=message )
if __name__ == '__main__':
print(" debut api")
context = SSL.Context(SSL.SSLv23_METHOD)