02/02/2024 - 23h

master
cherif 2024-02-02 23:01:08 +01:00
parent 78036bee47
commit d596575de6
6 changed files with 2519 additions and 43 deletions

View File

@ -1,16 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="31/01/2024 - 20h">
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="02/02/2024 - 17h">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Inscription_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/Inscription_mgt.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Log/log_file.log" beforeDir="false" afterPath="$PROJECT_DIR$/Log/log_file.log" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Session_Formation.py" beforeDir="false" afterPath="$PROJECT_DIR$/Session_Formation.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/email_inscription_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/email_inscription_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$/module_editique.py" beforeDir="false" afterPath="$PROJECT_DIR$/module_editique.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/partner_document_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/partner_document_mgt.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/partners.py" beforeDir="false" afterPath="$PROJECT_DIR$/partners.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/prj_common.py" beforeDir="false" afterPath="$PROJECT_DIR$/prj_common.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -80,13 +77,6 @@
<option name="presentableId" value="Default" />
<updated>1680804787304</updated>
</task>
<task id="LOCAL-00160" summary="01/12/2023 - 23h">
<created>1701470779882</created>
<option name="number" value="00160" />
<option name="presentableId" value="LOCAL-00160" />
<option name="project" value="LOCAL" />
<updated>1701470779882</updated>
</task>
<task id="LOCAL-00161" summary="04/12/2023 - 21h">
<created>1701722884012</created>
<option name="number" value="00161" />
@ -423,7 +413,14 @@
<option name="project" value="LOCAL" />
<updated>1706727057688</updated>
</task>
<option name="localTasksCounter" value="209" />
<task id="LOCAL-00209" summary="02/02/2024 - 17h">
<created>1706890019271</created>
<option name="number" value="00209" />
<option name="presentableId" value="LOCAL-00209" />
<option name="project" value="LOCAL" />
<updated>1706890019272</updated>
</task>
<option name="localTasksCounter" value="210" />
<servers />
</component>
<component name="Vcs.Log.Tabs.Properties">
@ -438,7 +435,6 @@
</option>
</component>
<component name="VcsManagerConfiguration">
<MESSAGE value="29/12/2023- 12h" />
<MESSAGE value="31/12/2023- 18h" />
<MESSAGE value="01/01/2024- 18h" />
<MESSAGE value="03/01/2024 - 17h30" />
@ -463,6 +459,7 @@
<MESSAGE value="ss" />
<MESSAGE value="31/01/2024 - 16h" />
<MESSAGE value="31/01/2024 - 20h" />
<option name="LAST_COMMIT_MESSAGE" value="31/01/2024 - 20h" />
<MESSAGE value="02/02/2024 - 17h" />
<option name="LAST_COMMIT_MESSAGE" value="02/02/2024 - 17h" />
</component>
</project>

View File

