18/02/2025 - 21h
parent
a1270ba76d
commit
95b126d3e1
|
@ -1,11 +1,14 @@
|
|||
<?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="11/02/2025 - 15h30">
|
||||
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="11/02/2025 - 21h">
|
||||
<change afterPath="$PROJECT_DIR$/base_document_automatic_setup.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Job_Cron.py" beforeDir="false" afterPath="$PROJECT_DIR$/Job_Cron.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$/base_partner_catalog_config.py" beforeDir="false" afterPath="$PROJECT_DIR$/base_partner_catalog_config.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.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$/tools_cherif/tools_cherif.py" beforeDir="false" afterPath="$PROJECT_DIR$/tools_cherif/tools_cherif.py" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
|
@ -76,13 +79,6 @@
|
|||
<option name="presentableId" value="Default" />
|
||||
<updated>1680804787304</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00389" summary="03/09/2024 - 20:00">
|
||||
<created>1725389636274</created>
|
||||
<option name="number" value="00389" />
|
||||
<option name="presentableId" value="LOCAL-00389" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1725389636275</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00390" summary="04/09/2024 - 23h">
|
||||
<created>1725482228553</created>
|
||||
<option name="number" value="00390" />
|
||||
|
@ -419,7 +415,14 @@
|
|||
<option name="project" value="LOCAL" />
|
||||
<updated>1739284937312</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="438" />
|
||||
<task id="LOCAL-00438" summary="11/02/2025 - 21h">
|
||||
<created>1739302914543</created>
|
||||
<option name="number" value="00438" />
|
||||
<option name="presentableId" value="LOCAL-00438" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1739302914543</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="439" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="Vcs.Log.Tabs.Properties">
|
||||
|
@ -461,7 +464,6 @@
|
|||
</option>
|
||||
</component>
|
||||
<component name="VcsManagerConfiguration">
|
||||
<MESSAGE value="qsd" />
|
||||
<MESSAGE value="22/11/2024 - 18h" />
|
||||
<MESSAGE value="27/11/2024 : 12h30" />
|
||||
<MESSAGE value="08/12/2024 - 12h" />
|
||||
|
@ -486,6 +488,7 @@
|
|||
<MESSAGE value="08/02/205 - 22h30" />
|
||||
<MESSAGE value="10/02/205 - 21h" />
|
||||
<MESSAGE value="11/02/2025 - 15h30" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="11/02/2025 - 15h30" />
|
||||
<MESSAGE value="11/02/2025 - 21h" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="11/02/2025 - 21h" />
|
||||
</component>
|
||||
</project>
|
23
Job_Cron.py
23
Job_Cron.py
|
@ -1120,3 +1120,26 @@ def Invoice_Data_From_Tab(diction):
|
|||
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, str(inspect.stack()[0][3]) + " -" + str(e) + " - Line : " + str(exc_tb.tb_lineno)
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Ce cron permet d'envoyer les documents automatique qui sont paramettrés dans la collection : "base_document_automatic_setup".
|
||||
Dans cette collection
|
||||
|
||||
Alogorithme :
|
||||
|
||||
|
||||
1 - On va aller directement dans le collection 'session_formation' recuperer toutes les session ayant : {'automatic_traitement.actif':'1'}
|
||||
|
||||
2 - Pour chacune des line retournées, on va faire le calcul manuellement (on pas un nombre gigantesque de session, ca peut donc passer pendant
|
||||
qqtps, deplus ce sont des traitement noctures, donc ca devrait aller.
|
||||
=> Pour chaque ligne (type document pr une session), on va faire le calcul :
|
||||
- si start_date session = Date Today + nb_jour_action, alors il faut lancer l'edition des documents.
|
||||
A la fin, ne surtout pas oublié de mettre à jour la ligne "session_formation.automatic_traitement" avec les info :
|
||||
- actif = -1
|
||||
- date_traitement = date du jour
|
||||
- statut traitement :
|
||||
- commentaire : combien de document envoyé.
|
||||
|
||||
"""
|
6323
Log/log_file.log
6323
Log/log_file.log
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,354 @@
|
|||
"""
|
||||
Ce document calqué sur la collection : base_document_automatic_setup
|
||||
permet de gerer le paramettrage de l'envoi automatique des documents.
|
||||
par exemple :
|
||||
- les Convocations doivent etre envoyées 7 jours avant le début de la session
|
||||
|
||||
/!\ principe d'utilisation :
|
||||
Il y aura un paramettrage par société qui va s'appliquer à tous les documents de la societe.
|
||||
Ce paramettrage sera dubliqué sur chaque instance du document.
|
||||
|
||||
En suite, l'utilisation pourra décider de modifier exceptionnellement le paramettrage d'une instance du document.
|
||||
|
||||
C'est le meme principe que la gestion de la relance des devis
|
||||
"""
|
||||
from base64 import b64encode
|
||||
|
||||
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
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Ajout ou mise à jour d'un paramettrage
|
||||
les champs :
|
||||
- courrier_template_type_document_id : Id du type de document
|
||||
- nb_jour_action : definit le nombre de avant ou après action (-5 = faire l'action 5 jours avant ..., +2 = faire l'action 2 après ...)
|
||||
- action_target_date : Définit la date cible. exemple (start_session = Debut de la session, end_session = fin de la session, etc)
|
||||
- collection_target : Définit la collection concernéer ( exe : session_formation)
|
||||
|
||||
/!\ : Pour un début on va rester sur des actions autours de sessions de formation
|
||||
|
||||
/!\ : Pour eviter les ecart de date trop long, une traitement automatique se trouver dans un intervalle de
|
||||
+/- 30 jours avant ou après la session.
|
||||
|
||||
|
||||
"""
|
||||
def Add_Update_base_document_automatic_setup(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', '_id', 'courrier_template_type_document_id', 'nb_jour_action', 'action_target_date',
|
||||
'collection_target', 'actif']
|
||||
|
||||
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', '_id', 'courrier_template_type_document_id', 'nb_jour_action', 'action_target_date',
|
||||
'collection_target', 'actif']
|
||||
|
||||
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
|
||||
|
||||
my_id = diction['_id']
|
||||
my_token = diction['token']
|
||||
|
||||
"""
|
||||
verifier que le courrier_template_type_document_id existe et est valide
|
||||
"""
|
||||
is_valide_courrier_template_type_document_id_count = MYSY_GV.dbname['courrier_template_type_document'].count_documents({'_id':ObjectId(str(diction['courrier_template_type_document_id'])),
|
||||
'valide':'1', 'locked':'0'})
|
||||
|
||||
if(is_valide_courrier_template_type_document_id_count != 1 ):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " L'identifiant du courrier_template_type_document_id est invalide ")
|
||||
return False, " L'identifiant du courrier_template_type_document_id est invalide "
|
||||
|
||||
is_valide_courrier_template_type_document_id_data = MYSY_GV.dbname[
|
||||
'courrier_template_type_document'].find_one(
|
||||
{'_id': ObjectId(str(diction['courrier_template_type_document_id'])),
|
||||
'valide': '1', 'locked': '0'})
|
||||
|
||||
|
||||
local_status, local_retval = mycommon.IsInt(str(diction['nb_jour_action']))
|
||||
if (local_status is False):
|
||||
mycommon.myprint(str(
|
||||
inspect.stack()[0][
|
||||
3]) + " Le nombre de jours est invalide ")
|
||||
return False, " Le nombre de jours est invalide "
|
||||
|
||||
|
||||
del diction['_id']
|
||||
del diction['token']
|
||||
|
||||
nom_document = ""
|
||||
if( "nom" in is_valide_courrier_template_type_document_id_data.keys() ):
|
||||
nom_document = is_valide_courrier_template_type_document_id_data['nom']
|
||||
|
||||
diction['nom_document'] =nom_document
|
||||
|
||||
if (my_id):
|
||||
diction['date_update'] = str(datetime.now())
|
||||
diction['update_by'] = str(my_partner['_id'])
|
||||
result = MYSY_GV.dbname['base_document_automatic_setup'].find_one_and_update(
|
||||
{'_id': ObjectId(str(my_id)),
|
||||
'partner_owner_recid': str(my_partner['recid'])},
|
||||
{"$set": diction},
|
||||
upsert=True,
|
||||
return_document=ReturnDocument.AFTER
|
||||
)
|
||||
|
||||
if (result is None or "_id" not in result.keys()):
|
||||
mycommon.myprint(
|
||||
" Impossible d'ajouter ou mettre à jour la configuration du catalogue public (2) ")
|
||||
return False, " Impossible d'ajouter ou mettre à jour la configuration du catalogue public (2) "
|
||||
|
||||
return True, " La configuration a été correctement mise à jour"
|
||||
|
||||
else:
|
||||
|
||||
diction['valide'] = "1"
|
||||
diction['locked'] = "0"
|
||||
diction['partner_owner_recid'] = str(my_partner['recid'])
|
||||
diction['date_update'] = str(datetime.now())
|
||||
diction['date_created'] = str(datetime.now())
|
||||
diction['update_by'] = str(my_partner['_id'])
|
||||
|
||||
result = MYSY_GV.dbname['base_document_automatic_setup'].insert_one(diction)
|
||||
|
||||
return True, " La configuration du catalogue a été correctement ajoutée"
|
||||
|
||||
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'ajouter ou mettre à jour la configuration du document "
|
||||
|
||||
|
||||
"""
|
||||
Recuperation de la liste des documents parametrés pour un partenaire donné
|
||||
"""
|
||||
def Get_List_base_document_automatic_setup(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', ]
|
||||
|
||||
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'existe pas")
|
||||
return False, " Les informations fournies sont incorrectes",
|
||||
|
||||
"""
|
||||
Verification des champs obligatoires
|
||||
"""
|
||||
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, " 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
|
||||
|
||||
"""
|
||||
Clés de mise à jour
|
||||
"""
|
||||
data_cle = {}
|
||||
data_cle['partner_owner_recid'] = my_partner['recid']
|
||||
data_cle['valide'] = "1"
|
||||
data_cle['locked'] = "0"
|
||||
|
||||
|
||||
RetObject = []
|
||||
val_tmp = 0
|
||||
|
||||
for retval in MYSY_GV.dbname['base_document_automatic_setup'].find(data_cle).sort([("_id", pymongo.DESCENDING), ]):
|
||||
user = retval
|
||||
user['id'] = str(val_tmp)
|
||||
val_tmp = val_tmp + 1
|
||||
|
||||
# Recuperation des données du courrier_template_type_document
|
||||
document_ref_interne = ""
|
||||
document_type_doc = ""
|
||||
document_type_nom = ""
|
||||
if( "courrier_template_type_document_id" in user.keys()):
|
||||
courrier_template_type_document_data = MYSY_GV.dbname['courrier_template_type_document'].find_one({'_id':ObjectId(str(user['courrier_template_type_document_id'])),
|
||||
'valide':'1', 'locked':'0'})
|
||||
|
||||
if( courrier_template_type_document_data and "ref_interne" in courrier_template_type_document_data.keys() ):
|
||||
document_ref_interne = courrier_template_type_document_data["ref_interne"]
|
||||
|
||||
if (courrier_template_type_document_data and "type_doc" in courrier_template_type_document_data.keys()):
|
||||
document_type_doc = courrier_template_type_document_data["type_doc"]
|
||||
|
||||
if ( courrier_template_type_document_data and "nom" in courrier_template_type_document_data.keys()):
|
||||
document_type_nom = courrier_template_type_document_data["nom"]
|
||||
|
||||
user['document_ref_interne'] = document_ref_interne
|
||||
user['document_type_doc'] = document_type_doc
|
||||
user['document_type_nom'] = document_type_nom
|
||||
|
||||
|
||||
|
||||
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 thèmes "
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Recuperation des données d'un base_document_automatic_setup donné
|
||||
"""
|
||||
|
||||
def Get_Given_base_document_automatic_setup(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', '_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'existe pas")
|
||||
return False, " Les informations fournies sont incorrectes",
|
||||
|
||||
"""
|
||||
Verification des champs obligatoires
|
||||
"""
|
||||
field_list_obligatoire = ['token', '_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']
|
||||
|
||||
local_status, my_partner = mycommon.Check_Connexion_And_Return_Partner_Data(diction)
|
||||
if (local_status is not True):
|
||||
return local_status, my_partner
|
||||
|
||||
"""
|
||||
Clés de mise à jour
|
||||
"""
|
||||
data_cle = {}
|
||||
data_cle['partner_owner_recid'] = my_partner['recid']
|
||||
data_cle['valide'] = "1"
|
||||
data_cle['locked'] = "0"
|
||||
data_cle['_id'] = ObjectId(str(diction['_id']))
|
||||
|
||||
RetObject = []
|
||||
val_tmp = 0
|
||||
|
||||
for retval in MYSY_GV.dbname['base_document_automatic_setup'].find(data_cle).sort(
|
||||
[("_id", pymongo.DESCENDING), ]):
|
||||
user = retval
|
||||
user['id'] = str(val_tmp)
|
||||
val_tmp = val_tmp + 1
|
||||
|
||||
# Recuperation des données du courrier_template_type_document
|
||||
document_ref_interne = ""
|
||||
document_type_doc = ""
|
||||
document_type_nom = ""
|
||||
if ("courrier_template_type_document_id" in user.keys()):
|
||||
courrier_template_type_document_data = MYSY_GV.dbname['courrier_template_type_document'].find_one(
|
||||
{'_id': ObjectId(str(user['courrier_template_type_document_id'])),
|
||||
'valide': '1', 'locked': '0'})
|
||||
|
||||
if (courrier_template_type_document_data and "ref_interne" in courrier_template_type_document_data.keys()):
|
||||
document_ref_interne = courrier_template_type_document_data["ref_interne"]
|
||||
|
||||
if (courrier_template_type_document_data and "type_doc" in courrier_template_type_document_data.keys()):
|
||||
document_type_doc = courrier_template_type_document_data["type_doc"]
|
||||
|
||||
if (courrier_template_type_document_data and "nom" in courrier_template_type_document_data.keys()):
|
||||
document_type_nom = courrier_template_type_document_data["nom"]
|
||||
|
||||
user['document_ref_interne'] = document_ref_interne
|
||||
user['document_type_doc'] = document_type_doc
|
||||
user['document_type_nom'] = document_type_nom
|
||||
|
||||
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 thèmes "
|
|
@ -176,11 +176,9 @@ def Add_Update_Partner_Catalog_Pub_Config(diction):
|
|||
diction['date_update'] = str(datetime.now())
|
||||
diction['update_by'] = str(my_partner['_id'])
|
||||
|
||||
|
||||
|
||||
result = MYSY_GV.dbname['config_partner_catalog'].insert_one(diction)
|
||||
|
||||
return True, " La configuration du catalogue a été correctement mis à jour"
|
||||
return True, " La configuration du catalogue a été correctement mise à jour"
|
||||
|
||||
except Exception as e:
|
||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||
|
|
51
main.py
51
main.py
|
@ -95,6 +95,9 @@ import suivi_pedagogique_mgt as suivi_pedagogique_mgt
|
|||
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 base_document_automatic_setup as base_document_automatic_setup
|
||||
|
||||
import Dashbord_queries.BPF as BPF
|
||||
import type_cours as type_cours
|
||||
|
||||
|
@ -6333,7 +6336,7 @@ API qui permet d'ajouter un document personnalisable
|
|||
def Add_Partner_Document():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Add_Partner_Document payload = ",payload)
|
||||
print(" ### Add_Partner_Document payload (troop long cherif= ")
|
||||
status, retval = partner_document_mgt.Add_Partner_Document(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
@ -11881,6 +11884,9 @@ def Conformite_Article_Blog_Demo():
|
|||
return jsonify(status=localStatus, message=message )
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@app.route('/myclass/api/Conformite_Article_Blog_Prod/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Conformite_Article_Blog_Prod():
|
||||
|
@ -11891,6 +11897,49 @@ def Conformite_Article_Blog_Prod():
|
|||
return jsonify(status=localStatus, message=message )
|
||||
|
||||
|
||||
"""
|
||||
API pour créer ou mettre à jour la configuration d'envoi automatique d'un type de document
|
||||
"""
|
||||
@app.route('/myclass/api/Add_Update_base_document_automatic_setup/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Add_Update_base_document_automatic_setup():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Add_Update_base_document_automatic_setup : payload = ",payload)
|
||||
localStatus, message= base_document_automatic_setup.Add_Update_base_document_automatic_setup(payload)
|
||||
return jsonify(status=localStatus, message=message )
|
||||
|
||||
|
||||
"""
|
||||
API pour recuperer la liste des configurations d'envoi automatique d'un type de document
|
||||
pour un partenaire
|
||||
"""
|
||||
@app.route('/myclass/api/Get_List_base_document_automatic_setup/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Get_List_base_document_automatic_setup():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Get_List_base_document_automatic_setup : payload = ",payload)
|
||||
localStatus, message= base_document_automatic_setup.Get_List_base_document_automatic_setup(payload)
|
||||
return jsonify(status=localStatus, message=message )
|
||||
|
||||
|
||||
|
||||
"""
|
||||
API pour recuperer les données d'une configuration d'envoi automatique d'un type de document donné
|
||||
"""
|
||||
@app.route('/myclass/api/Get_Given_base_document_automatic_setup/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Get_Given_base_document_automatic_setup():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Get_Given_base_document_automatic_setup : payload = ",payload)
|
||||
localStatus, message= base_document_automatic_setup.Get_Given_base_document_automatic_setup(payload)
|
||||
return jsonify(status=localStatus, message=message )
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
print(" debut api")
|
||||
context = SSL.Context(SSL.SSLv23_METHOD)
|
||||
|
|
|
@ -872,119 +872,23 @@ def mysylmsdb():
|
|||
return False, " Connexion mariadb KOOO"
|
||||
|
||||
|
||||
from datetime import timedelta
|
||||
|
||||
def test_web_service(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = [ 'token', 'session_id', ]
|
||||
C1_pipe_qry = ([
|
||||
{'$match': {'$and': [ {'valide':'1'}, {'automatic_traitement.actif':'1'},
|
||||
|
||||
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', 'session_id', ]
|
||||
for retval in MYSY_GV.dbname['session_formation'].aggregate(C1_pipe_qry) :
|
||||
print( " ### retval == ", retval)
|
||||
|
||||
|
||||
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"
|
||||
|
||||
local_status, my_partner = mycommon.Check_Connexion_And_Return_Partner_Data(diction)
|
||||
if (local_status is not True):
|
||||
return local_status, my_partner
|
||||
|
||||
|
||||
# 1 - Recuperer la liste des participants
|
||||
List_participant = []
|
||||
for tmp in MYSY_GV.dbname['inscription'].find({'session_id':diction['session_id'], 'status':'1'},{'_id':1, 'email':1}):
|
||||
node = {}
|
||||
node['_id'] = str(tmp['_id'])
|
||||
node['email'] = str(tmp['email'])
|
||||
List_participant.append(node)
|
||||
|
||||
|
||||
|
||||
# 2 - Liste des documents traqués
|
||||
List_Document_a_Traquer = []
|
||||
for tmp in MYSY_GV.dbname['courrier_template_tracking'].find({'partner_owner_recid':str(my_partner['recid']),
|
||||
'valide':'1', 'locked':'0'},
|
||||
{'_id':1, 'courrier_template_type_document_id':1,
|
||||
'courrier_template_type_document_ref_interne':1, 'rang':1}).sort([("rang", pymongo.ASCENDING)]):
|
||||
node = {}
|
||||
node['_id'] = str(tmp['_id'])
|
||||
node['courrier_template_type_document_id'] = str(tmp['courrier_template_type_document_id'])
|
||||
node['courrier_template_type_document_ref_interne'] = str(tmp['courrier_template_type_document_ref_interne'])
|
||||
node['rang'] = str(tmp['rang'])
|
||||
List_Document_a_Traquer.append(node)
|
||||
|
||||
print(" LISTE des PARTIPANTS")
|
||||
for val in List_participant:
|
||||
print("Participant : "+str(val))
|
||||
|
||||
print(" LISTE des DOCUMENT A TRAQUER")
|
||||
for val in List_Document_a_Traquer:
|
||||
print("Document a traquer "+str(val))
|
||||
|
||||
"""
|
||||
Si pour chaque type de document a traquer, tous les partipants sont dans history, alors on mais ok
|
||||
si aucun, on met ko,
|
||||
si au moins 1, on met : partiel
|
||||
la clé est : courrier_template_tracking.courrier_template_type_document_ref_interne
|
||||
|
||||
-- clé de recherhce : document a traquer (courrier_template_tracking._id) et inscription_id
|
||||
"""
|
||||
|
||||
|
||||
|
||||
for doc_a_tracker in List_Document_a_Traquer:
|
||||
print("TRAITEMENT DU DOCUMENT " + str(doc_a_tracker['courrier_template_type_document_ref_interne'])+" - _id = "+ str(doc_a_tracker['_id']))
|
||||
local_nb_inscrit = 0
|
||||
local_nb_has_history_tracking = 0
|
||||
local_status = "Aucun"
|
||||
|
||||
for val in List_participant:
|
||||
#print("Participant zzz: " + str(val))
|
||||
print(" cle de recherche : courrier_template_tracking_id = ",str(doc_a_tracker['_id']), " / target_collection_recid = "+str(val['_id']) )
|
||||
local_nb_inscrit = local_nb_inscrit + 1
|
||||
local_qry = {'partner_owner_recid':str(my_partner['recid']),
|
||||
'valide':'1', 'locked':'0', 'target_collection_recid':str(val['_id']),
|
||||
'courrier_template_tracking_id':str(doc_a_tracker['_id'])}
|
||||
|
||||
is_tracking_history = MYSY_GV.dbname['courrier_template_tracking_history'].count_documents(local_qry)
|
||||
if( is_tracking_history > 0 ):
|
||||
local_nb_has_history_tracking = local_nb_has_history_tracking + 1
|
||||
|
||||
print("local_qry : " + str(local_qry))
|
||||
print(" Pour le document a traquer : ", doc_a_tracker['courrier_template_type_document_ref_interne'])
|
||||
print("local_nb_inscrit VS local_nb_has_history_tracking: " + str(local_nb_inscrit)+" VS "+str(local_nb_has_history_tracking))
|
||||
if( local_nb_inscrit == local_nb_has_history_tracking and local_nb_has_history_tracking == 0 ):
|
||||
local_status = "Aucun"
|
||||
|
||||
if( local_nb_inscrit == local_nb_has_history_tracking and local_nb_has_history_tracking != 0 ):
|
||||
local_status = "Complet"
|
||||
|
||||
if (local_nb_inscrit > local_nb_has_history_tracking and local_nb_has_history_tracking > 0):
|
||||
local_status = "Partiel"
|
||||
|
||||
doc_a_tracker['global_status'] = str(local_status)
|
||||
|
||||
print(" Statut : ", local_status)
|
||||
|
||||
print(" END LISTE des DOCUMENT A TRAQUER WITH STATUS ")
|
||||
for val in List_Document_a_Traquer:
|
||||
print("Document a traquer " + str(val['courrier_template_type_document_ref_interne'])+" STATUS = "+ str(val['global_status']) )
|
||||
|
||||
return True, "Test WebService OK Diction "
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue