29/11/2023 - 18h30
parent
47743b1377
commit
9aba866a81
|
@ -2,13 +2,13 @@
|
|||
<project version="4">
|
||||
<component name="ChangeListManager">
|
||||
<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$/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$/base_config_modele_journee.py" beforeDir="false" afterPath="$PROJECT_DIR$/base_config_modele_journee.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" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
|
|
|
@ -0,0 +1,82 @@
|
|||
"""
|
||||
Fonction commune des tableaux de bord comme :
|
||||
- get_list_tbd
|
||||
- add to my tbd
|
||||
- remove from my tbd,
|
||||
- etc
|
||||
"""
|
||||
|
||||
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
|
||||
from datetime import timedelta
|
||||
from datetime import timedelta
|
||||
|
||||
def Get_List_Partner_Dashbord(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', 'session_start_date', 'session_end_date' ]
|
||||
|
||||
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
|
||||
|
||||
RetObject = []
|
||||
val_tmp = 1
|
||||
|
||||
for retval in MYSY_GV.dbname['base_config_dashbord'].find({'$or':[{'valide':"1", 'locked':'0', 'partner_owner_recid':'default'},
|
||||
{'valide':"1", 'locked':'0', 'partner_owner_recid':str(my_partner['recid'])} ]} ):
|
||||
RetObject.append(mycommon.JSONEncoder().encode(retval))
|
||||
|
||||
|
||||
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 tableaux de bord "
|
||||
|
|
@ -0,0 +1,174 @@
|
|||
"""
|
||||
Ce fichier contient les requetes utilisées dans les tableaux de bord des session
|
||||
"""
|
||||
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
|
||||
from datetime import timedelta
|
||||
from datetime import timedelta
|
||||
|
||||
|
||||
def Get_Qery_List_Session_Data(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', 'session_start_date', 'session_end_date' ]
|
||||
|
||||
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
|
||||
|
||||
filt_session_start_date = ""
|
||||
if ("session_start_date" in diction.keys()):
|
||||
filt_session_start_date = str(diction['session_start_date'])[0:10]
|
||||
local_status = mycommon.CheckisDate(filt_session_start_date)
|
||||
if (local_status is False):
|
||||
mycommon.myprint(str(
|
||||
inspect.stack()[0][3]) + " 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 = ""
|
||||
if ("session_end_date" in diction.keys()):
|
||||
filt_session_end_date = str(diction['session_end_date'])[0:10]
|
||||
local_status = mycommon.CheckisDate(filt_session_end_date)
|
||||
if (local_status is False):
|
||||
mycommon.myprint(str(
|
||||
inspect.stack()[0][3]) + " Le filtre : 'date de fin de session' n'est pas au format jj/mm/aaaa.")
|
||||
return False, " Le filtre : 'date de fin de session' n'est pas au format jj/mm/aaaa."
|
||||
|
||||
|
||||
RetObject = []
|
||||
val_tmp = 1
|
||||
|
||||
qery = [{'partner_owner_recid':str(my_partner['recid'])}, {'code_session':1, 'session_etape':1, 'class_internal_url':1, 'distantiel':1,
|
||||
'presentiel':1, 'nb_participant':1, 'formateur_id':1,
|
||||
'date_debut':1, 'date_fin':1}]
|
||||
|
||||
|
||||
print(" #### qery = ", qery)
|
||||
for retval in MYSY_GV.dbname['session_formation'].find({'partner_owner_recid':str(my_partner['recid'])}, {'code_session':1, 'session_etape':1, 'class_internal_url':1, 'distantiel':1,
|
||||
'presentiel':1, 'nb_participant':1, 'formateur_id':1, 'date_debut':1, 'date_fin':1}):
|
||||
user = retval
|
||||
user['id'] = str(val_tmp)
|
||||
val_tmp = val_tmp + 1
|
||||
|
||||
nb_participant = "1"
|
||||
if ("nb_participant" in retval.keys()):
|
||||
nb_participant = retval['nb_participant']
|
||||
|
||||
user['nb_participant'] = nb_participant
|
||||
|
||||
## Recuperation du nombre d'inscrits
|
||||
Count_Inscrit = MYSY_GV.dbname['inscription'].count_documents(
|
||||
{'session_id': str(retval['_id']), 'class_internal_url': str(retval['class_internal_url']),
|
||||
'status': "1"})
|
||||
user['nb_inscrit'] = str(Count_Inscrit)
|
||||
|
||||
## Recuperation du nombre de preinscrits
|
||||
Count_Preinscrit = MYSY_GV.dbname['inscription'].count_documents(
|
||||
{'session_id': str(retval['_id']), 'class_internal_url': str(retval['class_internal_url']),
|
||||
'status': "0"})
|
||||
|
||||
user['nb_preinscrit'] = str(Count_Preinscrit)
|
||||
|
||||
taux_disponibilite = "100"
|
||||
taux_remplissage = "0"
|
||||
if (str(nb_participant) != "0"):
|
||||
taux_remplissage = (round(int(mycommon.tryInt(Count_Inscrit)) / int(mycommon.tryInt(nb_participant)),
|
||||
2))*100
|
||||
|
||||
taux_disponibilite = 100 - taux_remplissage
|
||||
|
||||
|
||||
|
||||
user['taux_remplissage'] = str(taux_remplissage)
|
||||
user['taux_remplissageColor'] = "green"
|
||||
|
||||
user['taux_disponibilite'] = str(taux_disponibilite)
|
||||
user['taux_disponibiliteColor'] = "yellow"
|
||||
|
||||
|
||||
if (filt_session_start_date and filt_session_end_date):
|
||||
# Si on a un filtre sur la date debut et de fin de session
|
||||
if ((datetime.strptime(str(retval['date_debut'][0:10]).strip(), '%d/%m/%Y') >= datetime.strptime(
|
||||
str(filt_session_start_date).strip(), '%d/%m/%Y'))
|
||||
and
|
||||
(datetime.strptime(str(retval['date_fin'][0:10]).strip(),
|
||||
'%d/%m/%Y') <= datetime.strptime(str(filt_session_end_date).strip(),
|
||||
'%d/%m/%Y'))
|
||||
):
|
||||
RetObject.append(mycommon.JSONEncoder().encode(user))
|
||||
|
||||
|
||||
elif (filt_session_start_date):
|
||||
# Si on a un filtre uniquement sur la date de debut de session
|
||||
if ((datetime.strptime(str(retval['date_debut'][0:10]).strip(), '%d/%m/%Y') >= datetime.strptime(
|
||||
str(filt_session_start_date).strip(), '%d/%m/%Y'))):
|
||||
RetObject.append(mycommon.JSONEncoder().encode(user))
|
||||
|
||||
|
||||
elif (filt_session_end_date):
|
||||
# Si on a un filtre uniquement sur la date de fin session
|
||||
if ((datetime.strptime(str(retval['date_fin'][0:10]).strip(), '%d/%m/%Y') <= datetime.strptime(
|
||||
str(filt_session_end_date).strip(), '%d/%m/%Y'))):
|
||||
RetObject.append(mycommon.JSONEncoder().encode(user))
|
||||
|
||||
|
||||
else:
|
||||
RetObject.append(mycommon.JSONEncoder().encode(user))
|
||||
|
||||
|
||||
|
||||
#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 les données "
|
||||
|
|
@ -5906,6 +5906,20 @@ def UpdateStagiairetoClass_Tuteurs(diction):
|
|||
# query_key['token'] = diction['token']
|
||||
|
||||
|
||||
if( "tuteur1_email" in diction.keys() and diction['tuteur1_email']):
|
||||
if( mycommon.isEmailValide ( str(diction['tuteur1_email'])) is False ):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " L'adresse email '"+str(diction['tuteur1_email'])+"' est invalide ")
|
||||
return False, "L'adresse email '"+str(diction['tuteur1_email'])+"' est invalide"
|
||||
|
||||
if ("tuteur2_email" in diction.keys() and diction['tuteur2_email'] ):
|
||||
if (mycommon.isEmailValide(str(diction['tuteur2_email'])) is False):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " L'adresse email '" + str(
|
||||
diction['tuteur2_email']) + "' est invalide ")
|
||||
return False, "L'adresse email '" + str(diction['tuteur2_email']) + "' est invalide"
|
||||
|
||||
|
||||
local_status, my_partner = mycommon.Check_Connexion_And_Return_Partner_Data({'token': mytoken})
|
||||
if (local_status is not True):
|
||||
return local_status, my_partner
|
||||
|
|
3902
Log/log_file.log
3902
Log/log_file.log
File diff suppressed because one or more lines are too long
|
@ -981,14 +981,20 @@ def GetAllValideSessionPartner_List(diction):
|
|||
val['duration_unit'] = retVal['myclass_collection'][0]['duration_unit']
|
||||
|
||||
## Recuperation du nombre d'inscrits
|
||||
Count_Inscrit = MYSY_GV.dbname['inscription'].count_documents({'session_id':str(retVal['code_session']), 'class_internal_url':str(retVal['class_internal_url']),
|
||||
'status':"1"})
|
||||
Count_Inscrit = MYSY_GV.dbname['inscription'].count_documents({'session_id':str(retVal['_id']), 'class_internal_url':str(retVal['class_internal_url']),
|
||||
'status':"1", 'partner_owner_recid':str(my_partner['recid'])})
|
||||
|
||||
qry_nb_inscrit = {'session_id':str(retVal['_id']), 'class_internal_url':str(retVal['class_internal_url']),
|
||||
'status':"1", 'partner_owner_recid':str(my_partner['recid'])}
|
||||
|
||||
|
||||
val['nb_inscrit'] = str(Count_Inscrit)
|
||||
|
||||
## Recuperation du nombre de preinscrits
|
||||
Count_Preinscrit = MYSY_GV.dbname['inscription'].count_documents(
|
||||
{'session_id': str(retVal['code_session']), 'class_internal_url': str(retVal['class_internal_url']),
|
||||
'status': "0"})
|
||||
{'session_id': str(retVal['_id']), 'class_internal_url': str(retVal['class_internal_url']),
|
||||
'status': "0",
|
||||
'partner_owner_recid':str(my_partner['recid'])})
|
||||
|
||||
val['nb_preinscrit'] = str(Count_Preinscrit)
|
||||
|
||||
|
@ -1197,13 +1203,13 @@ def GetAllValideSessionPartner_List_filter_like(diction):
|
|||
|
||||
## Recuperation du nombre d'inscrits
|
||||
Count_Inscrit = MYSY_GV.dbname['inscription'].count_documents(
|
||||
{'session_id': str(retVal['code_session']), 'class_internal_url': str(retVal['class_internal_url']),
|
||||
{'session_id': str(retVal['_id']), 'class_internal_url': str(retVal['class_internal_url']),
|
||||
'status': "1"})
|
||||
val['nb_inscrit'] = str(Count_Inscrit)
|
||||
|
||||
## Recuperation du nombre de preinscrits
|
||||
Count_Preinscrit = MYSY_GV.dbname['inscription'].count_documents(
|
||||
{'session_id': str(retVal['code_session']), 'class_internal_url': str(retVal['class_internal_url']),
|
||||
{'session_id': str(retVal['_id']), 'class_internal_url': str(retVal['class_internal_url']),
|
||||
'status': "0"})
|
||||
|
||||
val['nb_preinscrit'] = str(Count_Preinscrit)
|
||||
|
@ -1411,13 +1417,13 @@ def GetAllValideSessionPartner_List_no_filter(diction):
|
|||
|
||||
## Recuperation du nombre d'inscrits
|
||||
Count_Inscrit = MYSY_GV.dbname['inscription'].count_documents(
|
||||
{'session_id': str(retVal['code_session']), 'class_internal_url': str(retVal['class_internal_url']),
|
||||
{'session_id': str(retVal['_id']), 'class_internal_url': str(retVal['class_internal_url']),
|
||||
'status': "1"})
|
||||
val['nb_inscrit'] = str(Count_Inscrit)
|
||||
|
||||
## Recuperation du nombre de preinscrits
|
||||
Count_Preinscrit = MYSY_GV.dbname['inscription'].count_documents(
|
||||
{'session_id': str(retVal['code_session']), 'class_internal_url': str(retVal['class_internal_url']),
|
||||
{'session_id': str(retVal['_id']), 'class_internal_url': str(retVal['class_internal_url']),
|
||||
'status': "0"})
|
||||
|
||||
val['nb_preinscrit'] = str(Count_Preinscrit)
|
||||
|
|
27
main.py
27
main.py
|
@ -62,6 +62,8 @@ import base_partner_session_step as base_partner_session_step
|
|||
import Session_Formation_Sequence as Session_Formation_Sequence
|
||||
|
||||
import base_config_modele_journee as base_config_modele_journee
|
||||
import Dashbord_queries.session_tbd_qries as session_tbd_qries
|
||||
import Dashbord_queries.common_tdb_qries as common_tdb_qries
|
||||
|
||||
app = Flask(__name__)
|
||||
cors = CORS(app, resources={r"/foo": {"origins": "*"}})
|
||||
|
@ -5769,6 +5771,31 @@ def Get_Default_Debut_Fin_journee_Modele_Journee():
|
|||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
"""
|
||||
API / TBD / QRY : Recuperation des données des sessions de formation
|
||||
"""
|
||||
@app.route('/myclass/api/Get_Qery_List_Session_Data/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Get_Qery_List_Session_Data():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Get_Qery_List_Session_Data payload = ",payload)
|
||||
status, retval = session_tbd_qries.Get_Qery_List_Session_Data(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
"""
|
||||
Recuperation de liste des tableaux de bord d'un partenaire
|
||||
"""
|
||||
@app.route('/myclass/api/Get_List_Partner_Dashbord/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Get_List_Partner_Dashbord():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Get_List_Partner_Dashbord payload = ",payload)
|
||||
status, retval = session_tbd_qries.Get_List_Partner_Dashbord(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
Loading…
Reference in New Issue