@ -1590,7 +1590,8 @@ def DownloadParticipantsList(diction):
# Recuperation des données de la session
local_session = MYSY_GV.dbname['session_formation'].find_one({'code_session':session_id, 'class_internal_url':internal_url})
local_session = MYSY_GV.dbname['session_formation'].find_one({'_id':ObjectId(str(session_id)), 'class_internal_url':internal_url})
if (local_session is None):
@ -1844,12 +1845,12 @@ def DownloadEvaluationList(diction):
# Recuperation des données de la session
local_session = MYSY_GV.dbname['session_formation'].find_one({'code_session':session_id, 'class_internal_url':internal_url})
local_session = MYSY_GV.dbname['session_formation'].find_one({'_id':ObjectId(str(session_id)), 'class_internal_url':internal_url})
if (local_session is None):
mycommon.myprint(str(inspect.stack()[0][3]) + " - Cette de formation n'a pas d'informations detaillées ")
return False, " Cette session de formation n'a pas d'informations detaillées "
mycommon.myprint(str(inspect.stack()[0][3]) + " L'identifiant de la session est invalide ")
return False, " L'identifiant de la session est invalide "
# Recuperation des données de la formation
local_formation = MYSY_GV.dbname['myclass'].find_one({'internal_url':str(internal_url)})
@ -1871,14 +1872,38 @@ def DownloadEvaluationList(diction):
local_data = {}
local_data['titre'] = local_formation['title']
local_data['code_session'] = local_session['code_session']
titre_session = ""
if( "titre" in local_session.keys() ):
titre_session = local_session['titre']
local_data['titre_session'] = titre_session
nb_participants = ""
if ("nb_participant" in local_session.keys()):
nb_participants = local_session['nb_participant']
local_data['nb_participant'] = nb_participants
local_data['debut_session'] = local_session ['date_debut']
local_data['fin_session'] = local_session['date_fin']
local_formateur = ""
if ("formateur" in local_session.keys()):
if local_session['formateur']:
local_formateur = local_session['formateur']
local_data['formateur'] = local_formateur
formateur_nom_prenom = ""
# Si il y a un code formateur_id, alors on va recuperer les nom et prenom du formation
if ("formateur_id" in local_session.keys() and local_session['formateur_id']):
formateur_data = MYSY_GV.dbname['ressource_humaine'].find_one(
{'_id': ObjectId(str(local_session['formateur_id'])),
'valide': '1',
'locked': '0',
'partner_recid': str(partner_recid)
})
if (formateur_data and "nom" in formateur_data.keys() and "prenom" in formateur_data.keys()):
formateur_nom_prenom = str(formateur_data['nom']) + " " + str(formateur_data['prenom'])
local_data['formateur'] = formateur_nom_prenom
presentiel = ""
if ("presentiel" in local_session.keys()):
@ -1923,6 +1948,13 @@ def DownloadEvaluationList(diction):
eval_date = retval['eval_date']
local_data['evaluation_date'] = str(eval_date)[0:10]
date_demande_eval = ""
if ("date_demande_eval" in retval.keys()):
date_demande_eval = retval['date_demande_eval']
local_data['date_demande_eval'] = str(date_demande_eval)[0:10]
eval_note = ""
if ("eval_note" in retval.keys()):
eval_note = retval['eval_note']
@ -3770,7 +3802,7 @@ def Evaluation_Class(diction):
"""
now = str(datetime.now().strftime("%d/%m/%Y %H:%M:%S"))
history_event_dict = {}
history_event_dict['token'] = diction['token']
history_event_dict['token'] = ""
history_event_dict['related_collection'] = "inscription"
history_event_dict['related_collection_recid'] = str(diction['inscription_id'])
history_event_dict['action_date'] = str(now)
@ -3854,17 +3886,14 @@ def SendTrainingEvaluationEmail(diction):
if diction['token']:
my_token = diction['token']
# Verifier la validité du token
retval = mycommon.check_partner_token_validity("", my_token)
if retval is False:
return "Err_Connexion", " La session de connexion n'est pas valide"
local_status, my_partner = mycommon.Check_Connexion_And_Return_Partner_Data(diction)
if (local_status is not True):
return local_status, my_partner
# Recuperation du recid du partenaire
partner_recid = mycommon.get_parnter_recid_from_token(str(my_token))
if partner_recid is False:
mycommon.myprint(str(inspect.stack()[0][3]) + " - Impossible d'imprimer la fiche detaillée")
return False, " Les informations fournies sont incorrectes"
partner_recid = str(my_partner['recid'])
# Verifier qui la formation n'a pas deja été evaluée
tmp_count = MYSY_GV.dbname['inscription'].count_documents({'session_id': str(diction['session_id']),
@ -3989,6 +4018,11 @@ def SendTrainingEvaluationEmail(diction):
my_retrun_dict['session_ondemande'] = session_ondemande
my_retrun_dict['partner_owner_recid'] = local_session_info['partner_owner_recid']
my_retrun_dict['token'] = str(diction['token'])
my_retrun_dict['session_id'] = str(diction['session_id'])
my_retrun_dict['inscription_id'] = str(local_Insc_retval['_id'])
# Envoi de l'email de notification au formateur
local_status, local_message = email_session.Evaluation_training_confirmation_mail(my_retrun_dict)
@ -4017,6 +4051,192 @@ def SendTrainingEvaluationEmail(diction):
"""
Cette fonction envoie l'email de demande d'evaluation from tab_ids
"""
def SendTrainingEvaluationEmail_from_tab_ids(diction):
try:
field_list_obligatoire = ['session_id', 'token', 'tab_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"
my_token = ""
if ("token" in diction.keys()):
if diction['token']:
my_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
my_inscription_ids = ""
if ("tab_ids" in diction.keys()):
if diction['tab_ids']:
my_inscription_ids = diction['tab_ids']
# Recuperation du recid du partenaire
partner_recid = str(my_partner['recid'])
tab_my_inscription_ids = str(my_inscription_ids).split(",")
for my_inscription_id in tab_my_inscription_ids:
# Verifier qui la formation n'a pas deja été evaluée
tmp_count = MYSY_GV.dbname['inscription'].count_documents({'session_id': str(diction['session_id']),
'_id':ObjectId(str(my_inscription_id)),
'partner_owner_recid': str(partner_recid),
"eval_date": {"$exists": True}})
if (tmp_count > 0):
mycommon.myprint(str(inspect.stack()[0][3]) + " Cet apprenant a déjà évalué cette session")
return False, " Cet apprenant a déjà évalué cette session"
RetObject = []
# Recuperation des infos de la formation
local_Insc_retval = MYSY_GV.dbname['inscription'].find_one({'session_id': str(diction['session_id']),
'_id':ObjectId(str(my_inscription_id)),
'partner_owner_recid': str(partner_recid),
})
if(local_Insc_retval is None ):
mycommon.myprint(str(inspect.stack()[0][3]) + " L'identifiant de l'inscrit est invalide ")
return False, " L'identifiant de l'inscrit est invalide "
my_retrun_dict = {}
print(' ##### local_Insc_retval = ', local_Insc_retval)
my_retrun_dict['token_eval'] = local_Insc_retval['_id']
if( "date_du" in local_Insc_retval.keys() ):
my_retrun_dict['date_du'] = str(local_Insc_retval['date_du'])[1:10]
else:
my_retrun_dict['date_du'] = ""
if ("date_au" in local_Insc_retval.keys() ):
my_retrun_dict['date_au'] = str(local_Insc_retval['date_au'])[0:10]
else:
my_retrun_dict['date_au'] = ""
my_retrun_dict['session_id'] = str(local_Insc_retval['_id'])
ville = ""
if ("ville" in local_Insc_retval.keys() and local_Insc_retval['ville']):
ville = local_Insc_retval['ville']
my_retrun_dict['ville'] = ville
code_postal = ""
if ("code_postal" in local_Insc_retval.keys() and local_Insc_retval['code_postal']):
code_postal = local_Insc_retval['code_postal']
my_retrun_dict['code_postal'] = code_postal
internal_url = ""
if ("class_internal_url" in local_Insc_retval.keys() and local_Insc_retval['class_internal_url']):
internal_url = local_Insc_retval['class_internal_url']
my_retrun_dict['internal_url'] = internal_url
adresse = ""
if ("adresse" in local_Insc_retval.keys() and local_Insc_retval['adresse']):
adresse = local_Insc_retval['adresse']
my_retrun_dict['adresse'] = adresse
nom = ""
if ("nom" in local_Insc_retval.keys() and local_Insc_retval['nom']):
nom = local_Insc_retval['nom']
my_retrun_dict['nom'] = nom
prenom = ""
if ("prenom" in local_Insc_retval.keys() and local_Insc_retval['prenom']):
prenom = local_Insc_retval['prenom']
my_retrun_dict['prenom'] = prenom
employeur = ""
if ("employeur" in local_Insc_retval.keys() and local_Insc_retval['employeur']):
employeur = local_Insc_retval['employeur']
my_retrun_dict['employeur'] = employeur
telephone = ""
if ("telephone" in local_Insc_retval.keys() and local_Insc_retval['telephone']):
telephone = local_Insc_retval['telephone']
my_retrun_dict['telephone'] = telephone
my_retrun_dict['email'] = local_Insc_retval['email']
# Recuperation des infotrmations de la formation
print(" ### str(local_Insc_retval['class_internal_url']) = ",str(local_Insc_retval['class_internal_url']) )
local_formation = MYSY_GV.dbname['myclass'].find_one(
{'internal_url': str(local_Insc_retval['class_internal_url'])})
my_retrun_dict['title'] = local_formation['title']
# Recuperation des info de session
local_session_info = MYSY_GV.dbname['session_formation'].find_one({'_id': ObjectId(str(diction['session_id'])),
'valide': '1'})
if( local_session_info is None):
mycommon.myprint(str(inspect.stack()[0][3]) + " Impossible de récupérer les données de la session de formation")
return False, " Impossible de récupérer les données de la session de formation"
if ("code_session" in local_session_info.keys()):
if local_session_info['code_session']:
my_retrun_dict['code_session'] = local_session_info['code_session']
if ("distantiel" in local_session_info.keys()):
if local_session_info['distantiel']:
my_retrun_dict['distantiel'] = local_session_info['distantiel']
if ("presentiel" in local_session_info.keys()):
if local_session_info['presentiel']:
my_retrun_dict['presentiel'] = local_session_info['presentiel']
session_ondemande = ""
if ("session_ondemande" in local_session_info.keys()):
if local_session_info['session_ondemande']:
session_ondemande = local_session_info['session_ondemande']
my_retrun_dict['session_ondemande'] = session_ondemande
my_retrun_dict['partner_owner_recid'] = local_session_info['partner_owner_recid']
my_retrun_dict['token'] = str(diction['token'])
my_retrun_dict['session_id'] = str(diction['session_id'])
my_retrun_dict['inscription_id'] = str(local_Insc_retval['_id'])
# Envoi de l'email de notification au formateur
local_status, local_message = email_session.Evaluation_training_confirmation_mail(my_retrun_dict)
"""
# Ajout de l'evenement dans l'historique
"""
now = str(datetime.now().strftime("%d/%m/%Y %H:%M:%S"))
history_event_dict = {}
history_event_dict['token'] = diction['token']
history_event_dict['related_collection'] = "inscription"
history_event_dict['related_collection_recid'] = str(local_Insc_retval['_id'])
history_event_dict['action_date'] = str(now)
history_event_dict['action_description'] = " Demande Evaluation Formation "
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 local_status, "Les demande d'évaluation ont été correctement envoyées "
except Exception as e:
exc_type, exc_obj, exc_tb = sys.exc_info()
print(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
return False, " Impossible d'envoyer la demande d'évaluation"
"""
Cette fonction envoie le certificat d'un stagiaire
@ -4490,13 +4710,14 @@ def GetListEvaluation_Session(diction):
RetObject = []
val_tmp = 1
#qry = {'session_id': str(diction['session_id']), 'partner_owner_recid':str(partner_recid)}
qry = {'session_id': str(diction['session_id']), 'partner_owner_recid':str(partner_recid)}
print(" #### qry = ", qry)
# Recuperation des infos de la formation
for local_Insc_retval in MYSY_GV.dbname['inscription'].find({'session_id': str(diction['session_id']), 'partner_owner_recid':str(partner_recid)}):
user = {}
user['id'] = str(val_tmp)
user['_id'] = str(local_Insc_retval['_id'])
val_tmp = val_tmp + 1
user['session_id'] = local_Insc_retval['session_id']
user['email'] = local_Insc_retval['email']
@ -4533,10 +4754,16 @@ def GetListEvaluation_Session(diction):
user['eval_pedagogie'] = ""
if ("date_demande_eval" in local_Insc_retval.keys()):
user['date_demande_eval'] = local_Insc_retval['date_demande_eval']
else:
user['date_demande_eval'] = ""
RetObject.append(mycommon.JSONEncoder().encode(user))
print(" ### RetObject = ", RetObject)
return True, RetObject
except Exception as e:

File diff suppressed because it is too large Load Diff

View File

@ -13,6 +13,7 @@ from bson import ObjectId
from pymongo import ReturnDocument
from xhtml2pdf import pisa
import module_editique
import prj_common as mycommon
import GlobalVariable as MYSY_GV
from dateutil import tz
@ -1113,7 +1114,7 @@ def Evaluation_training_confirmation_mail(diction):
Verification de la liste des champs obligatoires
"""
field_list_obligatoire = ['nom', 'prenom', 'email', 'date_du', 'date_au', 'adresse', 'title', 'token_eval',
'internal_url', 'session_ondemande']
'internal_url', 'session_ondemande', 'token', 'session_id', 'inscription_id']
for val in field_list_obligatoire:
if val not in diction:
mycommon.myprint(
@ -1121,6 +1122,9 @@ def Evaluation_training_confirmation_mail(diction):
return False, "Impossible d'envoyer l'email de demande d'evaluation"
local_status, my_partner = mycommon.Check_Connexion_And_Return_Partner_Data(diction)
if (local_status is not True):
return local_status, my_partner
tomorrow = datetime.date.today() + datetime.timedelta(days=1)
tomorrow_day = tomorrow.strftime("%A")
@ -1253,17 +1257,36 @@ def Evaluation_training_confirmation_mail(diction):
Apres l'envoi de la demande d'evaluation
on met à jour le statut 'eval_statut' à 0 (envoyé)
"""
now = str(datetime.datetime.now().strftime("%d/%m/%Y %H:%M:%S"))
new_data = {}
new_data['eval_status'] = "0"
new_data['date_demande_eval'] = str(now)
new_data['date_update'] = str(now)
new_data['update_by'] = str(my_partner['_id'])
#MYSY_GV.dbname['inscription'].find_one_and_update()
ret_val2 = MYSY_GV.dbname['inscription'].find_one_and_update(
{'_id': ObjectId(str(diction['session_id'])), 'valide': '1', },
{"$set": {'eval_status': '0', 'date_demande_eval': now, 'date_update': now}},
{'_id': ObjectId(str(diction['inscription_id'])), 'valide': '1', },
{"$set": new_data},
return_document=ReturnDocument.AFTER,
upsert=False,
)
if( ret_val2 is None ):
mycommon.myprint(
" WARNING : Impossible mettre à jour la date de demande d'évaluation: ")
"""
update du 30/01/2024 :
Apres l'envoi de la demande d'evaluation
loger une action dans la collection ==> courrier_template_tracking_history
"""
local_status, local_retval = module_editique.Editic_Log_History_Action_From_courrier_template_type_document_ref_interne(
my_partner, "EVALUATIONS",
str(diction['session_id']), 'inscription', str(diction['inscription_id']), "")
return True, " Email bien envoyé"
except Exception as e:

View File

@ -1798,7 +1798,7 @@ def SendInvoiceEmail(account_mail, diction):
"""
Cette fonction envoi une demande de validation de presence
à une formation.
C'est l'emargement electronique
C'est l'emargement electronique
"""
def SendEmargementMail( diction):
try:

17
main.py
View File

@ -2763,6 +2763,23 @@ def SendTrainingEvaluationEmail():
localStatus, message= inscription.SendTrainingEvaluationEmail(payload)
return jsonify(status=localStatus, message=message )
"""
Cette fonction envoie l'email de demande d'evaluation from tab_ids
"""
@app.route('/myclass/api/SendTrainingEvaluationEmail_from_tab_ids/', methods=['POST','GET'])
@crossdomain(origin='*')
def SendTrainingEvaluationEmail_from_tab_ids():
# On recupere le corps (payload) de la requete
payload = mycommon.strip_dictionary (request.form.to_dict())
print(" ### SendTrainingEvaluationEmail_from_tab_ids : payload = ",payload)
localStatus, message= inscription.SendTrainingEvaluationEmail_from_tab_ids(payload)
return jsonify(status=localStatus, message=message )
"""
API Qui declenche l'envoi de l'attestation de formation par email
"""