11/08/2024 - 18h32s

master
cherif 2024-08-11 18:49:06 +02:00
parent 62cc5aad4b
commit ff28ba5b09
6 changed files with 3038 additions and 11 deletions

View File

@ -1,11 +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="10/08/2024 - 20h32s">
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="11/08/2024 - 12h32s">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Log/log_file.log" beforeDir="false" afterPath="$PROJECT_DIR$/Log/log_file.log" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Session_Formation_Sequence.py" beforeDir="false" afterPath="$PROJECT_DIR$/Session_Formation_Sequence.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$/partners.py" beforeDir="false" afterPath="$PROJECT_DIR$/partners.py" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -75,13 +77,6 @@
<option name="presentableId" value="Default" />
<updated>1680804787304</updated>
</task>
<task id="LOCAL-00320" summary="01/06/2024 - 14h30">
<created>1717245781084</created>
<option name="number" value="00320" />
<option name="presentableId" value="LOCAL-00320" />
<option name="project" value="LOCAL" />
<updated>1717245781085</updated>
</task>
<task id="LOCAL-00321" summary="qsdsq">
<created>1717533847419</created>
<option name="number" value="00321" />
@ -418,7 +413,14 @@
<option name="project" value="LOCAL" />
<updated>1723319219157</updated>
</task>
<option name="localTasksCounter" value="369" />
<task id="LOCAL-00369" summary="11/08/2024 - 12h32s">
<created>1723371666599</created>
<option name="number" value="00369" />
<option name="presentableId" value="LOCAL-00369" />
<option name="project" value="LOCAL" />
<updated>1723371666602</updated>
</task>
<option name="localTasksCounter" value="370" />
<servers />
</component>
<component name="Vcs.Log.Tabs.Properties">
@ -460,7 +462,6 @@
</option>
</component>
<component name="VcsManagerConfiguration">
<MESSAGE value="wwssdss" />
<MESSAGE value="wwssdssd" />
<MESSAGE value="wwssdssddd" />
<MESSAGE value="11/07/2024 - 13h14" />
@ -485,6 +486,7 @@
<MESSAGE value="08/08/2024 - 20h32" />
<MESSAGE value="08/08/2024 - 20h32s" />
<MESSAGE value="10/08/2024 - 20h32s" />
<option name="LAST_COMMIT_MESSAGE" value="10/08/2024 - 20h32s" />
<MESSAGE value="11/08/2024 - 12h32s" />
<option name="LAST_COMMIT_MESSAGE" value="11/08/2024 - 12h32s" />
</component>
</project>

File diff suppressed because it is too large Load Diff

View File

@ -1653,6 +1653,29 @@ def Get_Session_Sequence_List(diction):
if( "grp_apprenant_id" not in user.keys() ):
user['grp_apprenant_id'] = ""
grp_apprenant_color = ""
grp_apprenant_code = ""
"""
Recuperer la couleur du groupe
"""
if( "grp_apprenant_id" in user.keys() and user['grp_apprenant_id']):
groupe_data = MYSY_GV.dbname['groupe_inscription'].find_one({'_id':ObjectId(str(user['grp_apprenant_id'])),
'valide':'1',
'locked':'0',
'partner_owner_recid':str(my_partner['recid'])},
{'code':1, 'color':1})
if( groupe_data and "color" in groupe_data.keys() and groupe_data['color']):
grp_apprenant_color = groupe_data['color']
if (groupe_data and "code" in groupe_data.keys() and groupe_data['code']):
grp_apprenant_code = groupe_data['code']
user['grp_apprenant_color'] = grp_apprenant_color
user['grp_apprenant_code'] = grp_apprenant_code
if ("ue_id" not in user.keys()):
user['ue_id'] = ""

48
main.py
View File

