30/11/2023 - 21h
parent
9aba866a81
commit
c75a756c11
|
@ -2,12 +2,10 @@
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="24/11/2023 - 18h30">
|
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="24/11/2023 - 18h30">
|
||||||
<change afterPath="$PROJECT_DIR$/Dashbord_queries/common_tdb_qries.py" afterDir="false" />
|
|
||||||
<change afterPath="$PROJECT_DIR$/Dashbord_queries/session_tbd_qries.py" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" 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$/Dashbord_queries/common_tdb_qries.py" beforeDir="false" afterPath="$PROJECT_DIR$/Dashbord_queries/common_tdb_qries.py" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/Dashbord_queries/session_tbd_qries.py" beforeDir="false" afterPath="$PROJECT_DIR$/Dashbord_queries/session_tbd_qries.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$/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$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
|
||||||
</list>
|
</list>
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
|
|
|
@ -24,6 +24,7 @@ from math import isnan
|
||||||
import GlobalVariable as MYSY_GV
|
import GlobalVariable as MYSY_GV
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
|
import ast
|
||||||
|
|
||||||
def Get_List_Partner_Dashbord(diction):
|
def Get_List_Partner_Dashbord(diction):
|
||||||
try:
|
try:
|
||||||
|
@ -80,3 +81,171 @@ def Get_List_Partner_Dashbord(diction):
|
||||||
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - Line : " + str(exc_tb.tb_lineno))
|
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 tableaux de bord "
|
return False, " Impossible de récupérer la liste des tableaux de bord "
|
||||||
|
|
||||||
|
|
||||||
|
"""
|
||||||
|
Fonction ajoute un dashbord au dashbord de l'utilisateur
|
||||||
|
"""
|
||||||
|
def Add_To_User_Dashbord(diction):
|
||||||
|
try:
|
||||||
|
diction = mycommon.strip_dictionary(diction)
|
||||||
|
|
||||||
|
"""
|
||||||
|
Verification des input acceptés
|
||||||
|
"""
|
||||||
|
field_list = ['token', "dashbord_internal_code", "default_filter", "title"]
|
||||||
|
|
||||||
|
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', "dashbord_internal_code", "default_filter", ]
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
# Verifier que le dashbord existe
|
||||||
|
is_existe_dashbord = MYSY_GV.dbname['base_config_dashbord'].count_documents({"dashbord_internal_code":str(diction['dashbord_internal_code']),
|
||||||
|
'valide':'1',
|
||||||
|
'locked':'0',
|
||||||
|
'partner_owner_recid':str(my_partner['recid'])
|
||||||
|
})
|
||||||
|
|
||||||
|
if( is_existe_dashbord <= 0 ):
|
||||||
|
mycommon.myprint(
|
||||||
|
str(inspect.stack()[0][3]) + " Le code du tableau de bord est invalide ")
|
||||||
|
return False, " Le code du tableau de bord est invalide "
|
||||||
|
|
||||||
|
# S'assurer que le 'default_qery' est bien un json
|
||||||
|
default_qery_Json = ast.literal_eval(diction['default_filter'])
|
||||||
|
|
||||||
|
|
||||||
|
my_data = {}
|
||||||
|
my_data['connected_id'] = str(my_partner['_id'])
|
||||||
|
my_data['update_by'] = str(my_partner['_id'])
|
||||||
|
my_data['partner_owner_recid'] = str(my_partner['recid'])
|
||||||
|
my_data['default_filter'] = str(diction['default_filter'])
|
||||||
|
my_data['title'] = str(diction['title'])
|
||||||
|
my_data['dashbord_internal_code'] = str(diction['dashbord_internal_code'])
|
||||||
|
my_data['valide'] = "1"
|
||||||
|
my_data['locked'] = "0"
|
||||||
|
|
||||||
|
result = MYSY_GV.dbname['user_dashbord'].find_one_and_update(
|
||||||
|
{'partner_owner_recid': str(my_partner['recid']), 'connected_id':str(my_partner['_id']),
|
||||||
|
'dashbord_internal_code':str(diction['dashbord_internal_code']),
|
||||||
|
'title':str(diction['title'])},
|
||||||
|
{"$set": my_data},
|
||||||
|
upsert=True,
|
||||||
|
return_document=ReturnDocument.AFTER
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
return True, " Le tableau de bord a été correctement ajouté "
|
||||||
|
|
||||||
|
|
||||||
|
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 le tableau de bord "
|
||||||
|
|
||||||
|
|
||||||
|
"""
|
||||||
|
Fonction qui supprime un dashbord de la liste des dashbord de l'utilisateur
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
def Delete_To_User_Dashbord(diction):
|
||||||
|
try:
|
||||||
|
diction = mycommon.strip_dictionary(diction)
|
||||||
|
|
||||||
|
"""
|
||||||
|
Verification des input acceptés
|
||||||
|
"""
|
||||||
|
field_list = ['token', "dashbord_internal_code", "title"]
|
||||||
|
|
||||||
|
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', "dashbord_internal_code" ]
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
# Verifier que le dashbord existe
|
||||||
|
is_existe_dashbord = MYSY_GV.dbname['base_config_dashbord'].count_documents(
|
||||||
|
{"dashbord_internal_code": str(diction['dashbord_internal_code']),
|
||||||
|
'valide': '1',
|
||||||
|
'locked': '0',
|
||||||
|
'partner_owner_recid': str(my_partner['recid'])
|
||||||
|
})
|
||||||
|
|
||||||
|
if (is_existe_dashbord <= 0):
|
||||||
|
mycommon.myprint(
|
||||||
|
str(inspect.stack()[0][3]) + " Le code du tableau de bord est invalide ")
|
||||||
|
return False, " Le code du tableau de bord est invalide "
|
||||||
|
|
||||||
|
# S'assurer que le 'default_qery' est bien un json
|
||||||
|
default_qery_Json = json.loads(diction['default_filter'])
|
||||||
|
|
||||||
|
my_data = {}
|
||||||
|
my_data['connected_id'] = str(my_partner['_id'])
|
||||||
|
my_data['partner_owner_recid'] = str(my_partner['recid'])
|
||||||
|
my_data['dashbord_internal_code'] = str(diction['dashbord_internal_code'])
|
||||||
|
|
||||||
|
|
||||||
|
MYSY_GV.dbname["user_dashbord"].delete_one(my_data)
|
||||||
|
|
||||||
|
data = {}
|
||||||
|
data['partner_owner_recid'] = my_partner['recid']
|
||||||
|
|
||||||
|
return True, " Le tableau de bord 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 d'ajouter le tableau de bord "
|
||||||
|
|
|
@ -61,7 +61,7 @@ def Get_Qery_List_Session_Data(diction):
|
||||||
return local_status, my_partner
|
return local_status, my_partner
|
||||||
|
|
||||||
filt_session_start_date = ""
|
filt_session_start_date = ""
|
||||||
if ("session_start_date" in diction.keys()):
|
if ("session_start_date" in diction.keys() and diction['session_start_date']):
|
||||||
filt_session_start_date = str(diction['session_start_date'])[0:10]
|
filt_session_start_date = str(diction['session_start_date'])[0:10]
|
||||||
local_status = mycommon.CheckisDate(filt_session_start_date)
|
local_status = mycommon.CheckisDate(filt_session_start_date)
|
||||||
if (local_status is False):
|
if (local_status is False):
|
||||||
|
@ -70,7 +70,7 @@ def Get_Qery_List_Session_Data(diction):
|
||||||
return False, " Le filtre : 'date de debut de session' n'est pas au format jj/mm/aaaa."
|
return False, " Le filtre : 'date de debut de session' n'est pas au format jj/mm/aaaa."
|
||||||
|
|
||||||
filt_session_end_date = ""
|
filt_session_end_date = ""
|
||||||
if ("session_end_date" in diction.keys()):
|
if ("session_end_date" in diction.keys() and diction['session_end_date']):
|
||||||
filt_session_end_date = str(diction['session_end_date'])[0:10]
|
filt_session_end_date = str(diction['session_end_date'])[0:10]
|
||||||
local_status = mycommon.CheckisDate(filt_session_end_date)
|
local_status = mycommon.CheckisDate(filt_session_end_date)
|
||||||
if (local_status is False):
|
if (local_status is False):
|
||||||
|
|
1461
Log/log_file.log
1461
Log/log_file.log
File diff suppressed because it is too large
Load Diff
11
main.py
11
main.py
|
@ -5796,6 +5796,17 @@ def Get_List_Partner_Dashbord():
|
||||||
status, retval = session_tbd_qries.Get_List_Partner_Dashbord(payload)
|
status, retval = session_tbd_qries.Get_List_Partner_Dashbord(payload)
|
||||||
return jsonify(status=status, message=retval)
|
return jsonify(status=status, message=retval)
|
||||||
|
|
||||||
|
"""
|
||||||
|
API pour ajouter un tbd à la list des tbd d'un user
|
||||||
|
"""
|
||||||
|
@app.route('/myclass/api/Add_To_User_Dashbord/', methods=['POST','GET'])
|
||||||
|
@crossdomain(origin='*')
|
||||||
|
def Add_To_User_Dashbord():
|
||||||
|
# On recupere le corps (payload) de la requete
|
||||||
|
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||||
|
print(" ### Add_To_User_Dashbord payload = ",payload)
|
||||||
|
status, retval = common_tdb_qries.Add_To_User_Dashbord(payload)
|
||||||
|
return jsonify(status=status, message=retval)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
Loading…
Reference in New Issue