01/09/23 - 19h
parent
69a99f1ecf
commit
eacd542b4f
|
@ -2,9 +2,13 @@
|
|||
<project version="4">
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="30/08/23 - 22h">
|
||||
<change afterPath="$PROJECT_DIR$/partner_document_mgt.py" afterDir="false" />
|
||||
<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$/ressources_materiels.py" beforeDir="false" afterPath="$PROJECT_DIR$/ressources_materiels.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" />
|
||||
|
|
|
@ -473,4 +473,10 @@ Dans le processus d'inscription, les statuts accepté sont :
|
|||
- 1 => Inscription (validée)
|
||||
- 2 => Encours (Inscription en cours de creation, ici, on ne declenche aucun email)
|
||||
"""
|
||||
INSCRIPTION_STATUS = ['-1', '0', '1', '2']
|
||||
INSCRIPTION_STATUS = ['-1', '0', '1', '2']
|
||||
|
||||
|
||||
"""
|
||||
Gestion de modele de courrier : Type de courrier autorisé
|
||||
"""
|
||||
MODELE_DOCUMENT_TYPE = ['sms', 'email', 'pdf']
|
|
@ -1789354,3 +1789354,97 @@ INFO:root:2023-08-31 19:54:04.453895 : Security check : IP adresse '127.0.0.1'
|
|||
INFO:werkzeug:127.0.0.1 - - [31/Aug/2023 19:54:04] "POST /myclass/api/Add_Update_SessionFormation_mass/ HTTP/1.1" 200 -
|
||||
INFO:root:2023-08-31 19:54:05.090157 : Security check : IP adresse '127.0.0.1' connected
|
||||
INFO:werkzeug:127.0.0.1 - - [31/Aug/2023 19:54:05] "POST /myclass/api/GetAllValideSessionFormation_List/ HTTP/1.1" 200 -
|
||||
INFO:root:2023-09-01 09:48:09.437973 : ++++ ENVIRONNEMENT DEVELOPPEMENT ++++
|
||||
INFO:root:2023-09-01 09:48:09.438976 : ++ DATABASE mongodb://localhost:27017/cherifdb_dev ++
|
||||
INFO:root:2023-09-01 09:48:09.438976 : ++ DBNAME Database(MongoClient(host=['localhost:27017'], document_class=dict, tz_aware=False, connect=True), 'cherifdb_dev') ++
|
||||
INFO:root:2023-09-01 09:48:09.438976 : ++ FLASK PORT 5001 ++
|
||||
INFO:root:2023-09-01 09:48:09.438976 : ++ LMS_BAS_URL mysy-training.com/ ++
|
||||
INFO:werkzeug:[31m[1mWARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.[0m
|
||||
* Running on http://localhost:5001
|
||||
INFO:werkzeug:[33mPress CTRL+C to quit[0m
|
||||
INFO:werkzeug: * Restarting with stat
|
||||
INFO:root:2023-09-01 09:48:19.332196 : ++++ ENVIRONNEMENT DEVELOPPEMENT ++++
|
||||
INFO:root:2023-09-01 09:48:19.332196 : ++ DATABASE mongodb://localhost:27017/cherifdb_dev ++
|
||||
INFO:root:2023-09-01 09:48:19.332196 : ++ DBNAME Database(MongoClient(host=['localhost:27017'], document_class=dict, tz_aware=False, connect=True), 'cherifdb_dev') ++
|
||||
INFO:root:2023-09-01 09:48:19.332196 : ++ FLASK PORT 5001 ++
|
||||
INFO:root:2023-09-01 09:48:19.332196 : ++ LMS_BAS_URL mysy-training.com/ ++
|
||||
WARNING:werkzeug: * Debugger is active!
|
||||
INFO:werkzeug: * Debugger PIN: 131-539-023
|
||||
INFO:root:2023-09-01 18:37:04.196252 : ++++ ENVIRONNEMENT DEVELOPPEMENT ++++
|
||||
INFO:root:2023-09-01 18:37:04.197272 : ++ DATABASE mongodb://localhost:27017/cherifdb_dev ++
|
||||
INFO:root:2023-09-01 18:37:04.197272 : ++ DBNAME Database(MongoClient(host=['localhost:27017'], document_class=dict, tz_aware=False, connect=True), 'cherifdb_dev') ++
|
||||
INFO:root:2023-09-01 18:37:04.197272 : ++ FLASK PORT 5001 ++
|
||||
INFO:root:2023-09-01 18:37:04.197272 : ++ LMS_BAS_URL mysy-training.com/ ++
|
||||
INFO:werkzeug:[31m[1mWARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.[0m
|
||||
* Running on http://localhost:5001
|
||||
INFO:werkzeug:[33mPress CTRL+C to quit[0m
|
||||
INFO:werkzeug: * Restarting with stat
|
||||
INFO:root:2023-09-01 18:37:13.820476 : ++++ ENVIRONNEMENT DEVELOPPEMENT ++++
|
||||
INFO:root:2023-09-01 18:37:13.820476 : ++ DATABASE mongodb://localhost:27017/cherifdb_dev ++
|
||||
INFO:root:2023-09-01 18:37:13.821481 : ++ DBNAME Database(MongoClient(host=['localhost:27017'], document_class=dict, tz_aware=False, connect=True), 'cherifdb_dev') ++
|
||||
INFO:root:2023-09-01 18:37:13.821481 : ++ FLASK PORT 5001 ++
|
||||
INFO:root:2023-09-01 18:37:13.821481 : ++ LMS_BAS_URL mysy-training.com/ ++
|
||||
WARNING:werkzeug: * Debugger is active!
|
||||
INFO:werkzeug: * Debugger PIN: 131-539-023
|
||||
INFO:root:2023-09-01 18:37:19.585780 : Security check : IP adresse '127.0.0.1' connected
|
||||
INFO:werkzeug:127.0.0.1 - - [01/Sep/2023 18:37:19] "[32mPOST /myclass/api/test_jnja2_database HTTP/1.1[0m" 308 -
|
||||
INFO:root:2023-09-01 18:37:19.592834 : Security check : IP adresse '127.0.0.1' connected
|
||||
INFO:root:2023-09-01 18:37:20.204427 : test_jnja2_database - Aucun template avec 'ref_interne':'test01'
|
||||
INFO:werkzeug:127.0.0.1 - - [01/Sep/2023 18:37:20] "POST /myclass/api/test_jnja2_database/ HTTP/1.1" 200 -
|
||||
INFO:werkzeug: * Detected change in 'C:\\Users\\billa\\Documents\\myclass.com\\Siteweb\\Production\\Ela_back\\Back_Office\\tools_cherif\\tools_cherif.py', reloading
|
||||
INFO:werkzeug: * Restarting with stat
|
||||
INFO:root:2023-09-01 18:37:56.148574 : ++++ ENVIRONNEMENT DEVELOPPEMENT ++++
|
||||
INFO:root:2023-09-01 18:37:56.148574 : ++ DATABASE mongodb://localhost:27017/cherifdb_dev ++
|
||||
INFO:root:2023-09-01 18:37:56.149576 : ++ DBNAME Database(MongoClient(host=['localhost:27017'], document_class=dict, tz_aware=False, connect=True), 'cherifdb_dev') ++
|
||||
INFO:root:2023-09-01 18:37:56.149576 : ++ FLASK PORT 5001 ++
|
||||
INFO:root:2023-09-01 18:37:56.149576 : ++ LMS_BAS_URL mysy-training.com/ ++
|
||||
WARNING:werkzeug: * Debugger is active!
|
||||
INFO:werkzeug: * Debugger PIN: 131-539-023
|
||||
INFO:root:2023-09-01 18:37:56.185528 : Security check : IP adresse '127.0.0.1' connected
|
||||
INFO:werkzeug:127.0.0.1 - - [01/Sep/2023 18:37:56] "[32mPOST /myclass/api/test_jnja2_database HTTP/1.1[0m" 308 -
|
||||
INFO:root:2023-09-01 18:37:56.193275 : Security check : IP adresse '127.0.0.1' connected
|
||||
INFO:root:2023-09-01 18:37:56.692223 : test_jnja2_database - Aucun template avec 'ref_interne':'test01'
|
||||
INFO:root:2023-09-01 18:37:56.693678 : test_jnja2_database -'NoneType' object has no attribute 'keys' - Line : 840
|
||||
INFO:werkzeug:127.0.0.1 - - [01/Sep/2023 18:37:56] "POST /myclass/api/test_jnja2_database/ HTTP/1.1" 200 -
|
||||
INFO:werkzeug: * Detected change in 'C:\\Users\\billa\\Documents\\myclass.com\\Siteweb\\Production\\Ela_back\\Back_Office\\tools_cherif\\tools_cherif.py', reloading
|
||||
INFO:werkzeug: * Restarting with stat
|
||||
INFO:root:2023-09-01 18:38:32.586131 : ++++ ENVIRONNEMENT DEVELOPPEMENT ++++
|
||||
INFO:root:2023-09-01 18:38:32.586131 : ++ DATABASE mongodb://localhost:27017/cherifdb_dev ++
|
||||
INFO:root:2023-09-01 18:38:32.586131 : ++ DBNAME Database(MongoClient(host=['localhost:27017'], document_class=dict, tz_aware=False, connect=True), 'cherifdb_dev') ++
|
||||
INFO:root:2023-09-01 18:38:32.586131 : ++ FLASK PORT 5001 ++
|
||||
INFO:root:2023-09-01 18:38:32.586131 : ++ LMS_BAS_URL mysy-training.com/ ++
|
||||
WARNING:werkzeug: * Debugger is active!
|
||||
INFO:werkzeug: * Debugger PIN: 131-539-023
|
||||
INFO:root:2023-09-01 18:38:32.622957 : Security check : IP adresse '127.0.0.1' connected
|
||||
INFO:werkzeug:127.0.0.1 - - [01/Sep/2023 18:38:32] "[32mPOST /myclass/api/test_jnja2_database HTTP/1.1[0m" 308 -
|
||||
INFO:root:2023-09-01 18:38:32.629960 : Security check : IP adresse '127.0.0.1' connected
|
||||
INFO:root:2023-09-01 18:38:33.179166 : test_jnja2_database - Aucun template avec 'ref_interne':'test01'
|
||||
INFO:werkzeug:127.0.0.1 - - [01/Sep/2023 18:38:33] "[35m[1mPOST /myclass/api/test_jnja2_database/ HTTP/1.1[0m" 500 -
|
||||
INFO:werkzeug: * Detected change in 'C:\\Users\\billa\\Documents\\myclass.com\\Siteweb\\Production\\Ela_back\\Back_Office\\tools_cherif\\tools_cherif.py', reloading
|
||||
INFO:werkzeug: * Restarting with stat
|
||||
INFO:root:2023-09-01 18:38:56.808477 : ++++ ENVIRONNEMENT DEVELOPPEMENT ++++
|
||||
INFO:root:2023-09-01 18:38:56.808477 : ++ DATABASE mongodb://localhost:27017/cherifdb_dev ++
|
||||
INFO:root:2023-09-01 18:38:56.808477 : ++ DBNAME Database(MongoClient(host=['localhost:27017'], document_class=dict, tz_aware=False, connect=True), 'cherifdb_dev') ++
|
||||
INFO:root:2023-09-01 18:38:56.808477 : ++ FLASK PORT 5001 ++
|
||||
INFO:root:2023-09-01 18:38:56.808477 : ++ LMS_BAS_URL mysy-training.com/ ++
|
||||
WARNING:werkzeug: * Debugger is active!
|
||||
INFO:werkzeug: * Debugger PIN: 131-539-023
|
||||
INFO:root:2023-09-01 18:39:03.041309 : Security check : IP adresse '127.0.0.1' connected
|
||||
INFO:werkzeug:127.0.0.1 - - [01/Sep/2023 18:39:03] "[32mPOST /myclass/api/test_jnja2_database HTTP/1.1[0m" 308 -
|
||||
INFO:root:2023-09-01 18:39:03.047342 : Security check : IP adresse '127.0.0.1' connected
|
||||
INFO:root:2023-09-01 18:39:03.558620 : test_jnja2_database - Aucun template avec 'ref_interne':'test01'
|
||||
INFO:werkzeug:127.0.0.1 - - [01/Sep/2023 18:39:03] "POST /myclass/api/test_jnja2_database/ HTTP/1.1" 200 -
|
||||
INFO:werkzeug: * Detected change in 'C:\\Users\\billa\\Documents\\myclass.com\\Siteweb\\Production\\Ela_back\\Back_Office\\tools_cherif\\tools_cherif.py', reloading
|
||||
INFO:werkzeug: * Restarting with stat
|
||||
INFO:root:2023-09-01 18:39:31.487489 : ++++ ENVIRONNEMENT DEVELOPPEMENT ++++
|
||||
INFO:root:2023-09-01 18:39:31.487489 : ++ DATABASE mongodb://localhost:27017/cherifdb_dev ++
|
||||
INFO:root:2023-09-01 18:39:31.487489 : ++ DBNAME Database(MongoClient(host=['localhost:27017'], document_class=dict, tz_aware=False, connect=True), 'cherifdb_dev') ++
|
||||
INFO:root:2023-09-01 18:39:31.487489 : ++ FLASK PORT 5001 ++
|
||||
INFO:root:2023-09-01 18:39:31.487489 : ++ LMS_BAS_URL mysy-training.com/ ++
|
||||
WARNING:werkzeug: * Debugger is active!
|
||||
INFO:werkzeug: * Debugger PIN: 131-539-023
|
||||
INFO:root:2023-09-01 18:39:34.709876 : Security check : IP adresse '127.0.0.1' connected
|
||||
INFO:werkzeug:127.0.0.1 - - [01/Sep/2023 18:39:34] "[32mPOST /myclass/api/test_jnja2_database HTTP/1.1[0m" 308 -
|
||||
INFO:root:2023-09-01 18:39:34.714992 : Security check : IP adresse '127.0.0.1' connected
|
||||
INFO:root:2023-09-01 18:39:35.220198 : test_jnja2_database - Aucun template avec 'ref_interne':'test01'
|
||||
INFO:werkzeug:127.0.0.1 - - [01/Sep/2023 18:39:35] "POST /myclass/api/test_jnja2_database/ HTTP/1.1" 200 -
|
||||
|
|
15
main.py
15
main.py
|
@ -2587,6 +2587,21 @@ def test_web_service2():
|
|||
localStatus, message = tools_cherif.test_web_service2(payload)
|
||||
return jsonify(status=localStatus, message=message)
|
||||
|
||||
"""
|
||||
Cette API permet de tester l'utilisation de jinja2 avec
|
||||
des informations stockées dans une base de données
|
||||
"""
|
||||
@app.route('/myclass/api/test_jnja2_database/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def test_jnja2_database():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### test_jnja2_database : payload = ", payload)
|
||||
localStatus, message = tools_cherif.test_jnja2_database(payload)
|
||||
return jsonify(status=localStatus, message=message)
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Cette API créer un user LMS Mysy, c'est a dire un user chamilo
|
||||
"""
|
||||
|
|
|
@ -0,0 +1,622 @@
|
|||
"""
|
||||
Ce fichier permet de gerer la personalisation des documents d'un partenaire.
|
||||
|
||||
Par exemple, la personnalisation des documents de convocation.
|
||||
Il permet egalement de créer un document à par entitère, inconnu par l'editeur du logiciel.
|
||||
Use case : un partenaire souhaite un document d'attestation de presence.
|
||||
|
||||
A la creation, l'utilisateur devra choisir un objet (formation, stagiaire, etc), le système proposera les champs adequat
|
||||
|
||||
Donc au debut, l'utilisateur peut :
|
||||
1 - Modifier un document existant (convocation, confirmation inscription, annulation inscription, etc)
|
||||
2 - Créer un nouveau document from scratch (attestation de presence)
|
||||
/!\ : Prevoir un bouton previsualitation
|
||||
"""
|
||||
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
|
||||
|
||||
def Add_Partner_Document(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', "nom", "ref_interne", "type_doc", "cible", "sujet",'contenu_doc',]
|
||||
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
if val not in field_list:
|
||||
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', "ref_interne", ]
|
||||
|
||||
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
|
||||
|
||||
data = {}
|
||||
data['partner_owner_recid'] = my_partner['recid']
|
||||
|
||||
ref_interne = ""
|
||||
if ("ref_interne" in diction.keys()):
|
||||
if diction['ref_interne']:
|
||||
ref_interne = diction['ref_interne']
|
||||
if (len(str(ref_interne)) > 255):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " - Le champ 'ref_interne' fait plus de 255 caractère ")
|
||||
|
||||
return False, " - Le champ 'ref_interne' fait plus de 255 caractère "
|
||||
data['ref_interne'] = diction['ref_interne']
|
||||
|
||||
nom = ""
|
||||
if ("nom" in diction.keys()):
|
||||
if diction['nom']:
|
||||
nom = diction['nom']
|
||||
if (len(str(nom)) > 255):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " - Le champ 'nom' fait plus de 255 caractère ")
|
||||
|
||||
return False, " - Le champ 'nom' fait plus de 255 caractère "
|
||||
data['nom'] = diction['nom']
|
||||
|
||||
|
||||
|
||||
sujet = ""
|
||||
if ("sujet" in diction.keys()):
|
||||
if diction['sujet']:
|
||||
sujet = diction['sujet']
|
||||
if (len(str(sujet)) > 255):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " - Le champ 'sujet' fait plus de 255 caractère ")
|
||||
|
||||
return False, " - Le champ 'sujet' fait plus de 255 caractère "
|
||||
data['sujet'] = diction['sujet']
|
||||
|
||||
|
||||
type_doc = ""
|
||||
if ("type_doc" in diction.keys()):
|
||||
if diction['type_doc']:
|
||||
type_doc = diction['type_doc']
|
||||
if (type_doc not in MYSY_GV.MODELE_DOCUMENT_TYPE ):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " - Le champ 'type_doc' n'est pas accepté. les valeurs acceptées sont "+str(MYSY_GV.MODELE_DOCUMENT_TYPE))
|
||||
|
||||
return False, " - Le champ 'type_doc' n'est pas accepté. les valeurs acceptées sont "+str(MYSY_GV.MODELE_DOCUMENT_TYPE)
|
||||
data['type_doc'] = diction['type_doc']
|
||||
|
||||
|
||||
contenu_doc = ""
|
||||
if ("contenu_doc" in diction.keys()):
|
||||
if diction['contenu_doc']:
|
||||
contenu_doc = diction['contenu_doc']
|
||||
if (len(str(sujet)) > 10000):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " - Le champ 'contenu_doc' fait plus de 10000 caractère ")
|
||||
|
||||
return False, " - Le champ 'sujet' fait plus de 10000 caractère "
|
||||
data['contenu_doc'] = diction['contenu_doc']
|
||||
|
||||
|
||||
# Verifier qu'il n'existe pas un document avec le meme code code interne
|
||||
exist_doc_count = MYSY_GV.dbname['courrier_template'].count_documents({'ref_interne':str(ref_interne), 'valide':'1',
|
||||
'partner_owner_recid':str(my_partner['recid'])})
|
||||
|
||||
if( exist_doc_count > 0 ):
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - Il existe déjà un document avec la meme reference interne ")
|
||||
return False, "- Il existe déjà un document avec la meme reference interne "
|
||||
|
||||
data['valide'] = '1'
|
||||
data['locked'] = '0'
|
||||
data['date_update'] = str(datetime.now())
|
||||
|
||||
inserted_id = ""
|
||||
inserted_id = MYSY_GV.dbname['courrier_template'].insert_one(data).inserted_id
|
||||
if (not inserted_id):
|
||||
mycommon.myprint(
|
||||
" Impossible de créer le document ")
|
||||
return False, " Impossible de créer le document "
|
||||
|
||||
return True, " Le nouveau document a été correctement créé"
|
||||
|
||||
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 créer le nouveau document "
|
||||
|
||||
|
||||
"""
|
||||
Mise à jour d'un document d'un partenaire en se basant sur son _id
|
||||
"""
|
||||
def Update_Partner_Document(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', "nom", "ref_interne", "type_doc", "cible", "sujet",'contenu_doc', '_id']
|
||||
|
||||
|
||||
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
if val not in field_list:
|
||||
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
|
||||
|
||||
"""
|
||||
Verification si ce document n'existe pas deja pour ce partner
|
||||
"""
|
||||
|
||||
qry_update = {'_id': ObjectId(str(diction['_id'])), 'valide': '1', 'partner_owner_recid': str(my_partner['recid']),}
|
||||
|
||||
|
||||
|
||||
print(" ### qry_update zz = ", qry_update)
|
||||
|
||||
tmp_count = MYSY_GV.dbname['courrier_template'].count_documents(qry_update)
|
||||
if (tmp_count <= 0):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " - Ce document n'existe pas = "+str(diction['nom']))
|
||||
|
||||
return False, " - Ce document n'existe pas "
|
||||
|
||||
|
||||
|
||||
data_update = {}
|
||||
"""
|
||||
Recuperation des données fournies en entrée
|
||||
"""
|
||||
ref_interne = ""
|
||||
if ("ref_interne" in diction.keys()):
|
||||
if diction['ref_interne']:
|
||||
ref_interne = diction['ref_interne']
|
||||
if (len(str(ref_interne)) > 255):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " - Le champ 'ref_interne' fait plus de 255 caractère ")
|
||||
|
||||
return False, " - Le champ 'ref_interne' fait plus de 255 caractère "
|
||||
data_update['ref_interne'] = diction['ref_interne']
|
||||
|
||||
nom = ""
|
||||
if ("nom" in diction.keys()):
|
||||
if diction['nom']:
|
||||
nom = diction['nom']
|
||||
if (len(str(nom)) > 255):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " - Le champ 'nom' fait plus de 255 caractère ")
|
||||
|
||||
return False, " - Le champ 'nom' fait plus de 255 caractère "
|
||||
data_update['nom'] = diction['nom']
|
||||
|
||||
sujet = ""
|
||||
if ("sujet" in diction.keys()):
|
||||
if diction['sujet']:
|
||||
sujet = diction['sujet']
|
||||
if (len(str(sujet)) > 255):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " - Le champ 'sujet' fait plus de 255 caractère ")
|
||||
|
||||
return False, " - Le champ 'sujet' fait plus de 255 caractère "
|
||||
data_update['sujet'] = diction['sujet']
|
||||
|
||||
type_doc = ""
|
||||
if ("type_doc" in diction.keys()):
|
||||
if diction['type_doc']:
|
||||
type_doc = diction['type_doc']
|
||||
if (type_doc not in MYSY_GV.MODELE_DOCUMENT_TYPE):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " - Le champ 'type_doc' n'est pas accepté. les valeurs acceptées sont " + str(
|
||||
MYSY_GV.MODELE_DOCUMENT_TYPE))
|
||||
|
||||
return False, " - Le champ 'type_doc' n'est pas accepté. les valeurs acceptées sont " + str(
|
||||
MYSY_GV.MODELE_DOCUMENT_TYPE)
|
||||
data_update['type_doc'] = diction['type_doc']
|
||||
|
||||
contenu_doc = ""
|
||||
if ("contenu_doc" in diction.keys()):
|
||||
if diction['contenu_doc']:
|
||||
contenu_doc = diction['contenu_doc']
|
||||
if (len(str(sujet)) > 10000):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " - Le champ 'contenu_doc' fait plus de 10000 caractère ")
|
||||
|
||||
return False, " - Le champ 'sujet' fait plus de 10000 caractère "
|
||||
data_update['contenu_doc'] = diction['contenu_doc']
|
||||
|
||||
data_update['valide'] = '1'
|
||||
data_update['locked'] = '0'
|
||||
data_update['date_update'] = str(datetime.now())
|
||||
|
||||
"""
|
||||
Clés de mise à jour
|
||||
"""
|
||||
data_cle = {'_id': ObjectId(str(diction['_id'])), 'valide': '1', 'locked': '0', 'partner_owner_recid': str(my_partner['recid']),}
|
||||
|
||||
|
||||
inserted_id = ""
|
||||
result = MYSY_GV.dbname['courrier_template'].find_one_and_update(
|
||||
data_cle,
|
||||
{"$set": data_update},
|
||||
upsert=False,
|
||||
return_document=ReturnDocument.AFTER
|
||||
)
|
||||
|
||||
if (result is None or "_id" not in result.keys()):
|
||||
mycommon.myprint(
|
||||
" Impossible de mettre à jour le modèle de document = ")
|
||||
return False, " Impossible de mettre à jour le modèle de document "
|
||||
|
||||
return True, " Le modèle de document a été correctement mis à jour"
|
||||
|
||||
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 mettre à jour le modèle de document "
|
||||
|
||||
|
||||
"""
|
||||
Suppression d'un modèle de document d'un partenaire
|
||||
"""
|
||||
def Delete_Partner_Document(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', '_id', 'ref_interne', ]
|
||||
|
||||
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
if val not in field_list:
|
||||
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
|
||||
|
||||
"""
|
||||
Verification de l'existance du modèle de document a supprimer
|
||||
"""
|
||||
existe_modele_doc_count = MYSY_GV.dbname['courrier_template'].count_documents({'_id': ObjectId(str(diction['_id'])),
|
||||
'partner_owner_recid': str(my_partner['recid']),})
|
||||
|
||||
if( existe_modele_doc_count <= 0 ):
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - Ce modèle de document est invalide")
|
||||
return False, str(inspect.stack()[0][3]) + " - Ce modèle de document est invalide "
|
||||
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Suppression du modèle de document
|
||||
"""
|
||||
MYSY_GV.dbname['courrier_template'].delete_many({'_id': ObjectId(str(diction['_id'])),
|
||||
'partner_owner_recid': str(my_partner['recid']),})
|
||||
|
||||
|
||||
|
||||
return True, " Le modèle de document a été correctement supprimé"
|
||||
|
||||
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 supprimer le materiel "
|
||||
|
||||
|
||||
"""
|
||||
Recuperation de la liste des modèles de document d'un partenaire en se basant sur le token (partner_owner_recid)
|
||||
|
||||
"""
|
||||
def Get_List_Partner_Document(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:
|
||||
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'] = str(my_partner['recid'])
|
||||
|
||||
data_cle['locked'] = "0"
|
||||
data_cle['valide'] = "1"
|
||||
|
||||
RetObject = []
|
||||
val_tmp = 1
|
||||
|
||||
for retval in MYSY_GV.dbname['courrier_template'].find(data_cle):
|
||||
user = 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 recuperer la liste des modèles de document "
|
||||
|
||||
"""
|
||||
Recuperation d'un modèle de dcument donnée en se basant sur on token, _id,
|
||||
"""
|
||||
def Get_Given_Partner_Document(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:
|
||||
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'] = str(my_partner['recid'])
|
||||
data_cle['_id'] = ObjectId(str(diction['_id']))
|
||||
|
||||
data_cle['valide'] = "1"
|
||||
data_cle['locked'] = "0"
|
||||
|
||||
RetObject = []
|
||||
val_tmp = 1
|
||||
|
||||
#print(" ### data_cle = ", data_cle)
|
||||
for retval in MYSY_GV.dbname['courrier_template'].find(data_cle):
|
||||
user = retval
|
||||
user['id'] = str(val_tmp)
|
||||
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 recuperer le modèle de document "
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Recherche de la liste des modèles de document sans filter - no_filter
|
||||
"""
|
||||
def Get_List_Partner_Document_no_filter(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:
|
||||
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'] = str(my_partner['recid'])
|
||||
|
||||
data_cle['locked'] = "0"
|
||||
data_cle['valide'] = "1"
|
||||
|
||||
find_qry = {'partner_owner_recid': str(my_partner['recid']), 'valide':'1', 'locked':'0' }
|
||||
|
||||
print(" ### materiel find_qry = ", find_qry)
|
||||
RetObject = []
|
||||
val_tmp = 1
|
||||
|
||||
for retval in MYSY_GV.dbname['courrier_template'].find(find_qry):
|
||||
user = 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 recuperer la liste des modèles de document "
|
||||
|
||||
|
||||
|
||||
|
|
@ -258,7 +258,7 @@ def Add_Ressource_Materielle(diction):
|
|||
|
||||
|
||||
"""
|
||||
Mise à jour d'une ressource matereiel en se basant sur sont _id
|
||||
Mise à jour d'une ressource matereiel en se basant sur son _id
|
||||
"""
|
||||
def Update_Ressource_Materielle(diction):
|
||||
try:
|
||||
|
@ -321,7 +321,7 @@ def Update_Ressource_Materielle(diction):
|
|||
Verification si ce materiel n'existe pas deja pour ce partner
|
||||
"""
|
||||
|
||||
qry_update = {'_id': ObjectId(str(diction['_id'])), 'valide': '1', 'locked': '0', 'partner_recid': str(my_partner['recid']),}
|
||||
qry_update = {'_id': ObjectId(str(diction['_id'])), 'valide': '1', 'partner_recid': str(my_partner['recid']),}
|
||||
|
||||
|
||||
|
||||
|
@ -528,7 +528,7 @@ def Delete_Ressource_Materielle(diction):
|
|||
|
||||
|
||||
"""
|
||||
Verification de l'existance de l'employée a supprimer
|
||||
Verification de l'existance du materiel a supprimer
|
||||
"""
|
||||
existe_employee_count = MYSY_GV.dbname['ressource_materielle'].count_documents({'_id': ObjectId(str(diction['_id'])),
|
||||
'partner_recid': str(my_partner['recid']),})
|
||||
|
|
|
@ -19,6 +19,7 @@ import ela_index_bdd_classes as eibdd
|
|||
import email_mgt as email
|
||||
|
||||
from validate_email import validate_email
|
||||
import jinja2
|
||||
def email_validation():
|
||||
try:
|
||||
|
||||
|
@ -823,3 +824,31 @@ def test_web_service2(diction):
|
|||
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - Line : " + str(exc_tb.tb_lineno))
|
||||
return False, "Test WebService KOOO"
|
||||
|
||||
"""
|
||||
Cette fonction permet de tester l'utilisation de jinja2 avec
|
||||
des informations stockées dans une base de données
|
||||
"""
|
||||
def test_jnja2_database(diction):
|
||||
try:
|
||||
# Recuperation des information du template
|
||||
Document_Template_Data = MYSY_GV.dbname['courrier_template'].find_one({'ref_interne':'test01'})
|
||||
if( Document_Template_Data is None):
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - Aucun template avec 'ref_interne':'test01' ")
|
||||
#return False, " - Aucun template avec 'ref_interne':'test01' "
|
||||
|
||||
|
||||
elif( "type_doc" in Document_Template_Data.keys()):
|
||||
print(" ### type_doc = ", str(Document_Template_Data['type_doc']))
|
||||
|
||||
tm = jinja2.Template("My name is {{ per.name }} and I am {{ per.age }}")
|
||||
|
||||
person = {'name': 'Cherif BALDE', 'age': 41}
|
||||
msg = tm.render(per=person)
|
||||
|
||||
print(" ### MSG APRES JINJA2 = ",msg )
|
||||
|
||||
return True, "test_jnja2_database => OK : MESSAGE = "+str(msg)
|
||||
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, "test_jnja2_database KOOO"
|
||||
|
|
Loading…
Reference in New Issue