@ -5955,6 +5955,24 @@ def Update_Partner_Document():
status, retval = partner_document_mgt.Update_Partner_Document(payload)
return jsonify(status=status, message=retval)
"""
API qui permet de modifier un document personnalisable pour un super admin
"""
@app.route('/myclass/api/Update_Partner_Document_Super_Admin/', methods=['POST','GET'])
@crossdomain(origin='*')
def Update_Partner_Document_Super_Admin():
# On recupere le corps (payload) de la requete
payload = mycommon.strip_dictionary (request.form.to_dict())
#print(" ### Update_Partner_Document_Super_Admin payload = ",payload)
status, retval = partner_document_mgt.Update_Partner_Document_Super_Admin(payload)
return jsonify(status=status, message=retval)
"""
API qui permet de récupérer un document personnalisable donné
"""
@ -5968,6 +5986,20 @@ def Get_Given_Partner_Document():
return jsonify(status=status, message=retval)
"""
API qui permet de récupérer un document personnalisable donné pour un super admine
"""
@app.route('/myclass/api/Get_Given_Partner_Document_Super_Admin/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_Given_Partner_Document_Super_Admin():
# On recupere le corps (payload) de la requete
payload = mycommon.strip_dictionary (request.form.to_dict())
print(" ### Get_Given_Partner_Document_Super_Admin payload = ",payload)
status, retval = partner_document_mgt.Get_Given_Partner_Document_Super_Admin(payload)
return jsonify(status=status, message=retval)
"""
API de recuperation d'un document par default : un document par defaut qui EST UNIQUEMENT paramettré avec un "partner_owner_recid" = "default"
"""
@ -6037,6 +6069,22 @@ def Get_List_Partner_Document_no_filter():
"""
API Recherche de la liste des modèles de document sans filter - no_filter, pour tout le monde, y compris
les document "default", c'est le super admin
"""
@app.route('/myclass/api/Get_List_Partner_Document_Super_Admin_no_filter/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_List_Partner_Document_Super_Admin_no_filter():
# On recupere le corps (payload) de la requete
payload = mycommon.strip_dictionary (request.form.to_dict())
print(" ### Get_List_Partner_Document_Super_Admin_no_filter payload = ",payload)
status, retval = partner_document_mgt.Get_List_Partner_Document_Super_Admin_no_filter(payload)
return jsonify(status=status, message=retval)
"""
API qui permet de récupérer la liste des documents personnalisables d'un partenaire avec filtre
"""

View File

@ -545,6 +545,258 @@ def Update_Partner_Document(diction):
return False, " Impossible de mettre à jour le modèle de document "
"""
Mise à jour d'un document d'un partenaire en se basant sur son _id
Pour le super admin
"""
def Update_Partner_Document_Super_Admin(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',
'joint_pdf', 'default_version', 'corps_mail', 'edit_by_client']
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
is_document_super_admin = ""
if ("document_super_admin" in my_partner.keys()):
is_document_super_admin = my_partner['document_super_admin']
if (is_document_super_admin != "1"):
mycommon.myprint(
str(inspect.stack()[0][3]) + " Vous n'êtes pas autorisez à exécuter cette fonction ")
return False, " Vous n'êtes pas autorisez à exécuter cette fonction ",
"""
Verification si ce document n'existe pas deja pour ce partner
"""
qry_update = {'_id': ObjectId(str(diction['_id'])), 'valide': '1', }
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ères ")
return False, " - Le champ 'ref_interne' fait plus de 255 caractères "
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ères ")
return False, " - Le champ 'nom' fait plus de 255 caractères "
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ères ")
return False, " - Le champ 'sujet' fait plus de 255 caractères "
data_update['sujet'] = diction['sujet']
cible = ""
if ("cible" in diction.keys()):
if diction['cible']:
cible = diction['cible']
if (len(str(cible)) > 255):
mycommon.myprint(
str(inspect.stack()[0][
3]) + " - Le champ 'cible' fait plus de 255 caractères ")
return False, " - Le champ 'cible' fait plus de 255 caractères "
data_update['cible'] = diction['cible']
type_doc = ""
if ("type_doc" in diction.keys()):
if diction['type_doc']:
type_doc = diction['type_doc']
if (str(type_doc).lower().strip() 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)) > 20000):
mycommon.myprint(
str(inspect.stack()[0][
3]) + " - Le champ 'contenu_doc' fait plus de 20000 caractères ")
return False, " - Le champ 'contenu_doc' fait plus de 20000 caractère "
data_update['contenu_doc'] = diction['contenu_doc']
# ----
joint_pdf = "0"
if ("joint_pdf" in diction.keys()):
if diction['joint_pdf']:
joint_pdf = diction['joint_pdf']
if (str(joint_pdf) not in ['0', '1']):
joint_pdf = '0'
data_update['joint_pdf'] = joint_pdf
edit_by_client = "0"
if ("edit_by_client" in diction.keys()):
if diction['edit_by_client']:
edit_by_client = diction['edit_by_client']
if (str(edit_by_client) not in ['0', '1']):
edit_by_client = '0'
data_update['edit_by_client'] = edit_by_client
default_version = "0"
if ("default_version" in diction.keys()):
if diction['default_version']:
default_version = diction['default_version']
if (str(default_version) not in ['0', '1']):
default_version = '0'
data_update['default_version'] = default_version
corps_mail = ""
if ("corps_mail" in diction.keys()):
if diction['corps_mail']:
corps_mail = diction['corps_mail']
if (len(str(corps_mail)) > 10000):
mycommon.myprint(
str(inspect.stack()[0][
3]) + " - Le champ 'corps_mail' fait plus de 10000 caractères ")
return False, " - Le champ 'corps_mail' fait plus de 10000 caractères "
data_update['corps_mail'] = corps_mail
# ---
data_update['valide'] = '1'
data_update['locked'] = '0'
data_update['date_update'] = str(datetime.now())
data_update['update_by'] = str(my_partner['_id'])
"""
Si le document est une vesion par defaut, il faut alors decoché un eventuel document avec le meme :
- ref_interne
- type_doc
"""
qry_update ={'ref_interne': str(ref_interne),
'_id': ObjectId(str(diction['_id'])),
'valide': '1',
'edit_by_client': str(edit_by_client),
'type_doc': str(diction['type_doc'])}
print(" ### qry_update = ", qry_update)
if ("default_version" in diction.keys() and str(diction['default_version']) == "1"):
MYSY_GV.dbname['courrier_template'].update_many({'ref_interne': str(ref_interne),
'valide': '1',
'edit_by_client': str(edit_by_client),
'_id': ObjectId(str(diction['_id'])),
'type_doc': str(diction['type_doc'])},
{'$set': {'default_version': '0'}})
"""
Clés de mise à jour
"""
data_cle = {'_id': ObjectId(str(diction['_id'])), 'valide': '1', 'locked': '0', }
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
"""
@ -833,6 +1085,94 @@ def Get_Given_Partner_Document(diction):
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - Line : " + str(exc_tb.tb_lineno))
return False, " Impossible de récupérer le modèle de document "
"""
Recuperation d'un modèle de dcument donnée en se basant sur on token, _id,
par un super admin, donc pas de controle sur sur le partner_owner
"""
def Get_Given_Partner_Document_Super_Admin(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
is_document_super_admin = ""
if( "document_super_admin" in my_partner.keys()):
is_document_super_admin = my_partner['document_super_admin']
if( is_document_super_admin != "1"):
mycommon.myprint(
str(inspect.stack()[0][3]) + " Vous n'êtes pas autorisez à exécuter cette fonction ")
return False, " Vous n'êtes pas autorisez à exécuter cette fonction ",
"""
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(" ### Get_Given_Partner_Documentdata_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 récupérer le modèle de document "
"""
Recuperation d'un document par defaut qui EST UNIQUEMENT paramettré avec un "partner_owner_recid" = "default"
"""
@ -983,6 +1323,108 @@ def Get_List_Partner_Document_no_filter(diction):
return False, " Impossible de récupérer la liste des modèles de document "
"""
Recherche de la liste des modèles de document sans filter - no_filter, pour tout le monde, y compris
les document "default", c'est le super admin
"""
def Get_List_Partner_Document_Super_Admin_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 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
is_document_super_admin = ""
if ("document_super_admin" in my_partner.keys()):
is_document_super_admin = my_partner['document_super_admin']
if (is_document_super_admin != "1"):
mycommon.myprint(
str(inspect.stack()[0][3]) + " Vous n'êtes pas autorisez à exécuter cette fonction ")
return False, " Vous n'êtes pas autorisez à exécuter cette fonction ",
"""
Clés de mise à jour
"""
data_cle = {}
data_cle['locked'] = "0"
data_cle['valide'] = "1"
find_qry = {'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).sort([("_id", pymongo.DESCENDING)]):
user = retval
user['id'] = str(val_tmp)
val_tmp = val_tmp + 1
if( "duplicate" not in retval.keys()):
user['duplicate'] = "0"
"""
Recuprer le nom du client
"""
if( "partner_owner_recid" in user.keys() and user['partner_owner_recid'] == "default"):
user['partner_owner_nom'] = "default"
else:
partnair_account_data = MYSY_GV.dbname['partnair_account'].find_one({'recid':user['partner_owner_recid']}, {'nom':1})
if( partnair_account_data and "nom" in partnair_account_data.keys()):
user['partner_owner_nom'] = partnair_account_data['nom']
if( "partner_owner_nom" not in user.keys() ):
user['partner_owner_nom'] = "???"
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 modèles de document "
"""
Recherche de la liste des modèles de document avec des filter
"""

View File

@ -1172,6 +1172,12 @@ def get_partner_account(diction):
user['formation_initiale'] = formation_initiale
document_super_admin = "0"
if (admin_partnair_account and "document_super_admin" in admin_partnair_account.keys()):
document_super_admin = str(admin_partnair_account['document_super_admin'])
user['document_super_admin'] = document_super_admin
RetObject.append(JSONEncoder().encode(user))