06/06/2024 - 12h

master
cherif 2024-06-06 12:12:07 +02:00
parent e8eb55a5cc
commit d45f024d35
5 changed files with 2863 additions and 41 deletions

View File

@ -1,12 +1,11 @@
<?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="qsdsqsqdsq">
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="05/06/2024 - 23h">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/GlobalVariable.py" beforeDir="false" afterPath="$PROJECT_DIR$/GlobalVariable.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/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$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/module_editique.py" beforeDir="false" afterPath="$PROJECT_DIR$/module_editique.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" />
@ -77,13 +76,6 @@
<option name="presentableId" value="Default" />
<updated>1680804787304</updated>
</task>
<task id="LOCAL-00275" summary="22/04/2024 - 17h30">
<created>1713799833124</created>
<option name="number" value="00275" />
<option name="presentableId" value="LOCAL-00275" />
<option name="project" value="LOCAL" />
<updated>1713799833126</updated>
</task>
<task id="LOCAL-00276" summary="23/04/2024 - 14h06">
<created>1713874032440</created>
<option name="number" value="00276" />
@ -420,7 +412,14 @@
<option name="project" value="LOCAL" />
<updated>1717601060943</updated>
</task>
<option name="localTasksCounter" value="324" />
<task id="LOCAL-00324" summary="05/06/2024 - 23h">
<created>1717621132734</created>
<option name="number" value="00324" />
<option name="presentableId" value="LOCAL-00324" />
<option name="project" value="LOCAL" />
<updated>1717621132735</updated>
</task>
<option name="localTasksCounter" value="325" />
<servers />
</component>
<component name="Vcs.Log.Tabs.Properties">
@ -462,7 +461,6 @@
</option>
</component>
<component name="VcsManagerConfiguration">
<MESSAGE value="dd" />
<MESSAGE value="ddsdfsd" />
<MESSAGE value="12/05/2024 - 21h30" />
<MESSAGE value="13/05/2024 - 18h30" />
@ -487,6 +485,7 @@
<MESSAGE value="01/06/2024 - 14h30" />
<MESSAGE value="qsdsq" />
<MESSAGE value="qsdsqsqdsq" />
<option name="LAST_COMMIT_MESSAGE" value="qsdsqsqdsq" />
<MESSAGE value="05/06/2024 - 23h" />
<option name="LAST_COMMIT_MESSAGE" value="05/06/2024 - 23h" />
</component>
</project>

File diff suppressed because it is too large Load Diff

View File

@ -1443,18 +1443,22 @@ def GetAllValideSessionPartner_List(diction):
"""
Pour chaque session recuperer le statut de controle d'alert
"""
is_session_alert = ""
session_alert_message = ""
local_diction = {}
local_diction['token'] = str(diction['token'])
local_diction['session_id'] = str(retVal['_id'])
local_check_session_alert_status, local_check_session_alert_retval, local_check_session_alert_is_warning = mycommon.Check_Partner_Session_Alert(local_diction)
is_session_alert = ""
session_alert_message = ""
if( local_check_session_alert_status ):
is_session_alert = local_check_session_alert_is_warning
session_alert_message = local_check_session_alert_retval
val['is_session_alert'] = is_session_alert
val['session_alert_message'] = session_alert_message

View File

