master
cherif 2024-01-26 21:52:03 +01:00
parent 80bb16ba97
commit 0e1092b2c3
5 changed files with 1604 additions and 16 deletions

View File

@ -1,10 +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="24/01/2024 -12h00">
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="rrr">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" 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" />
</list>
<option name="SHOW_DIALOG" value="false" />
@ -75,13 +76,6 @@
<option name="presentableId" value="Default" />
<updated>1680804787304</updated>
</task>
<task id="LOCAL-00153" summary="18/11/2023 - 17h00">
<created>1700322992177</created>
<option name="number" value="00153" />
<option name="presentableId" value="LOCAL-00153" />
<option name="project" value="LOCAL" />
<updated>1700322992178</updated>
</task>
<task id="LOCAL-00154" summary="20/11/2023 - 21h00">
<created>1700513271611</created>
<option name="number" value="00154" />
@ -418,7 +412,14 @@
<option name="project" value="LOCAL" />
<updated>1706182967824</updated>
</task>
<option name="localTasksCounter" value="202" />
<task id="LOCAL-00202" summary="rrr">
<created>1706219904725</created>
<option name="number" value="00202" />
<option name="presentableId" value="LOCAL-00202" />
<option name="project" value="LOCAL" />
<updated>1706219904725</updated>
</task>
<option name="localTasksCounter" value="203" />
<servers />
</component>
<component name="Vcs.Log.Tabs.Properties">
@ -433,7 +434,6 @@
</option>
</component>
<component name="VcsManagerConfiguration">
<MESSAGE value="18/12/2023 - 18:00" />
<MESSAGE value="18/12/2023 - 22:00" />
<MESSAGE value="20/12/2023 - 18h" />
<MESSAGE value="27/12/2023 - 13h" />
@ -458,6 +458,7 @@
<MESSAGE value="21/01/2024 -18h30" />
<MESSAGE value="22/01/2024 -22h00" />
<MESSAGE value="24/01/2024 -12h00" />
<option name="LAST_COMMIT_MESSAGE" value="24/01/2024 -12h00" />
<MESSAGE value="rrr" />
<option name="LAST_COMMIT_MESSAGE" value="rrr" />
</component>
</project>

File diff suppressed because one or more lines are too long

View File

@ -4157,11 +4157,15 @@ def Prepare_and_Send_Convention_From_Session_By_Email(tab_files, Folder, diction
"""
25/01/2024 : pour loger une action dans la collection ==> courrier_template_tracking_history
"""
courrier_template_type_document_id = "-1"
if( "courrier_template_type_document_id" in courrier_template_data.keys() ):
courrier_template_type_document_id = courrier_template_data['courrier_template_type_document_id']
courrier_template_tracking_id = ""
courrier_template_tracking_data = MYSY_GV.dbname['courrier_template_tracking'].find_one({'partner_owner_recid':str(my_partner['recid']),
'valide':'1',
'locked':'0',
'courrier_template_id':str(diction['courrier_template_id'])})
'courrier_template_type_document_id':str(courrier_template_type_document_id)})
if(courrier_template_tracking_data is None ):
mycommon.myprint(
" WARNING impossible de recuperer le 'courrier_template_tracking' pour courrier_template_id : " +str(diction['courrier_template_id']) )

13
main.py
View File

