24/01/2024 -12h00
parent
d95c28c89e
commit
f4db24a458
|
@ -1,32 +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="21/01/2024 -18h30">
|
||||
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="22/01/2024 -22h00">
|
||||
<change afterPath="$PROJECT_DIR$/__init__.py" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/module_editique.py" afterDir="false" />
|
||||
<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$/lms_chamilo/mysy_lms.py" beforeDir="false" afterPath="$PROJECT_DIR$/lms_chamilo/mysy_lms.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/prj_common.py" beforeDir="false" afterPath="$PROJECT_DIR$/prj_common.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/temp_direct/6hiIO7wJaXj2eLziy9Lry4DDtmLJAlCA.xlsx" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/temp_direct/Part_Order_Devis_1.pdf" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/temp_direct/Part_Order_Order_26.pdf" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/temp_direct/Partner_Invoice_Invoice_6.pdf" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/temp_direct/Partner_Order_Order_26.pdf" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/temp_direct/Partner_Order_Order_27.pdf" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/temp_direct/Partner_Order_Order_42.pdf" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/temp_direct/WCQlrZZnorlwo5CibI5lH6Uyo87dXeEAQ.xlsx" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/temp_direct/WtYvQ8XkpiW0gQBhE0jmfRotrGBuNlyYpQ.xlsx" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/temp_direct/YdTiV5IUJU8Tf5JJCITl5fUAXheJXhWRA.xlsx" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/temp_direct/invoice_FACT_236000270.pdf" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/temp_direct/invoice_FACT_236000271.pdf" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/temp_direct/invoice_FACT_236000272.pdf" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/temp_direct/invoice_FACT_236000273.pdf" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/temp_direct/invoice_FACT_237000313.pdf" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/temp_direct/nwIs5pmCWNrdJqyQny11Pu6zV0TR77QA.xlsx" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/temp_direct/uYbhzQgoZXTmghSCJtPAzDiu13Z1mcpw.xlsx" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/temp_direct/xcn5ILu7ok3Ah7gCDkD1cy4UiyHntOg.xlsx" beforeDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
|
@ -96,13 +77,6 @@
|
|||
<option name="presentableId" value="Default" />
|
||||
<updated>1680804787304</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00151" summary="15/11/2023 - 21h">
|
||||
<created>1700080381522</created>
|
||||
<option name="number" value="00151" />
|
||||
<option name="presentableId" value="LOCAL-00151" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1700080381523</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00152" summary="17/11/2023 - 16h">
|
||||
<created>1700233488529</created>
|
||||
<option name="number" value="00152" />
|
||||
|
@ -439,7 +413,14 @@
|
|||
<option name="project" value="LOCAL" />
|
||||
<updated>1705859319077</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="200" />
|
||||
<task id="LOCAL-00200" summary="22/01/2024 -22h00">
|
||||
<created>1705957023841</created>
|
||||
<option name="number" value="00200" />
|
||||
<option name="presentableId" value="LOCAL-00200" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1705957023842</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="201" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="Vcs.Log.Tabs.Properties">
|
||||
|
@ -454,7 +435,6 @@
|
|||
</option>
|
||||
</component>
|
||||
<component name="VcsManagerConfiguration">
|
||||
<MESSAGE value="15/12/2023 - 18h" />
|
||||
<MESSAGE value="16/12/2023 - 23h12" />
|
||||
<MESSAGE value="18/12/2023 - 18:00" />
|
||||
<MESSAGE value="18/12/2023 - 22:00" />
|
||||
|
@ -479,6 +459,7 @@
|
|||
<MESSAGE value="16/01/2024 - 19h" />
|
||||
<MESSAGE value="19/01/2024 - 16h" />
|
||||
<MESSAGE value="21/01/2024 -18h30" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="21/01/2024 -18h30" />
|
||||
<MESSAGE value="22/01/2024 -22h00" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="22/01/2024 -22h00" />
|
||||
</component>
|
||||
</project>
|
|
@ -6711,6 +6711,99 @@ def Get_List_Conventions_Stagiaire(diction):
|
|||
return False, " Impossible de récupérer la liste des conventions"
|
||||
|
||||
|
||||
"""
|
||||
Cette fonction recupere les differentes types de convention de stagiaire avec des option comme :
|
||||
- ref_interne
|
||||
- nom
|
||||
- type_doc
|
||||
|
||||
On accepte plusieurs versions du meme doc
|
||||
"""
|
||||
|
||||
def Get_List_Conventions_Stagiaire_With_Filter(diction):
|
||||
try:
|
||||
|
||||
field_list = ['token', 'ref_interne','nom', 'type_doc' ]
|
||||
|
||||
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, "Le champ '" + val + "' n'est pas autorisé"
|
||||
|
||||
|
||||
|
||||
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
|
||||
|
||||
|
||||
# Recuperation des option de filter
|
||||
filt_type_doc = {}
|
||||
if ("type_doc" in diction.keys()):
|
||||
filt_type_doc = {'type_doc': str(diction['type_doc'])}
|
||||
|
||||
filt_nom = {}
|
||||
if ("nom" in diction.keys()):
|
||||
filt_nom = {'nom': str(diction['nom'])}
|
||||
|
||||
filt_ref_interne = {}
|
||||
if ("ref_interne" in diction.keys()):
|
||||
filt_ref_interne = {'ref_interne': str(diction['ref_interne'])}
|
||||
|
||||
|
||||
RetObject = []
|
||||
val_tmp = 0
|
||||
|
||||
"""
|
||||
# Recuperation des documents (collection : courrier_template) de ce partenaire avec 'ref_interne' = 'CONVENTION_STAGIAIRE'
|
||||
1 - On regarde le partenaire à des conventions qui sont personnalisées, si non
|
||||
2 - On va sortir les conventions par defaut de MySy.
|
||||
|
||||
/!\ : On ne melange pas les 2. c'est l'un ou l'autre
|
||||
"""
|
||||
|
||||
|
||||
for retval in MYSY_GV.dbname['courrier_template'].find({'$and': [{'ref_interne': 'CONVENTION_STAGIAIRE',
|
||||
'valide': '1',
|
||||
'locked': '0',
|
||||
'partner_owner_recid': str(my_partner['recid'])}, filt_type_doc, filt_nom, filt_ref_interne ]}):
|
||||
user = retval
|
||||
val_tmp = val_tmp + 1
|
||||
RetObject.append(mycommon.JSONEncoder().encode(user))
|
||||
|
||||
# Si aucune convention personnalisée, on va chercher les conventions mysy
|
||||
if (val_tmp == 0):
|
||||
for retval in MYSY_GV.dbname['courrier_template'].find({'$and': [{'ref_interne': 'CONVENTION_STAGIAIRE',
|
||||
'valide': '1',
|
||||
'locked': '0',
|
||||
'partner_owner_recid': 'default'}, filt_type_doc, filt_nom, filt_ref_interne ]}):
|
||||
user = retval
|
||||
val_tmp = val_tmp + 1
|
||||
RetObject.append(mycommon.JSONEncoder().encode(user))
|
||||
|
||||
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 conventions"
|
||||
|
||||
|
||||
"""
|
||||
Recuperatin des convention SEULEMENT Individuelles
|
||||
|
|
1794
Log/log_file.log
1794
Log/log_file.log
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,2 @@
|
|||
# Define a package-level variable
|
||||
__version__ = '0.0.5'
|
84
main.py
84
main.py
|
@ -72,6 +72,8 @@ import Dashbord_queries.inscription_tdb_qries as inscription_tdb_qries
|
|||
import Collection_Historique as Collection_Historique
|
||||
import purchase_prices as purchase_prices
|
||||
import apprenant_mgt as apprenant_mgt
|
||||
import module_editique as module_editique
|
||||
|
||||
|
||||
app = Flask(__name__)
|
||||
cors = CORS(app, resources={r"/foo": {"origins": "*"}})
|
||||
|
@ -4340,6 +4342,25 @@ def Get_List_Conventions_Stagiaire():
|
|||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
"""
|
||||
API qui permet de recuperer la liste des convention stagiaires avec des options
|
||||
comme :
|
||||
- ref_interne
|
||||
- nom
|
||||
- type_doc
|
||||
"""
|
||||
@app.route('/myclass/api/Get_List_Conventions_Stagiaire_With_Filter/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Get_List_Conventions_Stagiaire_With_Filter():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Get_List_Conventions_Stagiaire_With_Filter payload = ",payload)
|
||||
status, retval = inscription.Get_List_Conventions_Stagiaire_With_Filter(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
|
||||
|
||||
"""
|
||||
API pour recuperer seulement les conventions INDIVIDUELLES
|
||||
"""
|
||||
|
@ -7206,6 +7227,69 @@ def Lock_partner_account():
|
|||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
"""
|
||||
Cette API retourne * la liste de documents editable par une
|
||||
- un partner
|
||||
"""
|
||||
@app.route('/myclass/api/Get_Editable_Document_By_Partner/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Get_Editable_Document_By_Partner():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Get_Editable_Document_By_Partner payload = ",payload)
|
||||
print(request.files)
|
||||
status, retval = module_editique.Get_Editable_Document_By_Partner(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
"""
|
||||
Cette API retourne retourne la liste de documents editable par une
|
||||
- un partner
|
||||
- une collection (ex : session_formation).
|
||||
|
||||
important : ici on recuperer juste la liste des document tracké, pas l'historique de traitement
|
||||
"""
|
||||
@app.route('/myclass/api/Get_Editable_Document_By_Partner_By_Collection/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Get_Editable_Document_By_Partner_By_Collection():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Get_Editable_Document_By_Partner_By_Collection payload = ",payload)
|
||||
print(request.files)
|
||||
status, retval = module_editique.Get_Editable_Document_By_Partner_By_Collection(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
"""
|
||||
Cette API retourne l'HISTORIQUE des telechargements et envois de mail
|
||||
des documents tracés, pour :
|
||||
- un partner (Obligatoire)
|
||||
- un related_collection_recid (Obligatoire) (ex : l'_id de la session)
|
||||
"""
|
||||
@app.route('/myclass/api/Get_Editable_History_Document_By_Partner_By_Collection/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Get_Editable_History_Document_By_Partner_By_Collection():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Get_Editable_Document_By_Partner_By_Collection payload = ",payload)
|
||||
print(request.files)
|
||||
status, retval = module_editique.Get_Editable_History_Document_By_Partner_By_Collection(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
|
||||
"""
|
||||
API des test des actions server
|
||||
"""
|
||||
@app.route('/myclass/api/Action_Server_send_convention_entreprise_mail/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Action_Server_send_convention_entreprise_mail():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Action_Server_send_convention_entreprise_mail payload = ",payload)
|
||||
|
||||
return jsonify(status=True, message=" OK Action_Server_send_convention_entreprise_mail")
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
print(" debut api")
|
||||
|
|
|
@ -0,0 +1,543 @@
|
|||
"""
|
||||
Ce fichier traite de tous les sujets concenant l'editique
|
||||
C'est a dire :
|
||||
- Quel document à imprimer
|
||||
- Quand il a été imprimé ou téléchargé, et
|
||||
"""
|
||||
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 retourne la liste de documents editable par une
|
||||
- un partner
|
||||
"""
|
||||
def Get_Editable_Document_By_Partner(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'est pas autorisé")
|
||||
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
|
||||
|
||||
RetObject = []
|
||||
val_tmp = 0
|
||||
|
||||
qry_match = {"partner_owner_recid":str(my_partner['recid']), 'valide':'1', 'locked':'0'}
|
||||
|
||||
pipe_qry = ([
|
||||
{'$match': qry_match},
|
||||
{'$sort': {'_id': -1}},
|
||||
{'$lookup': {
|
||||
'from': 'courrier_template',
|
||||
"let": {'courrier_template_id': "$courrier_template_id", 'partner_owner_recid': '$partner_owner_recid'},
|
||||
'pipeline': [
|
||||
{'$match':
|
||||
{'$expr':
|
||||
{'$and':
|
||||
[
|
||||
|
||||
{'$eq': ["$_id", {'$convert': {
|
||||
'input': "$$courrier_template_id",
|
||||
'to': "objectId",
|
||||
'onError': {'error': 'true'},
|
||||
'onNull': {'isnull': 'true'}
|
||||
}}]},
|
||||
|
||||
{'$eq': ["$valide", "1"]},
|
||||
{'$eq': ["$partner_owner_recid", '$$partner_owner_recid']}
|
||||
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
{'$project': {'contenu_doc': 0, 'corps_mail': 0}},
|
||||
],
|
||||
'as': 'collection_courrier_template'
|
||||
}
|
||||
},
|
||||
{
|
||||
'$unwind': '$collection_courrier_template'
|
||||
}
|
||||
])
|
||||
|
||||
print(" #### Get_Editable_Document_By_Partner pipe_qry_Get_Editable_Document_By_Partner = ", pipe_qry)
|
||||
|
||||
for New_retVal in MYSY_GV.dbname['courrier_template_tracking'].aggregate(pipe_qry):
|
||||
if( "collection_courrier_template" in New_retVal.keys() ):
|
||||
user = New_retVal
|
||||
user['id'] = str(val_tmp)
|
||||
val_tmp = val_tmp + 1
|
||||
RetObject.append(mycommon.JSONEncoder().encode(user))
|
||||
|
||||
|
||||
|
||||
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 la liste de documents editable par une
|
||||
- un partner
|
||||
- une collection (ex : session_formation).
|
||||
|
||||
important : ici on recuperer juste la liste des document tracké, pas l'historique de traitement
|
||||
"""
|
||||
|
||||
def Get_Editable_Document_By_Partner_By_Collection(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', 'related_collection', 'related_collection_recid']
|
||||
|
||||
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']
|
||||
|
||||
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',
|
||||
"let": {'courrier_template_id': "$courrier_template_id", 'partner_owner_recid': '$partner_owner_recid'},
|
||||
'pipeline': [
|
||||
{'$match':
|
||||
{'$expr':
|
||||
{'$and':
|
||||
[
|
||||
|
||||
{'$eq': ["$_id", {'$convert': {
|
||||
'input': "$$courrier_template_id",
|
||||
'to': "objectId",
|
||||
'onError': {'error': 'true'},
|
||||
'onNull': {'isnull': 'true'}
|
||||
}}]},
|
||||
|
||||
{'$eq': ["$valide", "1"]},
|
||||
{'$eq': ["$partner_owner_recid", '$$partner_owner_recid']}
|
||||
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
{'$project': {'contenu_doc': 0, 'corps_mail': 0}},
|
||||
],
|
||||
'as': 'collection_courrier_template'
|
||||
}
|
||||
},
|
||||
{
|
||||
'$unwind': '$collection_courrier_template'
|
||||
}
|
||||
])
|
||||
|
||||
print(" #### Get_Editable_Document_By_Partner_By_Collection pipe_qry_Get_Editable_Document_By_Partner = ", pipe_qry)
|
||||
|
||||
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'])
|
||||
|
||||
user['rang'] = "99999"
|
||||
if ('rang' in New_retVal.keys()):
|
||||
user['rang'] = str(New_retVal['rang'])
|
||||
|
||||
user['server_action_name'] = ""
|
||||
if ('server_action_name' in New_retVal.keys()):
|
||||
user['server_action_name'] = str(New_retVal['server_action_name'])
|
||||
|
||||
user['partner_owner_recid'] = ""
|
||||
if ('partner_owner_recid' in New_retVal.keys()):
|
||||
user['partner_owner_recid'] = str(New_retVal['partner_owner_recid'])
|
||||
|
||||
user['related_collection'] = ""
|
||||
if ('related_collection' in New_retVal.keys()):
|
||||
user['related_collection'] = str(New_retVal['related_collection'])
|
||||
|
||||
user['courrier_template_ref_interne'] = ""
|
||||
if ('courrier_template_ref_interne' in New_retVal.keys()):
|
||||
user['courrier_template_ref_interne'] = str(New_retVal['courrier_template_ref_interne'])
|
||||
|
||||
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'])
|
||||
|
||||
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'])
|
||||
|
||||
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)
|
||||
|
||||
if( is_document_has_history_event > 0 ):
|
||||
has_history_event = "1"
|
||||
|
||||
#print(" #### is_document_has_history_event RESULT = ", is_document_has_history_event)
|
||||
|
||||
user['has_history_event'] = has_history_event
|
||||
|
||||
val_tmp = val_tmp + 1
|
||||
RetObject.append(mycommon.JSONEncoder().encode(user))
|
||||
|
||||
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 :
|
||||
- un partner (Obligatoire)
|
||||
- un related_collection_recid (Obligatoire) (ex : l'_id de la session)
|
||||
|
||||
"""
|
||||
|
||||
def Get_Editable_History_Document_By_Partner_By_Collection(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', 'related_collection_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_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_id = ""
|
||||
if ("related_collection_id" in diction.keys()):
|
||||
if diction['related_collection_id']:
|
||||
related_collection_id = diction['related_collection_id']
|
||||
|
||||
if( str(related_collection_id).strip() == ""):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " L'Id de la collection est invalide ")
|
||||
return False, " L'Id 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_recid':str(related_collection_id)}
|
||||
|
||||
pipe_qry = ([
|
||||
{'$match': qry_match},
|
||||
{'$sort': {'_id': -1}},
|
||||
{'$lookup': {
|
||||
'from': 'courrier_template_tracking',
|
||||
"let": {'courrier_template_tracking_id': "$courrier_template_tracking_id",
|
||||
'partner_owner_recid': '$partner_owner_recid'},
|
||||
'pipeline': [
|
||||
{'$match':
|
||||
{'$expr':
|
||||
{'$and':
|
||||
[
|
||||
|
||||
{'$eq': ["$_id", {'$convert': {
|
||||
'input': "$$courrier_template_tracking_id",
|
||||
'to': "objectId",
|
||||
'onError': {'error': 'true'},
|
||||
'onNull': {'isnull': 'true'}
|
||||
}}]},
|
||||
|
||||
{'$eq': ["$valide", "1"]},
|
||||
{'$eq': ["$partner_owner_recid", '$$partner_owner_recid']}
|
||||
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
],
|
||||
'as': 'courrier_template_tracking'
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
'$unwind': '$courrier_template_tracking'
|
||||
},
|
||||
{'$lookup': {
|
||||
'from': 'courrier_template',
|
||||
"let": {'courrier_template_id': "$courrier_template_tracking.courrier_template_id", 'partner_owner_recid': '$partner_owner_recid'},
|
||||
'pipeline': [
|
||||
{'$match':
|
||||
{'$expr':
|
||||
{'$and':
|
||||
[
|
||||
|
||||
{'$eq': ["$_id", {'$convert': {
|
||||
'input': "$$courrier_template_id",
|
||||
'to': "objectId",
|
||||
'onError': {'error': 'true'},
|
||||
'onNull': {'isnull': 'true'}
|
||||
}}]},
|
||||
{'$eq': ["$valide", "1"]},
|
||||
{'$eq': ["$partner_owner_recid", '$$partner_owner_recid']}
|
||||
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{'$project': {'contenu_doc': 0, 'corps_mail': 0}},
|
||||
|
||||
],
|
||||
'as': 'courrier_template'
|
||||
}
|
||||
},
|
||||
{
|
||||
'$unwind': '$courrier_template'
|
||||
},
|
||||
])
|
||||
|
||||
print(" #### Get_Editable_Document_By_Partner pipe_qry_Get_Editable_Document_By_Partner = ", pipe_qry)
|
||||
|
||||
for New_retVal in MYSY_GV.dbname['courrier_template_tracking_history'].aggregate(pipe_qry):
|
||||
if ("courrier_template_tracking" in New_retVal.keys() and "courrier_template" in New_retVal.keys()):
|
||||
|
||||
user = {}
|
||||
user['_id'] = str(New_retVal['_id'])
|
||||
user['id'] = str(val_tmp)
|
||||
|
||||
user['related_collection_recid'] = ""
|
||||
if ('related_collection_recid' in New_retVal.keys()):
|
||||
user['related_collection_recid'] = str(New_retVal['related_collection_recid'])
|
||||
|
||||
user['courrier_template_tracking_id'] = ""
|
||||
if ('courrier_template_tracking_id' in New_retVal.keys()):
|
||||
user['courrier_template_tracking_id'] = str(New_retVal['courrier_template_tracking_id'])
|
||||
|
||||
user['date_update'] = ""
|
||||
if ('date_update' in New_retVal.keys()):
|
||||
user['date_update'] = str(New_retVal['date_update'])
|
||||
|
||||
user['update_by'] = ""
|
||||
if ('update_by' in New_retVal.keys()):
|
||||
user['update_by'] = str(New_retVal['update_by'])
|
||||
|
||||
|
||||
# Traitement de courrier_template_tracking
|
||||
user['courrier_template_id'] = ""
|
||||
if ('courrier_template_id' in New_retVal['courrier_template_tracking'].keys()):
|
||||
user['courrier_template_id'] = str(New_retVal['courrier_template_tracking']['courrier_template_id'])
|
||||
|
||||
user['related_collection'] = ""
|
||||
if ('related_collection' in New_retVal['courrier_template_tracking'].keys()):
|
||||
user['related_collection'] = str(New_retVal['courrier_template_tracking']['related_collection'])
|
||||
|
||||
user['server_action_name'] = ""
|
||||
if ('server_action_name' in New_retVal['courrier_template_tracking'].keys()):
|
||||
user['server_action_name'] = str(New_retVal['courrier_template_tracking']['server_action_name'])
|
||||
|
||||
user['courrier_template_ref_interne'] = ""
|
||||
if ('courrier_template_ref_interne' in New_retVal['courrier_template_tracking'].keys()):
|
||||
user['courrier_template_ref_interne'] = str(New_retVal['courrier_template_tracking']['courrier_template_ref_interne'])
|
||||
|
||||
user['rang'] = ""
|
||||
if ('rang' in New_retVal['courrier_template_tracking'].keys()):
|
||||
user['rang'] = str(New_retVal['courrier_template_tracking']['rang'])
|
||||
|
||||
# Traitement de courrier_template
|
||||
user['ref_interne'] = ""
|
||||
if ('ref_interne' in New_retVal['courrier_template'].keys()):
|
||||
user['ref_interne'] = str(New_retVal['courrier_template']['ref_interne'])
|
||||
|
||||
user['nom'] = ""
|
||||
if ('nom' in New_retVal['courrier_template'].keys()):
|
||||
user['nom'] = str(New_retVal['courrier_template']['nom'])
|
||||
|
||||
user['cible'] = ""
|
||||
if ('cible' in New_retVal['courrier_template'].keys()):
|
||||
user['cible'] = str(New_retVal['courrier_template']['cible'])
|
||||
|
||||
user['type_doc'] = ""
|
||||
if ('type_doc' in New_retVal['courrier_template'].keys()):
|
||||
user['cible'] = str(New_retVal['courrier_template']['type_doc'])
|
||||
|
||||
|
||||
|
||||
val_tmp = val_tmp + 1
|
||||
RetObject.append(mycommon.JSONEncoder().encode(user))
|
||||
|
||||
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 "
|
||||
|
Loading…
Reference in New Issue