@ -436,6 +436,277 @@ def Get_Editable_Document_By_Partner_By_Collection(diction):
return False, " Impossible de récupérer la liste des documents éditables "
def Get_Editable_Document_By_Partner_By_Collection_Light(diction):
try:
diction = mycommon.strip_dictionary(diction)
"""
Verification des input acceptés
"""
field_list = ['token', 'related_collection', 'related_collection_recid', 'session_id']
incom_keys = diction.keys()
for val in incom_keys:
if val not in field_list and val.startswith('my_') is False:
mycommon.myprint(str(
inspect.stack()[0][3]) + " Le champ '" + val + "' n'est pas autorisé")
return False, " Les informations fournies sont incorrectes"
"""
Verification des champs obligatoires
"""
field_list_obligatoire = ['token', 'related_collection', 'session_id']
for val in field_list_obligatoire:
if val not in diction:
mycommon.myprint(
str(inspect.stack()[0][3]) + " - La valeur '" + val + "' n'est pas presente dans liste ")
return False, " Les informations fournies sont incorrectes"
"""
Verification de l'identité et autorisation de l'entité qui
appelle cette API
"""
token = ""
if ("token" in diction.keys()):
if diction['token']:
token = diction['token']
related_collection = ""
if ("related_collection" in diction.keys()):
if diction['related_collection']:
related_collection = diction['related_collection']
if( str(related_collection).strip() == ""):
mycommon.myprint(
str(inspect.stack()[0][3]) + " Le nom de la collection est invalide ")
return False, " Le nom de la collection 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
RetObject = []
val_tmp = 0
qry_match = {"partner_owner_recid": str(my_partner['recid']), 'valide': '1', 'locked': '0', 'related_collection':str(related_collection)}
pipe_qry = ([
{'$match': qry_match},
{'$sort': {'rang': 1}},
{'$lookup': {
'from': 'courrier_template_type_document',
"let": {'courrier_template_type_document_ref_interne': '$courrier_template_type_document_ref_interne',
'partner_owner_recid': '$partner_owner_recid'},
'pipeline': [
{'$match':
{'$expr':
{'$and':
[
{'$eq': ["$ref_interne", '$$courrier_template_type_document_ref_interne']},
{'$eq': ["$valide", "1"]},
{'$eq': ["$partner_owner_recid", 'default']}
]
}
}
},
{'$project': {'contenu_doc': 0, 'corps_mail': 0}},
],
'as': 'collection_courrier_template'
}
},
{
'$unwind': '$collection_courrier_template'
},
{'$sort': {"collection_courrier_template.rang": 1}},
])
#print(" #### Get_Editable_Document_By_Partner_By_Collection pipe_qry_Get_Editable_Document_By_Partner = ", pipe_qry)
json_formatted_str = json.dumps(pipe_qry, indent=2)
#print(" #### Get_Editable_Document_By_Partner_By_Collection pipe_qry_Get_Editable_Document_By_Partner = ", json_formatted_str)
for New_retVal in MYSY_GV.dbname['courrier_template_tracking'].aggregate(pipe_qry):
if ("collection_courrier_template" in New_retVal.keys()):
user = {}
user['_id'] = str(New_retVal['_id'])
user['id'] = str(val_tmp)
user['courrier_template_id'] = ""
if('courrier_template_id' in New_retVal.keys()):
user['courrier_template_id'] = str(New_retVal['courrier_template_id'])
docu_statut = "0" #
user['courrier_template_ref_interne'] = ""
if ('ref_interne' in New_retVal['collection_courrier_template'].keys()):
user['courrier_template_ref_interne'] = str(New_retVal['collection_courrier_template']['ref_interne'])
# On va recuperer le statut de ce type de document pour savoir si toutes les actions ont été menées
docu_statut = 0 #
local_diction = {}
local_diction['session_id'] = diction['session_id']
local_diction['token'] = diction['token']
local_diction['courrier_template_type_document_ref_interne'] = str(New_retVal['collection_courrier_template']['ref_interne'])
#print(" ### local_diction = ", local_diction )
local_doc_status, local_doc_retval = Get_Given_Session_Action_Status_By_Document(local_diction)
if( local_doc_status is False ):
docu_statut = "0" #
List_Document_a_Traquer = local_doc_retval
if (List_Document_a_Traquer[0]['global_status']):
if( str(List_Document_a_Traquer[0]['global_status']) == "partiel"):
docu_statut = "1"
elif( str(List_Document_a_Traquer[0]['global_status']) == "complet"):
docu_statut = "2"
else:
docu_statut = "0"
"""
pour la completude d'un document :
0 = Rien n'est fait
1 = Partiel
2 = Terminé
"""
user['statut_completude'] = str(docu_statut)
user['courrier_template_nom'] = ""
if ('nom' in New_retVal['collection_courrier_template'].keys()):
user['courrier_template_nom'] = str(
New_retVal['collection_courrier_template']['nom'])
user['courrier_template_sujet'] = ""
if ('sujet' in New_retVal['collection_courrier_template'].keys()):
user['courrier_template_sujet'] = str(
New_retVal['collection_courrier_template']['sujet'])
user['courrier_template_cible'] = ""
if ('cible' in New_retVal['collection_courrier_template'].keys()):
user['courrier_template_cible'] = str(
New_retVal['collection_courrier_template']['cible'])
user['courrier_template_type_doc'] = ""
if ('type_doc' in New_retVal['collection_courrier_template'].keys()):
user['courrier_template_type_doc'] = str(
New_retVal['collection_courrier_template']['type_doc'])
list_document_history_event = []
has_history_event = "0"
if( "related_collection_recid" in diction.keys() and diction['related_collection_recid']):
"""
Verifier si document a un historic pour le related_collection_recid.
Cela permet de savoir si pour l'entité qui appelle cette fonction, ce document a déjà été
traité
"""
local_qry = {'partner_owner_recid':str(my_partner['recid']),
'related_collection_recid':str(diction['related_collection_recid']),
'courrier_template_tracking_id':str(New_retVal['_id']),
'valide':'1',
'locked':'0'}
#print(" #### is_document_has_history_event qry = ", local_qry)
is_document_has_history_event = MYSY_GV.dbname['courrier_template_tracking_history'].count_documents(local_qry)
local_related_collection = ""
local_related_collection_id = ""
local_related_collection_name = ""
if( is_document_has_history_event > 0 ):
has_history_event = "1"
for val in MYSY_GV.dbname['courrier_template_tracking_history'].find(local_qry):
#print(" val 1 = ", val)
if( val and "courrier_template_id" in val.keys() and "related_collection_recid" in val.keys() ):
local_courrier_template_id = val['courrier_template_id']
if( ObjectId.is_valid(local_courrier_template_id)):
courrier_template_data = MYSY_GV.dbname['courrier_template'].find_one({'_id':ObjectId(str(local_courrier_template_id))},
{'contenu_doc':'0'})
related_collection_data = MYSY_GV.dbname[related_collection].find_one({'_id':ObjectId(str(diction['related_collection_recid']))})
#print(" #### SESSSION DATA = ", related_collection_data)
local_related_collection = "Session Formation"
local_related_collection_id = str(val['related_collection_recid'])
local_related_collection_name = str(related_collection_data['code_session'])
val['local_related_collection'] = local_related_collection
val['local_related_collection_id'] = local_related_collection_id
val['local_related_collection_name'] = local_related_collection_name
"""
Recuperation des infos de la cible pour qui l'action a été faite.
"""
local_target_collection = ""
local_target_collection_id = ""
local_target_collection_name = ""
if( val and "target_collection" in val.keys() and val['target_collection'] and "target_collection_recid" in val.keys() and val['target_collection_recid']):
if( str(val['target_collection']) == "inscription"):
local_target_collection = str(val['target_collection'])
local_target_collection_id = str(val['target_collection_recid'])
local_target_collection_data = MYSY_GV.dbname[str(val['target_collection'])].find_one({'_id':ObjectId(str(val['target_collection_recid'])),
'partner_owner_recid':str(my_partner['recid'])})
if( local_target_collection_data and "email" in local_target_collection_data.keys()):
local_target_collection_name = local_target_collection_data['email']
elif (str(val['target_collection']) == "emargement"):
local_target_collection = str(val['target_collection'])
local_target_collection_id = str(val['target_collection_recid'])
local_target_collection_data = MYSY_GV.dbname[str(val['target_collection'])].find_one(
{'_id': ObjectId(str(val['target_collection_recid'])),
'partner_owner_recid': str(my_partner['recid'])})
if (local_target_collection_data and "email" in local_target_collection_data.keys()):
local_target_collection_name = local_target_collection_data['email']
val['local_target_collection'] = local_target_collection
val['local_target_collection_id'] = local_target_collection_id
val['local_target_collection_name'] = local_target_collection_name
local_update_by_email = ""
if( "update_by" in val.keys()):
update_by_data = MYSY_GV.dbname['partnair_account'].find_one({'_id':ObjectId(val['update_by']),
'recid':my_partner['recid']})
if( "email" in update_by_data ):
local_update_by_email = update_by_data['email']
val['local_update_by_email'] = local_update_by_email
#print(" ### VALLL = ", val)
list_document_history_event.append(val)
#print(" #### is_document_has_history_event RESULT = ", is_document_has_history_event)
user['has_history_event'] = has_history_event
user['list_document_history_event'] = list_document_history_event
val_tmp = val_tmp + 1
RetObject.append(mycommon.JSONEncoder().encode(user))
#print(" #### RetObject = ", RetObject)
return True, RetObject
except Exception as e:
exc_type, exc_obj, exc_tb = sys.exc_info()
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - Line : " + str(exc_tb.tb_lineno))
return False, " Impossible de récupérer la liste des documents éditables "
"""
Cette fonction retourne l'HISTORIQUE des telechargements et envois de mail
des documents tracés, pour :

View File

@ -6070,15 +6070,16 @@ def Check_Partner_Session_Alert(diction):
session_warning_lead_time = str(tmp_val['config_value'])
session_warning_lead_time_INT = tryInt(session_warning_lead_time)
make_ctl = 0
if(session_warning == "1" and session_warning_lead_time_INT >= delta_day_INT ):
if(session_warning == "1" and delta_day_INT > 0 and session_warning_lead_time_INT >= delta_day_INT ):
make_ctl = 1
if( make_ctl == 0 ):
return True, "OK", "0"
print(" ## session_warning_lead_time_INT = ", session_warning_lead_time_INT)
#print(" ## session_warning_lead_time_INT = ", session_warning_lead_time_INT)
"""
Pour la liste des étapes à controler, on prent : 'courrier_template_ref_interne'
@ -6098,39 +6099,40 @@ def Check_Partner_Session_Alert(diction):
- si les questionnaire de positionnement n'ont pas été envoyés
"""
diction_list_tracked_doc = {}
diction_list_tracked_doc['token'] = str(diction['token'])
diction_list_tracked_doc['related_collection'] = "session_formation"
diction_list_tracked_doc['related_collection_recid'] = str(diction['session_id'])
diction_list_tracked_doc['session_id'] = str(diction['session_id'])
for tmp_val in MYSY_GV.dbname['courrier_template_type_document'].find({'valide':'1', 'locked':'0',
'partner_owner_recid':'default'}):
diction_list_tracked_doc = {}
diction_list_tracked_doc['token'] = str(diction['token'])
diction_list_tracked_doc['courrier_template_type_document_ref_interne'] = str(tmp_val['ref_interne'])
diction_list_tracked_doc['session_id'] = str(diction['session_id'])
local_status, local_retval = module_editique.Get_Editable_Document_By_Partner_By_Collection(
diction_list_tracked_doc)
if (local_status is False):
return local_status, local_retval, False
local_status, local_retval = module_editique.Get_Given_Session_Action_Status_By_Document(
diction_list_tracked_doc)
if (local_status is False):
return local_status, local_retval, False
json_formatted_str = json.dumps(local_retval, indent=2)
local_data = local_retval[0]
#print(" ### AFFICHAGE dU data Check_Partner_Session_Alert ")
#print(json_formatted_str)
local_courrier_template_ref_interne = local_data['courrier_template_type_document_ref_interne']
for val_str in local_retval:
val = ast.literal_eval(val_str)
local_courrier_template_ref_interne = val['courrier_template_ref_interne']
if( local_courrier_template_ref_interne in list_etape_a_controler ):
if( str(val['statut_completude']) == "1"):
if (local_courrier_template_ref_interne in list_etape_a_controler):
if (str(local_data['global_status']) == "partiel"):
is_warning = 1
warning_message = warning_message + "<br/> "+str(val['courrier_template_nom'])+ " Partiel"
warning_message = warning_message + "<br/> " + str(local_data['courrier_template_type_document_ref_interne']) + " Partiel"
if (str(val['statut_completude']) == "0"):
if (str(local_data['global_status']) == "aucun"):
is_warning = 1
warning_message = warning_message + "<br/> " + str(val['courrier_template_nom']) + " Non Commencé"
warning_message = warning_message + "<br/> " + str(local_data['courrier_template_type_document_ref_interne']) + " Non Commencé"
# print(" is_warning = ", is_warning)
# print(" warning_message = ", warning_message)
#print(" is_warning = ", is_warning)
#print(" warning_message = ", warning_message)
#json_formatted_str = json.dumps(local_retval, indent=2)
#print(" ### AFFICHAGE dU data Get_Given_Session_Action_Status_By_Document ")
#print(json_formatted_str)
if( is_warning == 1 ):
return True, warning_message, str(is_warning)