@ -7277,6 +7277,19 @@ def Get_Editable_History_Document_By_Partner_By_Collection():
return jsonify(status=status, message=retval)
"""
API Pour initialiser la traçabilité des documents
"""
@app.route('/myclass/api/Init_And_Update_courrier_template_tracking/', methods=['POST','GET'])
@crossdomain(origin='*')
def Init_And_Update_courrier_template_tracking():
# On recupere le corps (payload) de la requete
payload = mycommon.strip_dictionary (request.form.to_dict())
print(" ### Init_And_Update_courrier_template_tracking payload = ",payload)
print(request.files)
status, retval = module_editique.Init_And_Update_courrier_template_tracking(payload)
return jsonify(status=status, message=retval)
"""
API des test des actions server

View File

@ -208,8 +208,8 @@ def Get_Editable_Document_By_Partner_By_Collection(diction):
{'$match': qry_match},
{'$sort': {'rang': 1}},
{'$lookup': {
'from': 'courrier_template',
"let": {'courrier_template_id': "$courrier_template_id", 'partner_owner_recid': '$partner_owner_recid'},
'from': 'courrier_template_type_document',
"let": {'courrier_template_type_document_id': "$courrier_template_type_document_id", 'partner_owner_recid': '$partner_owner_recid'},
'pipeline': [
{'$match':
{'$expr':
@ -217,7 +217,7 @@ def Get_Editable_Document_By_Partner_By_Collection(diction):
[
{'$eq': ["$_id", {'$convert': {
'input': "$$courrier_template_id",
'input': "$$courrier_template_type_document_id",
'to': "objectId",
'onError': {'error': 'true'},
'onNull': {'isnull': 'true'}
@ -253,7 +253,7 @@ def Get_Editable_Document_By_Partner_By_Collection(diction):
if('courrier_template_id' in New_retVal.keys()):
user['courrier_template_id'] = str(New_retVal['courrier_template_id'])
user['rang'] = "99999"
user['rang'] = "99"
if ('rang' in New_retVal.keys()):
user['rang'] = str(New_retVal['rang'])
@ -541,3 +541,114 @@ def Get_Editable_History_Document_By_Partner_By_Collection(diction):
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 a initialiser le contenu de la collection 'courrier_template_tracking' depuis les paramettres
mise dans la collection : 'courrier_template'.
Algo :
Pour chaque element de la collection 'courrier_template' ayant le
- tracked = 0 et
- tacking_collection[] (des elements dans ce tableau)
- partner_owner_recid : identique à l'utilisateur appelant
Le système va créer une entrée dans le collection 'courrier_template_tracking'
"""
def Init_And_Update_courrier_template_tracking(diction):
try:
field_list_obligatoire = ['token']
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, " La valeur '" + val + "' n'est pas presente dans liste"
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
warning_message = ""
cpt = 0
for retval in MYSY_GV.dbname['courrier_template_type_document'].find({'tracked':'0', 'valide':'1', 'locked':'0',
'partner_owner_recid':str(my_partner['recid'])}):
tab_tacking_collection = []
if( "tacking_collection" in retval.keys() ):
tab_tacking_collection = retval['tacking_collection']
for collection in tab_tacking_collection:
new_data = {}
new_data['courrier_template_type_document_id'] = str(retval['_id'])
new_data['partner_owner_recid'] = str(my_partner['recid'])
new_data['related_collection'] = str(collection)
new_data['courrier_template_ref_interne'] = str(retval['ref_interne'])
new_data['rang'] = str(retval['rang'])
new_data['server_action_name'] = "a préciser"
new_data['valide'] = "1"
new_data['locked'] = "0"
key_data = {}
key_data['courrier_template_id'] = str(retval['_id'])
key_data['partner_owner_recid'] = str(my_partner['recid'])
key_data['related_collection'] = str(collection)
key_data['valide'] = "1"
new_retval_data = MYSY_GV.dbname['courrier_template_tracking'].find_one_and_update(key_data,
{"$set": new_data},
upsert=True,
return_document=ReturnDocument.AFTER
)
if new_retval_data is None or "_id" not in new_retval_data.keys():
mycommon.myprint(
str(inspect.stack()[0][3]) + " Impossible d'initialiser la traçabilité du document "+str(retval['ref_interne'])+". ")
warning_message = warning_message + " Impossible d'initialiser la traçabilité du document "+str(retval['ref_interne'])+". "
cpt = cpt + 1
# Mise à jour du courrier_template pour mettre 'tracked':'1'
update_data = {}
update_data['date_update'] = datetime.now().strftime("%d/%m/%Y, %H:%M:%S")
update_data['update_by'] = str(my_partner['_id'])
update_data['tracked'] = "1"
MYSY_GV.dbname['courrier_template_type_document'].update_one({'_id':ObjectId(str(retval['_id']))}, {'$set':update_data})
if( warning_message == "" ):
return True, "Initialisation de la traçabilité de "+str(cpt)+" document(s) Ok "
else:
return True, warning_message
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 modèles de fiche"
"""
Au lieu de travailler sur : 'courrier_template' dans la reccherche des courriers
je dois créer une nouvelle collection 'type_doc' qui contient les infos statiques de 'courrier_template' comment
- setaction_server_to_run
- setaction_server_type_doc
- setaction_server_nom_doc
- setaction_server_ref_interne_doc
Le problème avec 'courrier_template' est que j'ai les differentes version d'un doc. Donc au lieu d'afficher juste
un doc pour les 'conventions entreprise mail', il va m'affichier toutes version, d'ou le bin's
"""