02/08/2024 - 17h
parent
8b3563510f
commit
b5d8267f01
|
@ -3,8 +3,10 @@
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="02/08/2024 - 17h">
|
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="02/08/2024 - 17h">
|
||||||
<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$/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$/Log/log_file.log" beforeDir="false" afterPath="$PROJECT_DIR$/Log/log_file.log" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/groupe_inscrit_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/groupe_inscrit_mgt.py" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/unite_enseignement_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/unite_enseignement_mgt.py" afterDir="false" />
|
||||||
</list>
|
</list>
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||||
|
|
|
@ -290,7 +290,10 @@ Nombre maximum de clients de partner importable par csv
|
||||||
"""
|
"""
|
||||||
MAX_PARTNER_CLIENT_BY_CSV = 100
|
MAX_PARTNER_CLIENT_BY_CSV = 100
|
||||||
|
|
||||||
|
"""
|
||||||
|
Nombre maximum de lignes dans un fichier de planification d'une UE
|
||||||
|
"""
|
||||||
|
MAX_EU_PLANIF_BY_CSV = 200
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Stripe : Nom des produits et prix et la clé de config
|
Stripe : Nom des produits et prix et la clé de config
|
||||||
|
|
|
@ -2634976,3 +2634976,21 @@ INFO:werkzeug:127.0.0.1 - - [02/Aug/2024 19:07:16] "POST /myclass/api/Get_List_C
|
||||||
INFO:werkzeug:127.0.0.1 - - [02/Aug/2024 19:07:16] "POST /myclass/api/Get_List_Unite_Enseignement_no_filter/ HTTP/1.1" 200 -
|
INFO:werkzeug:127.0.0.1 - - [02/Aug/2024 19:07:16] "POST /myclass/api/Get_List_Unite_Enseignement_no_filter/ HTTP/1.1" 200 -
|
||||||
INFO:root:2024-08-02 19:07:18.592792 : Security check : IP adresse '127.0.0.1' connected
|
INFO:root:2024-08-02 19:07:18.592792 : Security check : IP adresse '127.0.0.1' connected
|
||||||
INFO:werkzeug:127.0.0.1 - - [02/Aug/2024 19:07:18] "POST /myclass/api/Get_Given_Unite_Enseignement/ HTTP/1.1" 200 -
|
INFO:werkzeug:127.0.0.1 - - [02/Aug/2024 19:07:18] "POST /myclass/api/Get_Given_Unite_Enseignement/ HTTP/1.1" 200 -
|
||||||
|
INFO:werkzeug: * Detected change in 'C:\\Users\\billa\\Documents\\myclass.com\\Siteweb\\Production\\Ela_back\\Back_Office\\unite_enseignement_mgt.py', reloading
|
||||||
|
INFO:werkzeug: * Restarting with stat
|
||||||
|
INFO:root:2024-08-02 20:14:50.321625 : ++++ ENVIRONNEMENT DEVELOPPEMENT ++++
|
||||||
|
INFO:root:2024-08-02 20:14:50.321625 : ++ DATABASE mongodb://localhost:27017/cherifdb_dev ++
|
||||||
|
INFO:root:2024-08-02 20:14:50.321625 : ++ DBNAME Database(MongoClient(host=['localhost:27017'], document_class=dict, tz_aware=False, connect=True), 'cherifdb_dev') ++
|
||||||
|
INFO:root:2024-08-02 20:14:50.321625 : ++ FLASK PORT 5001 ++
|
||||||
|
INFO:root:2024-08-02 20:14:50.321625 : ++ 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:2024-08-02 20:15:00.858565 : ++++ ENVIRONNEMENT DEVELOPPEMENT ++++
|
||||||
|
INFO:root:2024-08-02 20:15:00.858565 : ++ DATABASE mongodb://localhost:27017/cherifdb_dev ++
|
||||||
|
INFO:root:2024-08-02 20:15:00.858565 : ++ DBNAME Database(MongoClient(host=['localhost:27017'], document_class=dict, tz_aware=False, connect=True), 'cherifdb_dev') ++
|
||||||
|
INFO:root:2024-08-02 20:15:00.858565 : ++ FLASK PORT 5001 ++
|
||||||
|
INFO:root:2024-08-02 20:15:00.858565 : ++ LMS_BAS_URL mysy-training.com/ ++
|
||||||
|
WARNING:werkzeug: * Debugger is active!
|
||||||
|
INFO:werkzeug: * Debugger PIN: 877-541-979
|
||||||
|
|
80
main.py
80
main.py
|
@ -10591,6 +10591,86 @@ def Automatic_Creation_Groupe_Member_Inscrit():
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
"""
|
||||||
|
API permet d'ajouter / mettre à jour une ligne de planification d'une UE.
|
||||||
|
En effet une UE a sa propre planification qui comprend :
|
||||||
|
- code
|
||||||
|
- titre
|
||||||
|
- nb_heure
|
||||||
|
"""
|
||||||
|
@app.route('/myclass/api/Add_Update_Unite_Enseignement_Planif/', methods=['POST','GET'])
|
||||||
|
@crossdomain(origin='*')
|
||||||
|
def Add_Update_Unite_Enseignement_Planif():
|
||||||
|
# On recupere le corps (payload) de la requete
|
||||||
|
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||||
|
print(" ### Add_Update_Unite_Enseignement_Planif payload = ",payload)
|
||||||
|
status, retval = unite_enseignement_mgt.Add_Update_Unite_Enseignement_Planif(payload)
|
||||||
|
return jsonify(status=status, message=retval)
|
||||||
|
|
||||||
|
|
||||||
|
"""
|
||||||
|
API pour Supprimer une liste de planification UE
|
||||||
|
"""
|
||||||
|
@app.route('/myclass/api/Delete_List_Unite_Enseignement_Planif/', methods=['POST','GET'])
|
||||||
|
@crossdomain(origin='*')
|
||||||
|
def Delete_List_Unite_Enseignement_Planif():
|
||||||
|
# On recupere le corps (payload) de la requete
|
||||||
|
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||||
|
print(" ### Delete_List_Unite_Enseignement_Planif payload = ",payload)
|
||||||
|
status, retval = unite_enseignement_mgt.Delete_List_Unite_Enseignement_Planif(payload)
|
||||||
|
return jsonify(status=status, message=retval)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
"""
|
||||||
|
API d'import en masse des lignes de planification d'une UE avec un fichier csv
|
||||||
|
"""
|
||||||
|
@app.route('/myclass/api/Add_Update_Unite_Enseignement_Planif_mass/', methods=['POST','GET'])
|
||||||
|
@crossdomain(origin='*')
|
||||||
|
def Add_Update_Unite_Enseignement_Planif_mass():
|
||||||
|
|
||||||
|
# On recupere le corps (payload) de la requete
|
||||||
|
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||||
|
print(" ### Add_Update_Unite_Enseignement_Planif_mass payload = ",payload)
|
||||||
|
#print(request.files)
|
||||||
|
|
||||||
|
if request.method == 'POST':
|
||||||
|
# Create variable for uploaded file
|
||||||
|
f = request.files['File']
|
||||||
|
localStatus, message = SF.Add_Update_Unite_Enseignement_Planif_mass(f, MYSY_GV.TEMPORARY_DIRECTORY_V2, payload)
|
||||||
|
#status, retval = cm.add_class_mass(f, app.config['UPLOAD_FOLDER'], payload)
|
||||||
|
|
||||||
|
return jsonify(status=localStatus, message=message)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
"""
|
||||||
|
API pour Recuperer les lignes de planification d'une UE
|
||||||
|
"""
|
||||||
|
@app.route('/myclass/api/Get_List_Unite_Enseignement_Planif_lines/', methods=['POST','GET'])
|
||||||
|
@crossdomain(origin='*')
|
||||||
|
def Get_List_Unite_Enseignement_Planif_lines():
|
||||||
|
# On recupere le corps (payload) de la requete
|
||||||
|
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||||
|
print(" ### Get_List_Unite_Enseignement_Planif_lines payload = ",payload)
|
||||||
|
status, retval = unite_enseignement_mgt.Get_List_Unite_Enseignement_Planif_lines(payload)
|
||||||
|
return jsonify(status=status, message=retval)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
"""
|
||||||
|
API pour Recuperer les données d'une lignes de planification UE donnée
|
||||||
|
"""
|
||||||
|
@app.route('/myclass/api/Get_Given_Unite_Enseignement_Planif_Data/', methods=['POST','GET'])
|
||||||
|
@crossdomain(origin='*')
|
||||||
|
def Get_Given_Unite_Enseignement_Planif_Data():
|
||||||
|
# On recupere le corps (payload) de la requete
|
||||||
|
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||||
|
print(" ### Get_Given_Unite_Enseignement_Planif_Data payload = ",payload)
|
||||||
|
status, retval = unite_enseignement_mgt.Get_Given_Unite_Enseignement_Planif_Data(payload)
|
||||||
|
return jsonify(status=status, message=retval)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
print(" debut api")
|
print(" debut api")
|
||||||
|
|
|
@ -833,3 +833,725 @@ def Get_Givent_Unite_Enseignement_Data_Of_Given_Class(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 les données de unites d'enseignement de la formation "
|
return False, " Impossible de récupérer les données de unites d'enseignement de la formation "
|
||||||
|
|
||||||
|
|
||||||
|
"""
|
||||||
|
Cette fonction permet d'ajouter une ligne de planification d'une UE.
|
||||||
|
En effet une UE a sa propre planification qui comprend :
|
||||||
|
- code
|
||||||
|
- titre
|
||||||
|
- nb_heure
|
||||||
|
|
||||||
|
|
||||||
|
C'est ensuite cette planification qui sera utiliser dans la planification de la session avec des dates et heure
|
||||||
|
|
||||||
|
"""
|
||||||
|
def Add_Update_Unite_Enseignement_Planif(diction):
|
||||||
|
try:
|
||||||
|
diction = mycommon.strip_dictionary(diction)
|
||||||
|
|
||||||
|
"""
|
||||||
|
Verification des input acceptés
|
||||||
|
"""
|
||||||
|
field_list = ['token', 'code', 'titre', 'description', 'objectif', 'prerequis', 'volume_horaire',
|
||||||
|
'ue_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', 'code', 'titre', 'volume_horaire', 'ue_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
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
"""
|
||||||
|
Verifier que l'UE est valide
|
||||||
|
"""
|
||||||
|
is_valide_ue = MYSY_GV.dbname["unite_enseignement"].count_documents({'_id':ObjectId(str(diction['ue_id'])),
|
||||||
|
'partner_owner_recid':str(my_partner['recid']),
|
||||||
|
'valide':'1',
|
||||||
|
'locked':'0'})
|
||||||
|
|
||||||
|
if( is_valide_ue != 1 ):
|
||||||
|
mycommon.myprint(
|
||||||
|
str(inspect.stack()[0][3]) + " L'identifiant de l'ue est invalide ")
|
||||||
|
return False, " L'identifiant de l'ue est invalide "
|
||||||
|
|
||||||
|
mydata = {}
|
||||||
|
|
||||||
|
local_token = diction['token']
|
||||||
|
|
||||||
|
mydata = diction
|
||||||
|
del mydata['token']
|
||||||
|
|
||||||
|
# Initialisation des champs non envoyés à vide
|
||||||
|
for val in field_list:
|
||||||
|
if val not in diction.keys():
|
||||||
|
mydata[str(val)] = ""
|
||||||
|
|
||||||
|
|
||||||
|
"""
|
||||||
|
Verifier le volume horaire
|
||||||
|
"""
|
||||||
|
volume_horaire_status, volume_horaire_value = mycommon.IsFloat(str(diction['volume_horaire']))
|
||||||
|
if (volume_horaire_status is False):
|
||||||
|
mycommon.myprint(str(inspect.stack()[0][3]) + " Le volume horaire est invalide ")
|
||||||
|
return False, "Le volume horaire est invalide "
|
||||||
|
|
||||||
|
now = str(datetime.now())
|
||||||
|
mydata['date_update'] = now
|
||||||
|
mydata['valide'] = "1"
|
||||||
|
mydata['locked'] = "0"
|
||||||
|
mydata['partner_owner_recid'] = str(my_partner['recid'])
|
||||||
|
mydata['update_by'] = str(my_partner['_id'])
|
||||||
|
|
||||||
|
|
||||||
|
data_cle = {}
|
||||||
|
data_cle['partner_owner_recid'] = str(my_partner['recid'])
|
||||||
|
data_cle['ue_id'] = str(diction['ue_id'])
|
||||||
|
data_cle['code'] = str(diction['code'])
|
||||||
|
data_cle['valide'] = "1"
|
||||||
|
data_cle['locked'] = "0"
|
||||||
|
|
||||||
|
result = MYSY_GV.dbname['unite_enseignement_planif'].find_one_and_update(
|
||||||
|
data_cle,
|
||||||
|
{"$set": mydata},
|
||||||
|
upsert=True,
|
||||||
|
return_document=ReturnDocument.AFTER
|
||||||
|
)
|
||||||
|
|
||||||
|
if (result is None or "_id" not in result.keys()):
|
||||||
|
mycommon.myprint(
|
||||||
|
" mpossible de créer la planification de l'UE (2) ")
|
||||||
|
return False, " mpossible de créer la planification de l'UE "
|
||||||
|
|
||||||
|
return True, "La planification de l'UE a été correctement ajoutée / Mise à 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 créer la planification de l'UE"
|
||||||
|
|
||||||
|
|
||||||
|
"""
|
||||||
|
Supprimer une liste de planification UE
|
||||||
|
"""
|
||||||
|
def Delete_List_Unite_Enseignement_Planif(diction):
|
||||||
|
try:
|
||||||
|
diction = mycommon.strip_dictionary(diction)
|
||||||
|
|
||||||
|
"""
|
||||||
|
Verification des input acceptés
|
||||||
|
"""
|
||||||
|
field_list = ['token', 'tab_eu_planif_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', 'tab_eu_planif_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
|
||||||
|
|
||||||
|
tab_eu_planif_id = ""
|
||||||
|
if ("tab_eu_planif_id" in diction.keys()):
|
||||||
|
if diction['tab_eu_planif_id']:
|
||||||
|
tab_eu_planif_id = diction['tab_eu_planif_id']
|
||||||
|
|
||||||
|
tab_eu_planif_id_splited = str(tab_eu_planif_id).split(",")
|
||||||
|
|
||||||
|
tab_eu_planif_id_splited_Obj = []
|
||||||
|
for tmp in tab_eu_planif_id_splited:
|
||||||
|
if( tmp):
|
||||||
|
tab_eu_planif_id_splited_Obj.append(ObjectId(str(tmp)))
|
||||||
|
|
||||||
|
qery_delete = {'_id': {'$in': tab_eu_planif_id_splited_Obj},
|
||||||
|
'partner_owner_recid': str(my_partner['recid']),
|
||||||
|
'locked': '0',
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
ret_del_competence = MYSY_GV.dbname['unite_enseignement_planif'].delete_many(qery_delete)
|
||||||
|
|
||||||
|
return True, str(len(tab_eu_planif_id_splited_Obj))+ " ligne(s) supprimée(s) "
|
||||||
|
|
||||||
|
|
||||||
|
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 lignes de planification de l'UE "
|
||||||
|
|
||||||
|
|
||||||
|
"""
|
||||||
|
Ajouter des lignes de planification en masse avec un fichier csv
|
||||||
|
"""
|
||||||
|
|
||||||
|
def Add_Update_Unite_Enseignement_Planif_mass(file=None, Folder=None, diction=None):
|
||||||
|
try:
|
||||||
|
diction = mycommon.strip_dictionary(diction)
|
||||||
|
'''
|
||||||
|
# Verification que les champs reçus dans l'API sont bien dans la liste des champs autorisés
|
||||||
|
# Cela evite le cas ou une entité tierce ajouter les valeurs inconnu dans l'API
|
||||||
|
# Ici on doit mettre tous les champs possible (obligatoire ou non) de la BDD dans la liste
|
||||||
|
# field_list.
|
||||||
|
'''
|
||||||
|
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, Creation session annulée")
|
||||||
|
return False, " Le champ '" + val + "' n'existe pas, Creation session annulée "
|
||||||
|
|
||||||
|
'''
|
||||||
|
Une fois qu'on a controlé que toutes les clés mise dans l'API sont correcte. etape precedente,
|
||||||
|
On controle que les champs obligatoires sont presents dans la liste
|
||||||
|
'''
|
||||||
|
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
|
||||||
|
|
||||||
|
status, saved_file = mycommon.Upload_Save_CSV_File(file, Folder)
|
||||||
|
if (status == False):
|
||||||
|
return False, "Impossible d'importer la liste des sessions, le nom du fichier est incorrect "
|
||||||
|
|
||||||
|
# " Lecture du fichier "
|
||||||
|
# print(" Lecture du fichier : "+saved_file)
|
||||||
|
nb_line = 0
|
||||||
|
|
||||||
|
""""
|
||||||
|
update du 31/08/23 : Controle de l'integrité du fichier avant import
|
||||||
|
"""
|
||||||
|
local_controle_status, local_controle_message = Controle_Add_Update_Unite_Enseignement_Planif_mass(
|
||||||
|
saved_file,
|
||||||
|
Folder,
|
||||||
|
diction)
|
||||||
|
|
||||||
|
if (local_controle_status is False):
|
||||||
|
return local_controle_status, local_controle_message
|
||||||
|
|
||||||
|
print(" #### local_controle_message = ", local_controle_message)
|
||||||
|
|
||||||
|
df = pd.read_csv(saved_file, encoding='utf8', on_bad_lines='skip', sep=';', encoding_errors='ignore')
|
||||||
|
df = df.fillna('')
|
||||||
|
df = df.applymap(lambda x: x.strip() if isinstance(x, str) else x)
|
||||||
|
|
||||||
|
# Dictionnaire des champs utilisables
|
||||||
|
'''
|
||||||
|
# Verification que les noms des colonne sont bien corrects"
|
||||||
|
'''
|
||||||
|
field_list = ['code', 'titre', 'description', 'objectif', 'prerequis', 'volume_horaire', 'ue_code']
|
||||||
|
|
||||||
|
# Controle du nombre de lignes dans le fichier.
|
||||||
|
total_rows = len(df)
|
||||||
|
if (total_rows > MYSY_GV.MAX_EU_PLANIF_BY_CSV):
|
||||||
|
mycommon.myprint(
|
||||||
|
str(inspect.stack()[0][3]) + " Le fichier comporte plus de " + str(
|
||||||
|
MYSY_GV.MAX_EU_PLANIF_BY_CSV) + " lignes.")
|
||||||
|
return False, " Le fichier comporte plus de " + str(MYSY_GV.MAX_EU_PLANIF_BY_CSV) + " lignes."
|
||||||
|
|
||||||
|
# print(df.columns)
|
||||||
|
for val in df.columns:
|
||||||
|
if str(val).lower() not in field_list:
|
||||||
|
mycommon.myprint(
|
||||||
|
str(inspect.stack()[0][3]) + " : entete du fichier csv. '" + val + "' n'est pas acceptée")
|
||||||
|
return False, " Entete du fichier csv. La Colonne '" + val + "' n'est pas acceptée"
|
||||||
|
|
||||||
|
# Verification des champs obligatoires dans le fichier
|
||||||
|
field_list_obligatoire_file = ['code', 'titre', 'volume_horaire', 'ue_code']
|
||||||
|
|
||||||
|
for val in field_list_obligatoire_file:
|
||||||
|
if val not in df.columns:
|
||||||
|
mycommon.myprint(
|
||||||
|
str(inspect.stack()[0][
|
||||||
|
3]) + " : Le champ '" + val + "' n'est pas présent dans le fichier. Il est obligatoire")
|
||||||
|
return False, " Le champ '" + val + "' n'est pas présent dans le fichier. Il est obligatoire "
|
||||||
|
|
||||||
|
x = range(0, total_rows)
|
||||||
|
ignored_line = ""
|
||||||
|
nb_inserted_line = 0
|
||||||
|
|
||||||
|
for n in x:
|
||||||
|
mydata = {}
|
||||||
|
|
||||||
|
mydata['token'] = diction['token']
|
||||||
|
|
||||||
|
nb_inserted_line = nb_inserted_line + 1
|
||||||
|
# Si une ligne n'a aucune information obligatoire, alors on ignore la ligne
|
||||||
|
if (str(df['code'].values[n]) == "nan" or str(df['titre'].values[n]) == "nan" or
|
||||||
|
str(df['volume_horaire'].values[n]) == "nan" or str(df['ue_code'].values[n]) == "nan"):
|
||||||
|
mycommon.myprint(str(
|
||||||
|
inspect.stack()[0][
|
||||||
|
3]) + " - La ligne " + str(n + 2) + " a été ignorée")
|
||||||
|
ignored_line = str(n + 2) + " , " + str(ignored_line)
|
||||||
|
|
||||||
|
nb_inserted_line = nb_inserted_line - 1
|
||||||
|
continue
|
||||||
|
|
||||||
|
ue_code = ""
|
||||||
|
ue_id = ""
|
||||||
|
if ("ue_code" in df.keys()):
|
||||||
|
if (str(df['ue_code'].values[n])):
|
||||||
|
ue_code = str(df['ue_code'].values[n]).strip()
|
||||||
|
|
||||||
|
# On verifie la validité de l'unité d'enseignement
|
||||||
|
count_eu = MYSY_GV.dbname['unite_enseignement'].count_documents(
|
||||||
|
{'code': str(ue_code), 'valide': '1',
|
||||||
|
'locked': '0', 'partner_owner_recid': str(my_partner['recid'])})
|
||||||
|
|
||||||
|
if (count_eu != 1):
|
||||||
|
mycommon.myprint(
|
||||||
|
str(inspect.stack()[0][3]) + " Ligne " + str(
|
||||||
|
n + 2) + " : Le ue_code n'est pas valide.")
|
||||||
|
return False, " Ligne " + str(n + 2) + " : Le ue_code n'est pas valide."
|
||||||
|
|
||||||
|
eu_data = MYSY_GV.dbname['unite_enseignement'].find_one(
|
||||||
|
{'code': str(ue_code), 'valide': '1',
|
||||||
|
'locked': '0', 'partner_owner_recid': str(my_partner['recid'])})
|
||||||
|
|
||||||
|
ue_id = str(eu_data['_id'])
|
||||||
|
|
||||||
|
else:
|
||||||
|
mycommon.myprint(
|
||||||
|
str(inspect.stack()[0][3]) + " Erreur : Ligne " + str(
|
||||||
|
n + 2) + " : Le ue_code n'est pas invalide.")
|
||||||
|
return False, " Erreur : Ligne " + str(
|
||||||
|
n + 2) + " : Le ue_code n'est pas invalide."
|
||||||
|
|
||||||
|
mydata['ue_id'] = ue_id
|
||||||
|
|
||||||
|
|
||||||
|
titre = ""
|
||||||
|
if ("titre" in df.keys()):
|
||||||
|
titre = str(df['titre'].values[n]).strip()
|
||||||
|
mydata['titre'] = titre
|
||||||
|
|
||||||
|
if (titre == ""):
|
||||||
|
mycommon.myprint(
|
||||||
|
str(inspect.stack()[0][3]) + " Erreur : Ligne " + str(
|
||||||
|
n + 2) + " : Le Titre est vide .")
|
||||||
|
return False, " Erreur : Ligne " + str(
|
||||||
|
n + 2) + " : Le Titre est vide."
|
||||||
|
|
||||||
|
description = ""
|
||||||
|
if ("description" in df.keys()):
|
||||||
|
description = str(df['description'].values[n]).strip()
|
||||||
|
mydata['description'] = description
|
||||||
|
|
||||||
|
|
||||||
|
objectif = ""
|
||||||
|
if ("objectif" in df.keys()):
|
||||||
|
objectif = str(df['objectif'].values[n]).strip()
|
||||||
|
mydata['objectif'] = objectif
|
||||||
|
|
||||||
|
|
||||||
|
prerequis = ""
|
||||||
|
if ("prerequis" in df.keys()):
|
||||||
|
prerequis = str(df['prerequis'].values[n]).strip()
|
||||||
|
mydata['prerequis'] = prerequis
|
||||||
|
|
||||||
|
|
||||||
|
volume_horaire = "0"
|
||||||
|
if ("volume_horaire" in df.keys()):
|
||||||
|
if (str(df['volume_horaire'].values[n])):
|
||||||
|
volume_horaire = str(df['volume_horaire'].values[n]).strip()
|
||||||
|
|
||||||
|
local_status, volume_horaire = mycommon.IsFloat(volume_horaire)
|
||||||
|
if (local_status is False):
|
||||||
|
mycommon.myprint(
|
||||||
|
str(inspect.stack()[0][3]) + " Le champ 'volume_horaire' de la ligne " + str(
|
||||||
|
n + 2) + " est incorrecte.")
|
||||||
|
return False, " Le champ 'volume_horaire' de la ligne " + str(n + 2) + " est incorrecte. "
|
||||||
|
|
||||||
|
mydata['volume_horaire'] = str(volume_horaire)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
clean_dict = {k: mydata[k] for k in mydata if (str(mydata[k]) != "nan")}
|
||||||
|
|
||||||
|
print("#### Add_Update_Unite_Enseignement_Planif_mass : clean_dict ", clean_dict)
|
||||||
|
status, retval = Add_Update_Unite_Enseignement_Planif(clean_dict)
|
||||||
|
|
||||||
|
if (status is False):
|
||||||
|
return status, retval
|
||||||
|
|
||||||
|
print(str(total_rows) + " Lignes de planification ont été inserées")
|
||||||
|
|
||||||
|
message_ignored_line = ""
|
||||||
|
if (ignored_line):
|
||||||
|
message_ignored_line = " ATTENTION - Les lignes [" + str(
|
||||||
|
ignored_line) + "] ont été ignorées. car les toutes informations obligatoires ne sont pas fournies"
|
||||||
|
|
||||||
|
return True, str(nb_inserted_line) + " Lignes de planification ont été inserées / Mises à jour. " + str(message_ignored_line)
|
||||||
|
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||||
|
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
|
||||||
|
return False, "Impossible d'importer les lignes de planification de l'ue de formation en masse "
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
"""
|
||||||
|
Controle fichier avant import
|
||||||
|
"""
|
||||||
|
def Controle_Add_Update_Unite_Enseignement_Planif_mass(saved_file=None, Folder=None, diction=None):
|
||||||
|
try:
|
||||||
|
|
||||||
|
diction = mycommon.strip_dictionary(diction)
|
||||||
|
|
||||||
|
'''
|
||||||
|
# Verification que les champs reçus dans l'API sont bien dans la liste des champs autorisés
|
||||||
|
# Cela evite le cas ou une entité tierce ajouter les valeurs inconnu dans l'API
|
||||||
|
# Ici on doit mettre tous les champs possible (obligatoire ou non) de la BDD dans la liste
|
||||||
|
# field_list.
|
||||||
|
'''
|
||||||
|
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, Creation session annulée")
|
||||||
|
return False, " Le champ '" + val + "' n'existe pas, Creation session annulée "
|
||||||
|
|
||||||
|
'''
|
||||||
|
Une fois qu'on a controlé que toutes les clés mise dans l'API sont correcte. etape precedente,
|
||||||
|
On controle que les champs obligatoires sont presents dans la liste
|
||||||
|
'''
|
||||||
|
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
|
||||||
|
|
||||||
|
nb_line = 0
|
||||||
|
|
||||||
|
df = pd.read_csv(saved_file, encoding='utf8', on_bad_lines='skip', sep=';', encoding_errors='ignore')
|
||||||
|
df = df.fillna('')
|
||||||
|
df = df.applymap(lambda x: x.strip() if isinstance(x, str) else x)
|
||||||
|
|
||||||
|
# Dictionnaire des champs utilisables
|
||||||
|
'''
|
||||||
|
# Verification que les noms des colonne sont bien corrects"
|
||||||
|
'''
|
||||||
|
field_list = ['code', 'titre', 'description', 'objectif', 'prerequis', 'volume_horaire', 'ue_code']
|
||||||
|
|
||||||
|
# Controle du nombre de lignes dans le fichier.
|
||||||
|
total_rows = len(df)
|
||||||
|
if (total_rows > MYSY_GV.MAX_PARTICIPANT_BY_CSV):
|
||||||
|
mycommon.myprint(
|
||||||
|
str(inspect.stack()[0][3]) + " Le fichier comporte plus de " + str(
|
||||||
|
MYSY_GV.MAX_PARTICIPANT_BY_CSV) + " lignes.")
|
||||||
|
return False, " Le fichier comporte plus de " + str(MYSY_GV.MAX_PARTICIPANT_BY_CSV) + " lignes."
|
||||||
|
|
||||||
|
# print(df.columns)
|
||||||
|
for val in df.columns:
|
||||||
|
if str(val).lower() not in field_list:
|
||||||
|
mycommon.myprint(
|
||||||
|
str(inspect.stack()[0][3]) + " : entete du fichier csv. '" + val + "' n'est pas acceptée")
|
||||||
|
return False, " Entete du fichier csv. La Colonne '" + val + "' n'est pas acceptée"
|
||||||
|
|
||||||
|
# Verification des champs obligatoires dans le fichier
|
||||||
|
field_list_obligatoire_file = ['date_debut', 'date_fin', 'session_status', 'code_session',
|
||||||
|
'formation_code_externe']
|
||||||
|
|
||||||
|
for val in field_list_obligatoire_file:
|
||||||
|
if val not in df.columns:
|
||||||
|
mycommon.myprint(
|
||||||
|
str(inspect.stack()[0][
|
||||||
|
3]) + " : Le champ '" + val + "' n'est pas présent dans le fichier. Il est obligatoire")
|
||||||
|
return False, " Le champ '" + val + "' n'est pas présent dans le fichier. Il est obligatoire "
|
||||||
|
|
||||||
|
|
||||||
|
x = range(0, total_rows)
|
||||||
|
ignored_line = ""
|
||||||
|
nb_inserted_line = 0
|
||||||
|
|
||||||
|
for n in x:
|
||||||
|
mydata = {}
|
||||||
|
|
||||||
|
nb_inserted_line = nb_inserted_line + 1
|
||||||
|
# Si une ligne n'a aucune information obligatoire, alors on ignore la ligne
|
||||||
|
if (str(df['code'].values[n]) == "nan" or str(df['titre'].values[n]) == "nan" or
|
||||||
|
str(df['volume_horaire'].values[n]) == "nan" or str(df['ue_code'].values[n]) == "nan"):
|
||||||
|
mycommon.myprint(str(
|
||||||
|
inspect.stack()[0][
|
||||||
|
3]) + " - La ligne " + str(n + 2) + " a été ignorée")
|
||||||
|
ignored_line = str(n + 2) + " , " + str(ignored_line)
|
||||||
|
|
||||||
|
nb_inserted_line = nb_inserted_line - 1
|
||||||
|
continue
|
||||||
|
|
||||||
|
ue_code = ""
|
||||||
|
if ("ue_code" in df.keys()):
|
||||||
|
if (str(df['ue_code'].values[n])):
|
||||||
|
ue_code = str(df['ue_code'].values[n]).strip()
|
||||||
|
|
||||||
|
# On verifie la validité de l'unité d'enseignement
|
||||||
|
count_eu = MYSY_GV.dbname['unite_enseignement'].count_documents(
|
||||||
|
{'code': str(ue_code), 'valide': '1',
|
||||||
|
'locked': '0', 'partner_owner_recid': str(my_partner['recid'])})
|
||||||
|
|
||||||
|
if (count_eu != 1):
|
||||||
|
mycommon.myprint(
|
||||||
|
str(inspect.stack()[0][3]) + " Ligne " + str(
|
||||||
|
n + 2) + " : Le ue_code n'est pas valide.")
|
||||||
|
return False, " Ligne " + str(n + 2) + " : Le ue_code n'est pas valide."
|
||||||
|
|
||||||
|
|
||||||
|
else:
|
||||||
|
mycommon.myprint(
|
||||||
|
str(inspect.stack()[0][3]) + " Erreur : Ligne " + str(
|
||||||
|
n + 2) + " : Le ue_code n'est pas invalide.")
|
||||||
|
return False, " Erreur : Ligne " + str(
|
||||||
|
n + 2) + " : Le ue_code n'est pas invalide."
|
||||||
|
|
||||||
|
titre = ""
|
||||||
|
if ("titre" in df.keys()):
|
||||||
|
titre = str(df['titre'].values[n]).strip()
|
||||||
|
mydata['titre'] = titre
|
||||||
|
|
||||||
|
if( titre == ""):
|
||||||
|
mycommon.myprint(
|
||||||
|
str(inspect.stack()[0][3]) + " Erreur : Ligne " + str(
|
||||||
|
n + 2) + " : Le Titre est vide .")
|
||||||
|
return False, " Erreur : Ligne " + str(
|
||||||
|
n + 2) + " : Le Titre est vide."
|
||||||
|
|
||||||
|
|
||||||
|
volume_horaire = "0"
|
||||||
|
if ("volume_horaire" in df.keys()):
|
||||||
|
if (str(df['volume_horaire'].values[n])):
|
||||||
|
volume_horaire = str(df['volume_horaire'].values[n]).strip()
|
||||||
|
|
||||||
|
local_status, volume_horaire = mycommon.IsFloat(volume_horaire)
|
||||||
|
if (local_status is False):
|
||||||
|
mycommon.myprint(
|
||||||
|
str(inspect.stack()[0][3]) + " Le champ 'volume_horaire' de la ligne " + str(
|
||||||
|
n + 2) + " est incorrecte.")
|
||||||
|
return False, " Le champ 'volume_horaire' de la ligne " + str(n + 2) + " est incorrecte. "
|
||||||
|
|
||||||
|
mydata['volume_horaire'] = str(volume_horaire)
|
||||||
|
|
||||||
|
|
||||||
|
return True, str(total_rows)+" sessions dans le fichier"
|
||||||
|
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||||
|
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
|
||||||
|
return False, "Impossible de controler le fichier de la planification de l'UE en masse "
|
||||||
|
|
||||||
|
|
||||||
|
"""
|
||||||
|
Recuperer les lignes de planification d'une UE
|
||||||
|
"""
|
||||||
|
def Get_List_Unite_Enseignement_Planif_lines(diction):
|
||||||
|
try:
|
||||||
|
diction = mycommon.strip_dictionary(diction)
|
||||||
|
|
||||||
|
"""
|
||||||
|
Verification des input acceptés
|
||||||
|
"""
|
||||||
|
field_list = ['token', 'ue_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', ]
|
||||||
|
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
|
||||||
|
|
||||||
|
find_qry = {'partner_owner_recid': str(my_partner['recid']),
|
||||||
|
'valide': '1', 'locked': '0',
|
||||||
|
'ue_id':str(diction['ue_id'])}
|
||||||
|
|
||||||
|
print("### Get_List_Unite_Enseignement_Planif_lines find_qry = ", find_qry)
|
||||||
|
|
||||||
|
for retval in MYSY_GV.dbname['unite_enseignement_planif'].find(find_qry).sort([("_id", pymongo.DESCENDING), ]):
|
||||||
|
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 récupérer la planification de l'UE "
|
||||||
|
|
||||||
|
|
||||||
|
"""
|
||||||
|
Recuperer les données d'une lignes de planification UE donnée
|
||||||
|
"""
|
||||||
|
def Get_Given_Unite_Enseignement_Planif_Data(diction):
|
||||||
|
try:
|
||||||
|
diction = mycommon.strip_dictionary(diction)
|
||||||
|
|
||||||
|
"""
|
||||||
|
Verification des input acceptés
|
||||||
|
"""
|
||||||
|
field_list = ['token', 'tab_eu_planif_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', 'tab_eu_planif_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
|
||||||
|
|
||||||
|
tab_eu_planif_id = ""
|
||||||
|
if ("tab_eu_planif_id" in diction.keys()):
|
||||||
|
if diction['tab_eu_planif_id']:
|
||||||
|
tab_eu_planif_id = diction['tab_eu_planif_id']
|
||||||
|
|
||||||
|
tab_eu_planif_id_splited = str(tab_eu_planif_id).split(",")
|
||||||
|
|
||||||
|
tab_eu_planif_id_splited_Obj = []
|
||||||
|
for tmp in tab_eu_planif_id_splited:
|
||||||
|
if( tmp):
|
||||||
|
tab_eu_planif_id_splited_Obj.append(ObjectId(str(tmp)))
|
||||||
|
|
||||||
|
|
||||||
|
find_qry = {'partner_owner_recid': str(my_partner['recid']),
|
||||||
|
'valide': '1', 'locked': '0',
|
||||||
|
'_id': {'$in': tab_eu_planif_id_splited_Obj},}
|
||||||
|
|
||||||
|
RetObject = []
|
||||||
|
val_tmp = 0
|
||||||
|
for retval in MYSY_GV.dbname['unite_enseignement_planif'].find(find_qry).sort([("_id", pymongo.DESCENDING), ]):
|
||||||
|
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 récuperer la ligne de planification de l'UE "
|
||||||
|
|
Loading…
Reference in New Issue