sdf
parent
a44f0dcfda
commit
ea5daca054
|
@ -1,11 +1,16 @@
|
|||
<?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="ddd">
|
||||
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="17/05/2024 - 21h30">
|
||||
<change afterPath="$PROJECT_DIR$/note_evaluation_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$/Job_Cron.py" beforeDir="false" afterPath="$PROJECT_DIR$/Job_Cron.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$/class_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/class_mgt.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/notes_apprenant.py" beforeDir="false" afterPath="$PROJECT_DIR$/notes_apprenant_mgt.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/notes_apprenant_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/notes_apprenant_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 +80,6 @@
|
|||
<option name="presentableId" value="Default" />
|
||||
<updated>1680804787304</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00254" summary="2/04/24 - 20h30">
|
||||
<created>1712082670296</created>
|
||||
<option name="number" value="00254" />
|
||||
<option name="presentableId" value="LOCAL-00254" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1712082670298</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00255" summary="03/04/24 - 21h30">
|
||||
<created>1712174236031</created>
|
||||
<option name="number" value="00255" />
|
||||
|
@ -418,7 +416,14 @@
|
|||
<option name="project" value="LOCAL" />
|
||||
<updated>1715884005756</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="303" />
|
||||
<task id="LOCAL-00303" summary="17/05/2024 - 21h30">
|
||||
<created>1715973566772</created>
|
||||
<option name="number" value="00303" />
|
||||
<option name="presentableId" value="LOCAL-00303" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1715973566773</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="304" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="Vcs.Log.Tabs.Properties">
|
||||
|
@ -460,7 +465,6 @@
|
|||
</option>
|
||||
</component>
|
||||
<component name="VcsManagerConfiguration">
|
||||
<MESSAGE value="23/04/2024 - 14h06" />
|
||||
<MESSAGE value="25/04/2024 - 19h" />
|
||||
<MESSAGE value="27/04/2024 - 22h" />
|
||||
<MESSAGE value="28/04/2024 - 22h" />
|
||||
|
@ -485,6 +489,7 @@
|
|||
<MESSAGE value="sds" />
|
||||
<MESSAGE value="sdsdd" />
|
||||
<MESSAGE value="ddd" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="ddd" />
|
||||
<MESSAGE value="17/05/2024 - 21h30" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="17/05/2024 - 21h30" />
|
||||
</component>
|
||||
</project>
|
|
@ -635,8 +635,8 @@ def Cron_Monthly_Invoice_Inscription():
|
|||
data_for_invoicing['list_session'] = list_session
|
||||
|
||||
|
||||
print(" ### le tableau a facturer est : ")
|
||||
print(data_for_invoicing)
|
||||
#print(" ### le tableau a facturer est : ")
|
||||
#print(data_for_invoicing)
|
||||
|
||||
if( len(data_for_invoicing['detail_data']) > 0 ):
|
||||
print(" DEBUT FACTURATION")
|
||||
|
|
11302
Log/log_file.log
11302
Log/log_file.log
File diff suppressed because it is too large
Load Diff
|
@ -942,6 +942,75 @@ def GetActiveSessionFormation_List(diction):
|
|||
|
||||
|
||||
|
||||
"""
|
||||
Cette fonction recuperer les liste de sessions de formations
|
||||
d'un partenaire, mais avec une liste reduite de champs
|
||||
- _id
|
||||
- code_session
|
||||
- titre
|
||||
- class_internal_url
|
||||
- date_debut
|
||||
- date_fin
|
||||
|
||||
"""
|
||||
def Get_Partner_Session_Ftion_Reduice_Fields(diction):
|
||||
try:
|
||||
|
||||
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'est pas autorisé, Creation partenaire annulée")
|
||||
return False, " Impossible de récupérer la liste des session de formation"
|
||||
|
||||
"""
|
||||
Verification de la liste 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, "Impossible de récupérer la liste des session de formation"
|
||||
|
||||
# Le controle de token n'est effectué que une valeur est fournie dans le token
|
||||
if( 'token' in diction.keys() and len(str(diction['token'])) > 0) :
|
||||
local_status, my_partner = mycommon.Check_Connexion_And_Return_Partner_Data(diction)
|
||||
if (local_status is not True):
|
||||
return local_status, my_partner
|
||||
|
||||
local_status, my_partner = mycommon.Check_Connexion_And_Return_Partner_Data(diction)
|
||||
if (local_status is not True):
|
||||
return local_status, my_partner
|
||||
|
||||
RetObject = []
|
||||
|
||||
RetObject = []
|
||||
val_tmp = 0
|
||||
|
||||
for retval in MYSY_GV.dbname['session_formation'].find({'partner_owner_recid':str(my_partner['recid']),
|
||||
'valide':'1'},
|
||||
{'_id':1, 'code_session':1, 'titre':1,
|
||||
'class_internal_url':1, 'date_debut':1,
|
||||
'date_fin':1}):
|
||||
user = retval
|
||||
user['id'] = str(val_tmp)
|
||||
|
||||
RetObject.append(mycommon.JSONEncoder().encode(user))
|
||||
val_tmp = val_tmp + 1
|
||||
|
||||
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) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
|
||||
return False, "Impossible de récupérer la liste des sessions de formation valides et actives."
|
||||
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Cette fonction recupere UNIQUEMENT LES VILLES ET SI A DISTANCEsessions de formation actives et valides
|
||||
d'une formation données ET les sessions "on demande"
|
||||
|
|
71
class_mgt.py
71
class_mgt.py
|
@ -2851,6 +2851,77 @@ def find_partner_class_like(diction):
|
|||
return False, " Impossible de récupérer la formation"
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Cette fonction retourne la liste des formations
|
||||
d'un parenaire mais seulement les champs :
|
||||
- _id
|
||||
- external_code,
|
||||
- internal_code
|
||||
- internal_url
|
||||
"""
|
||||
|
||||
|
||||
def Get_Partner_All_Class_Few_Fields(diction):
|
||||
try:
|
||||
'''
|
||||
# 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]) + " - get_partner_class : Le champ '" + val + "' n'existe pas, Creation formation annulée")
|
||||
return False, " Impossible de récupérer la formation"
|
||||
|
||||
'''
|
||||
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, " Impossible de récupérer la formation"
|
||||
|
||||
|
||||
|
||||
local_status, my_partner = mycommon.Check_Connexion_And_Return_Partner_Data({'token': str(diction['token'])})
|
||||
if (local_status is not True):
|
||||
return local_status, my_partner
|
||||
|
||||
RetObject = []
|
||||
val_tmp = 0
|
||||
for retVal in MYSY_GV.dbname['myclass'].find(
|
||||
{'partner_owner_recid': my_partner['recid'],
|
||||
'valide':'1',
|
||||
'locked':'0'},
|
||||
{'_id': 1, 'external_code': 1, 'internal_code': 1, 'internal_url': 1, }
|
||||
).sort([("_id", pymongo.DESCENDING), ]):
|
||||
# mycommon.myprint(str(retVal))
|
||||
user = retVal
|
||||
user['id'] = str(val_tmp)
|
||||
|
||||
RetObject.append(JSONEncoder().encode(user))
|
||||
val_tmp = val_tmp + 1
|
||||
|
||||
# print(" #### return find_partner_class_like = : ", str(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 la liste des formations"
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Cette fonction retrourne
|
||||
- le code externe,
|
||||
|
|
134
main.py
134
main.py
|
@ -88,6 +88,7 @@ import domaine_formation_mgt as domaine_formation_mgt
|
|||
import invoice_paiement_mgt as invoice_paiement_mgt
|
||||
import Job_Cron as Job_Cron
|
||||
import notes_apprenant_mgt as notes_apprenant_mgt
|
||||
import note_evaluation_mgt as note_evaluation_mgt
|
||||
|
||||
|
||||
app = Flask(__name__)
|
||||
|
@ -416,6 +417,24 @@ def find_partner_class_like():
|
|||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
"""
|
||||
Cette API retourne la liste des formations
|
||||
d'un parenaire mais seulement les champs :
|
||||
- _id
|
||||
- external_code,
|
||||
- internal_code
|
||||
- internal_url
|
||||
"""
|
||||
@app.route('/myclass/api/Get_Partner_All_Class_Few_Fields/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Get_Partner_All_Class_Few_Fields():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Get_Partner_All_Class_Few_Fields payload = ",str(payload)+" IP requester = "+str(request.remote_addr))
|
||||
status, retval = cm.Get_Partner_All_Class_Few_Fields(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
|
||||
|
||||
"""
|
||||
|
@ -2048,6 +2067,27 @@ def GetActiveSession_Cities_And_Distance_Formation_List():
|
|||
|
||||
|
||||
|
||||
"""
|
||||
API pour recuperer les liste de sessions de formations
|
||||
d'un partenaire, mais avec une liste reduite de champs
|
||||
- _id
|
||||
- code_session
|
||||
- titre
|
||||
- class_internal_url
|
||||
- date_debut
|
||||
- date_fin
|
||||
|
||||
"""
|
||||
@app.route('/myclass/api/Get_Partner_Session_Ftion_Reduice_Fields/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Get_Partner_Session_Ftion_Reduice_Fields():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Get_Partner_Session_Ftion_Reduice_Fields : payload = ",str(payload))
|
||||
localStatus, message= SF.Get_Partner_Session_Ftion_Reduice_Fields(payload)
|
||||
return jsonify(status=localStatus, message=message )
|
||||
|
||||
|
||||
|
||||
"""
|
||||
API de toutes sessions de formation valide, (peu importe qu'elles soient terminées ou pas
|
||||
|
@ -9324,6 +9364,96 @@ def Delete_Class_UE_Evaluation():
|
|||
|
||||
|
||||
|
||||
"""
|
||||
API pour planifier une évaluation
|
||||
"""
|
||||
@app.route('/myclass/api/Add_Evaluation_Planification/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Add_Evaluation_Planification():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Add_Evaluation_Planification payload = ",payload)
|
||||
status, retval = note_evaluation_mgt.Add_Evaluation_Planification(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
|
||||
"""
|
||||
API pour MAJ une évaluation planifiée
|
||||
"""
|
||||
@app.route('/myclass/api/Update_Evaluation_Planification/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Update_Evaluation_Planification():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Update_Evaluation_Planification payload = ",payload)
|
||||
status, retval = note_evaluation_mgt.Update_Evaluation_Planification(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
|
||||
|
||||
"""
|
||||
API pour Recuperation de la liste des evaluation planifiée
|
||||
"""
|
||||
@app.route('/myclass/api/Get_List_Evaluation_Planification_No_Filter/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Get_List_Evaluation_Planification_No_Filter():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Get_List_Evaluation_Planification_No_Filter payload = ",payload)
|
||||
status, retval = note_evaluation_mgt.Get_List_Evaluation_Planification_No_Filter(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
|
||||
"""
|
||||
API pour Recuperation de la liste des evaluation planifiée avec des filter sur :
|
||||
- la formation (titre),
|
||||
- l'UE (code_ue)
|
||||
- la session (class) (code_session)
|
||||
"""
|
||||
@app.route('/myclass/api/Get_List_Evaluation_Planification_With_Filter/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Get_List_Evaluation_Planification_With_Filter():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Get_List_Evaluation_Planification_With_Filter payload = ",payload)
|
||||
status, retval = note_evaluation_mgt.Get_List_Evaluation_Planification_With_Filter(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
|
||||
"""
|
||||
API pour Recuperer les données d'une évaluation planifiée
|
||||
"""
|
||||
@app.route('/myclass/api/Get_Given_Evaluation_Planification/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Get_Given_Evaluation_Planification():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Get_Given_Evaluation_Planification payload = ",payload)
|
||||
status, retval = note_evaluation_mgt.Get_Given_Evaluation_Planification(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
|
||||
"""
|
||||
API pour Supprimer une evaluation planifiée
|
||||
|
||||
/!\ : les regles de suppression ne sont pas encore implémentés
|
||||
"""
|
||||
@app.route('/myclass/api/Delete_Evaluation_Planification/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Delete_Evaluation_Planification():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Delete_Evaluation_Planification payload = ",payload)
|
||||
status, retval = note_evaluation_mgt.Delete_Evaluation_Planification(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -9348,7 +9478,7 @@ if __name__ == '__main__':
|
|||
/!\ Dasactivé en dev pour pas consommer de ressource pr rien.
|
||||
"""
|
||||
|
||||
"""
|
||||
|
||||
scheduler = BackgroundScheduler()
|
||||
# Create the job
|
||||
scheduler.add_job(func=Flask_Cron_Strip_Get_Customer_Abonnement_Data, trigger="interval", minutes=3)
|
||||
|
@ -9361,7 +9491,7 @@ if __name__ == '__main__':
|
|||
|
||||
# /!\ IMPORTANT /!\ : Shut down the scheduler when exiting the app
|
||||
atexit.register(lambda: scheduler.shutdown())
|
||||
"""
|
||||
|
||||
|
||||
app.run(host='localhost', port=MYSY_GV.MYSY_PORT_DEV, debug=True, threaded=True)
|
||||
# Create the background scheduler
|
||||
|
|
|
@ -0,0 +1,791 @@
|
|||
"""
|
||||
Ce fichier permet de gerer les evaluations au sens propre du terme
|
||||
Par exemple la saisie d'une evaluation planifiée :
|
||||
- formation,
|
||||
- ue,
|
||||
- responsable (rh)
|
||||
- type eval (proje, td, controle contonie, etc)
|
||||
- date
|
||||
- lieu
|
||||
- ressource
|
||||
- apprenant
|
||||
- session_id (la class)
|
||||
|
||||
En suite la saisie de la note dans la collection : 'note_evaluation_apprenant'
|
||||
|
||||
"""
|
||||
import bson
|
||||
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
|
||||
import jinja2
|
||||
from flask import send_file
|
||||
from xhtml2pdf import pisa
|
||||
from email.message import EmailMessage
|
||||
from email.mime.text import MIMEText
|
||||
from email import encoders
|
||||
import smtplib
|
||||
from email.mime.multipart import MIMEMultipart
|
||||
from email.mime.text import MIMEText
|
||||
from email.mime.base import MIMEBase
|
||||
from email import encoders
|
||||
|
||||
"""
|
||||
Ajout d'une evaluation planifiée
|
||||
"""
|
||||
def Add_Evaluation_Planification(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', 'code', 'titre', 'description', 'comment',
|
||||
'class_id', 'class_eu_id', 'type_eval_id',
|
||||
'eval_date_heure_debut', 'eval_date_heure_fin', 'statut', 'adress', 'cp', 'ville',
|
||||
'pays', 'responsable_id', 'session_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', 'class_id', 'class_eu_id', 'type_eval_id',
|
||||
'eval_date_heure_debut', 'eval_date_heure_fin',]
|
||||
|
||||
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 la formation et l'ue de la formation existe et sont valides
|
||||
is_existe_class_and_class_ue = MYSY_GV.dbname['myclass'].count_documents({ '_id':ObjectId(str(diction['class_id'])),
|
||||
'list_unite_enseignement._id': str(diction['class_eu_id']),
|
||||
'partner_owner_recid':my_partner['recid'],
|
||||
'valide':'1',
|
||||
'locked':'0'})
|
||||
|
||||
|
||||
if( is_existe_class_and_class_ue != 1 ):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " La formation et l'UE ne sont pas cohérents ")
|
||||
return False, " La formation et l'UE ne sont pas cohérents "
|
||||
|
||||
|
||||
"""
|
||||
Verifier que le type d'évaluation est valide
|
||||
"""
|
||||
is_valide_type_eval = MYSY_GV.dbname['type_evaluation'].count_documents({'_id':ObjectId(str(diction['type_eval_id'])),
|
||||
'partner_owner_recid': my_partner[
|
||||
'recid'],
|
||||
'valide': '1',
|
||||
'locked': '0'})
|
||||
|
||||
if (is_valide_type_eval != 1):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " L'identifiant du type d'évaluation est invalide ")
|
||||
return False, " L'identifiant du type d'évaluation est invalide "
|
||||
|
||||
|
||||
"""
|
||||
Si responsable_id, alors verifier la validité
|
||||
"""
|
||||
if( 'responsable_id' in diction.keys() and diction['responsable_id']):
|
||||
is_valide_responsable = MYSY_GV.dbname['ressource_humaine'].count_documents(
|
||||
{'_id': ObjectId(str(diction['responsable_id'])),
|
||||
'partner_recid': my_partner[
|
||||
'recid'],
|
||||
'valide': '1',
|
||||
'locked': '0'})
|
||||
|
||||
if (is_valide_responsable != 1):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " L'identifiant du responsable de l'évaluation est invalide ")
|
||||
return False, " L'identifiant du responsable de l'évaluation est invalide "
|
||||
|
||||
|
||||
"""
|
||||
Si session_id, verifier la validité de la session
|
||||
"""
|
||||
if ('session_id' in diction.keys() and diction['session_id']):
|
||||
is_valide_session_id = MYSY_GV.dbname['session_formation'].count_documents(
|
||||
{'_id': ObjectId(str(diction['session_id'])),
|
||||
'partner_owner_recid': my_partner[
|
||||
'recid'],
|
||||
'valide': '1',
|
||||
})
|
||||
|
||||
if (is_valide_session_id != 1):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " L'identifiant de la session (class) est invalide ")
|
||||
return False, " L'identifiant de la session (class) est invalide "
|
||||
|
||||
"""
|
||||
Verifier que les date_heure_debut et date_heure_fin sont ok
|
||||
"""
|
||||
eval_date_heure_debut = str(diction['eval_date_heure_debut']).strip()[0:16]
|
||||
local_status = mycommon.CheckisDate_Hours(eval_date_heure_debut)
|
||||
if (local_status is False):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " La date de début d'évaluation n'est pas au format jj/mm/aaaa hh:mm")
|
||||
|
||||
return False, " La date de début d'évaluation n'est pas au format jj/mm/aaaa hh:mm"
|
||||
|
||||
eval_date_heure_fin = str(diction['eval_date_heure_fin']).strip()[0:16]
|
||||
local_status = mycommon.CheckisDate_Hours(eval_date_heure_fin)
|
||||
if (local_status is False):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " La date de fin d'évaluation n'est pas au format jj/mm/aaaa hh:mm")
|
||||
|
||||
return False, " La date de fin d'évaluation n'est pas au format jj/mm/aaaa hh:mm"
|
||||
|
||||
## Verification de la cohérence des dates. Date_du doit <= Date_au
|
||||
if (datetime.strptime(str(eval_date_heure_debut).strip(), '%d/%m/%Y %H:%M') > datetime.strptime(
|
||||
str(eval_date_heure_fin).strip(), '%d/%m/%Y %H:%M')):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " La date debut " + str(eval_date_heure_debut) + " est postérieure à la date de fin " + str(eval_date_heure_fin) + " ")
|
||||
|
||||
return False, " La date debut " + str(eval_date_heure_debut) + " est postérieure à la date de fin " + str(eval_date_heure_fin) + " "
|
||||
|
||||
|
||||
new_data = diction
|
||||
del diction['token']
|
||||
|
||||
# Initialisation des champs non envoyés à vide
|
||||
for val in field_list:
|
||||
if val not in diction.keys():
|
||||
new_data[str(val)] = ""
|
||||
|
||||
new_data['valide'] = "1"
|
||||
new_data['locked'] = "0"
|
||||
|
||||
new_data['date_update'] = str(datetime.now())
|
||||
new_data['update_by'] = str(my_partner['_id'])
|
||||
new_data['partner_owner_recid'] = str(my_partner['recid'])
|
||||
|
||||
inserted_id = MYSY_GV.dbname['note_evaluation'].insert_one(new_data).inserted_id
|
||||
if (not inserted_id):
|
||||
mycommon.myprint(
|
||||
" Impossible de créer l'évaluation (2) ")
|
||||
return False, " Impossible de créer l'évaluation (2) "
|
||||
|
||||
|
||||
return True, " L'évaluation a été correctement ajoutée"
|
||||
|
||||
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 l'évaluation "
|
||||
|
||||
|
||||
"""
|
||||
Mettre à jour une évalution planifiée
|
||||
"""
|
||||
def Update_Evaluation_Planification(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', 'evaluation_id', 'code', 'titre', 'description', 'comment',
|
||||
'class_id', 'class_eu_id', 'type_eval_id',
|
||||
'eval_date_heure_debut', 'eval_date_heure_fin', 'statut', 'site_id', 'adress', 'cp', 'ville',
|
||||
'pays', 'responsable_id', 'session_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', 'evaluation_id', 'code', 'titre', 'class_id', 'class_eu_id', 'type_eval_id',
|
||||
'eval_date_heure_debut', 'eval_date_heure_fin',]
|
||||
|
||||
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 class_ue_id est valide
|
||||
"""
|
||||
is_evaluation_id_existe_class = MYSY_GV.dbname['note_evaluation'].count_documents({ '_id':ObjectId(str(diction['evaluation_id'])),
|
||||
'partner_owner_recid':my_partner['recid'],
|
||||
'valide': '1',
|
||||
'locked': '0'
|
||||
})
|
||||
|
||||
if (is_evaluation_id_existe_class != 1):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " L'identifiant de l'évaluation est invalide ")
|
||||
return False, " L'identifiant de l'évaluation est invalide "
|
||||
|
||||
|
||||
# Verifier que la formation et l'ue de la formation existe et sont valides
|
||||
is_existe_class_and_class_ue = MYSY_GV.dbname['myclass'].count_documents(
|
||||
{'_id': ObjectId(str(diction['class_id'])),
|
||||
'list_unite_enseignement._id': str(diction['class_eu_id']),
|
||||
'partner_owner_recid': my_partner['recid'],
|
||||
'valide': '1',
|
||||
'locked': '0'})
|
||||
|
||||
if (is_existe_class_and_class_ue != 1):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " La formation et l'UE ne sont pas cohérents ")
|
||||
return False, " La formation et l'UE ne sont pas cohérents "
|
||||
|
||||
|
||||
"""
|
||||
Verifier que le type d'évaluation est valide
|
||||
"""
|
||||
is_valide_type_eval = MYSY_GV.dbname['type_evaluation'].count_documents(
|
||||
{'_id': ObjectId(str(diction['type_eval_id'])),
|
||||
'partner_owner_recid': my_partner[
|
||||
'recid'],
|
||||
'valide': '1',
|
||||
'locked': '0'})
|
||||
|
||||
if (is_valide_type_eval != 1):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " L'identifiant du type d'évaluation est invalide ")
|
||||
return False, " L'identifiant du type d'évaluation est invalide "
|
||||
|
||||
"""
|
||||
Si responsable_id, alors verifier la validité
|
||||
"""
|
||||
if ('responsable_id' in diction.keys() and diction['responsable_id']):
|
||||
is_valide_responsable = MYSY_GV.dbname['ressource_humaine'].count_documents(
|
||||
{'_id': ObjectId(str(diction['responsable_id'])),
|
||||
'partner_recid': my_partner[
|
||||
'recid'],
|
||||
'valide': '1',
|
||||
'locked': '0'})
|
||||
|
||||
if (is_valide_responsable != 1):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " L'identifiant du responsable de l'évaluation est invalide ")
|
||||
return False, " L'identifiant du responsable de l'évaluation est invalide "
|
||||
|
||||
"""
|
||||
Si session_id, verifier la validité de la session
|
||||
"""
|
||||
if ('session_id' in diction.keys() and diction['session_id']):
|
||||
is_valide_session_id = MYSY_GV.dbname['session_formation'].count_documents(
|
||||
{'_id': ObjectId(str(diction['session_id'])),
|
||||
'partner_owner_recid': my_partner[
|
||||
'recid'],
|
||||
'valide': '1',
|
||||
})
|
||||
|
||||
if (is_valide_session_id != 1):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " L'identifiant de la session (class) est invalide ")
|
||||
return False, " L'identifiant de la session (class) est invalide "
|
||||
|
||||
|
||||
"""
|
||||
Verifier que les date_heure_debut et date_heure_fin sont ok
|
||||
"""
|
||||
eval_date_heure_debut = str(diction['eval_date_heure_debut']).strip()[0:16]
|
||||
local_status = mycommon.CheckisDate_Hours(eval_date_heure_debut)
|
||||
if (local_status is False):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " La date de début d'évaluation n'est pas au format jj/mm/aaaa hh:mm")
|
||||
|
||||
return False, " La date de début d'évaluation n'est pas au format jj/mm/aaaa hh:mm"
|
||||
|
||||
eval_date_heure_fin = str(diction['eval_date_heure_fin']).strip()[0:16]
|
||||
local_status = mycommon.CheckisDate_Hours(eval_date_heure_fin)
|
||||
if (local_status is False):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " La date de fin d'évaluation n'est pas au format jj/mm/aaaa hh:mm")
|
||||
|
||||
return False, " La date de fin d'évaluation n'est pas au format jj/mm/aaaa hh:mm"
|
||||
|
||||
## Verification de la cohérence des dates. Date_du doit <= Date_au
|
||||
if (datetime.strptime(str(eval_date_heure_debut).strip(), '%d/%m/%Y %H:%M') > datetime.strptime(
|
||||
str(eval_date_heure_fin).strip(), '%d/%m/%Y %H:%M')):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " La date debut " + str(
|
||||
eval_date_heure_debut) + " est postérieure à la date de fin " + str(eval_date_heure_fin) + " ")
|
||||
|
||||
return False, " La date debut " + str(eval_date_heure_debut) + " est postérieure à la date de fin " + str(
|
||||
eval_date_heure_fin) + " "
|
||||
|
||||
|
||||
local_evaluation_id = diction['evaluation_id']
|
||||
new_data = diction
|
||||
del diction['token']
|
||||
del diction['evaluation_id']
|
||||
|
||||
|
||||
new_data['valide'] = "1"
|
||||
new_data['locked'] = "0"
|
||||
|
||||
new_data['date_update'] = str(datetime.now())
|
||||
new_data['update_by'] = str(my_partner['_id'])
|
||||
new_data['partner_owner_recid'] = str(my_partner['recid'])
|
||||
|
||||
result = MYSY_GV.dbname['note_evaluation'].find_one_and_update(
|
||||
{'_id': ObjectId(str(local_evaluation_id)),
|
||||
'partner_owner_recid': my_partner['recid'],
|
||||
'valide': '1',
|
||||
'locked': '0'
|
||||
},
|
||||
{"$set": new_data},
|
||||
upsert=False,
|
||||
return_document=ReturnDocument.AFTER
|
||||
)
|
||||
|
||||
|
||||
|
||||
if (result is None or "_id" not in result.keys()):
|
||||
mycommon.myprint(
|
||||
" Impossible de mettre à jour l'évaluation (2) ")
|
||||
return False, " Impossible de mettre à jour l'évaluation (2) "
|
||||
|
||||
|
||||
|
||||
|
||||
return True, " L'évaluation a été correctement 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 mettre à jour l'évaluation "
|
||||
|
||||
|
||||
"""
|
||||
Recuperation de la liste des evaluation planifiée
|
||||
"""
|
||||
|
||||
def Get_List_Evaluation_Planification_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
|
||||
|
||||
|
||||
"""
|
||||
Clés de mise à jour
|
||||
"""
|
||||
data_cle = {}
|
||||
data_cle['partner_owner_recid'] = str(my_partner['recid'])
|
||||
data_cle['valide'] = "1"
|
||||
data_cle['locked'] = "0"
|
||||
|
||||
|
||||
RetObject = []
|
||||
val_tmp = 0
|
||||
|
||||
for retval in MYSY_GV.dbname['note_evaluation'].find(data_cle).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 liste des évaluations "
|
||||
|
||||
|
||||
"""
|
||||
Recuperation de la liste des evaluation planifiée avec des filter sur :
|
||||
- la formation (code),
|
||||
- l'UE (code_ue)
|
||||
- la session (class) (code_session)
|
||||
"""
|
||||
|
||||
def Get_List_Evaluation_Planification_With_Filter(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token','class_external_code', 'code_session', 'code_ue']
|
||||
|
||||
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_id = {}
|
||||
list_session_id = []
|
||||
if ("code_session" in diction.keys()):
|
||||
filt_code_session = {'code_session': {'$regex': str(diction['code_session']), "$options": "i"}}
|
||||
|
||||
"""qry_list_session_id = { { '$and' :[ {'code_session': {'$regex': str(diction['code_session']), "$options": "i"}},
|
||||
{'partner_owner_recid': str(partner_recid)} ]}, {'_id':1}}
|
||||
"""
|
||||
|
||||
qry_list_session_id = {"$and": [{'code_session': {'$regex': str(diction['code_session']), "$options": "i"}},
|
||||
{'partner_owner_recid': str(my_partner['recid'])}]}
|
||||
|
||||
# print(" ### qry_list_session_id aa = ", qry_list_session_id)
|
||||
list_session_id_count = MYSY_GV.dbname['session_formation'].count_documents(qry_list_session_id)
|
||||
|
||||
if (list_session_id_count <= 0):
|
||||
# Aucune session
|
||||
return True, []
|
||||
|
||||
for val in MYSY_GV.dbname['session_formation'].find(qry_list_session_id):
|
||||
list_session_id.append(str(val['_id']))
|
||||
|
||||
#print(" ### liste des Id des sessions eligible list_session_id = ", list_session_id)
|
||||
filt_session_id = {'session_id': {'$in': list_session_id, }}
|
||||
|
||||
|
||||
|
||||
filt_class_id = {}
|
||||
list_class_id = []
|
||||
if ("class_external_code" in diction.keys()):
|
||||
filt_class_title = {'external_code': {'$regex': str(diction['class_external_code']), "$options": "i"}}
|
||||
|
||||
|
||||
qry_list_class_id = {"$and": [{'external_code': {'$regex': str(diction['class_external_code']), "$options": "i"}},
|
||||
{'partner_owner_recid': str(my_partner['recid'])}]}
|
||||
|
||||
print(" ### qry_list_class_id aa = ", qry_list_class_id)
|
||||
list_class_id_count = MYSY_GV.dbname['myclass'].count_documents(qry_list_class_id)
|
||||
|
||||
if (list_class_id_count <= 0):
|
||||
# Aucune session
|
||||
return True, []
|
||||
|
||||
for val in MYSY_GV.dbname['myclass'].find(qry_list_class_id):
|
||||
list_class_id.append(str(val['_id']))
|
||||
|
||||
# print(" ### liste des Id des sessions eligible list_session_id = ", list_session_id)
|
||||
filt_class_id = {'class_id': {'$in': list_class_id, }}
|
||||
|
||||
|
||||
|
||||
filt_ue_id = {}
|
||||
list_ue_id = []
|
||||
if ("code_ue" in diction.keys()):
|
||||
filt_code_ue = {'code': {'$regex': str(diction['code_ue']), "$options": "i"}}
|
||||
|
||||
"""qry_list_session_id = { { '$and' :[ {'code_session': {'$regex': str(diction['code_session']), "$options": "i"}},
|
||||
{'partner_owner_recid': str(partner_recid)} ]}, {'_id':1}}
|
||||
"""
|
||||
|
||||
qry_list_ue_id = {"$and": [{'code': {'$regex': str(diction['code_ue']), "$options": "i"}},
|
||||
{'partner_owner_recid': str(my_partner['recid'])}]}
|
||||
|
||||
#print(" ### qry_list_session_id aa = ", qry_list_ue_id)
|
||||
list_ue_id_count = MYSY_GV.dbname['unite_enseignement'].count_documents(qry_list_ue_id)
|
||||
|
||||
if (list_ue_id_count <= 0):
|
||||
# Aucune session
|
||||
return True, []
|
||||
|
||||
for val in MYSY_GV.dbname['unite_enseignement'].find(qry_list_ue_id):
|
||||
list_ue_id.append(str(val['_id']))
|
||||
|
||||
|
||||
filt_ue_id = {'class_eu_id': {'$in': list_ue_id, }}
|
||||
#print(" ### filt_ue_id des Id list_ue_id ", filt_ue_id)
|
||||
|
||||
|
||||
"""
|
||||
Clés de mise à jour
|
||||
"""
|
||||
data_cle = {}
|
||||
data_cle['partner_owner_recid'] = str(my_partner['recid'])
|
||||
data_cle['valide'] = "1"
|
||||
data_cle['locked'] = "0"
|
||||
|
||||
query = {"$and": [filt_session_id, filt_class_id, filt_ue_id, data_cle]}
|
||||
|
||||
|
||||
|
||||
RetObject = []
|
||||
val_tmp = 0
|
||||
|
||||
for retval in MYSY_GV.dbname['note_evaluation'].find(query).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 liste des évaluations "
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Recuperer les données d'une évaluation planifiée
|
||||
"""
|
||||
def Get_Given_Evaluation_Planification(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', 'evaluation_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', 'evaluation_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['valide'] = "1"
|
||||
data_cle['locked'] = "0"
|
||||
data_cle['_id'] = ObjectId(str(diction['evaluation_id']))
|
||||
|
||||
|
||||
RetObject = []
|
||||
val_tmp = 0
|
||||
|
||||
for retval in MYSY_GV.dbname['note_evaluation'].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 récupérer le types d'évaluation "
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Supprimer une evaluation planifiée
|
||||
|
||||
/!\ : les regles de suppression ne sont pas encore implémentés
|
||||
"""
|
||||
def Delete_Evaluation_Planification(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', 'evaluation_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', 'evaluation_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 class_ue_id est valide
|
||||
"""
|
||||
is_evaluation_id_existe_class = MYSY_GV.dbname['note_evaluation'].count_documents({ '_id':ObjectId(str(diction['evaluation_id'])),
|
||||
'partner_owner_recid':my_partner['recid'],
|
||||
'valide': '1',
|
||||
'locked': '0'
|
||||
})
|
||||
|
||||
if (is_evaluation_id_existe_class != 1):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " L'identifiant de l'évaluation est invalide ")
|
||||
return False, " L'identifiant de l'évaluation est invalide "
|
||||
|
||||
delete = MYSY_GV.dbname['note_evaluation'].delete_one({ '_id':ObjectId(str(diction['evaluation_id'])),
|
||||
'partner_owner_recid':my_partner['recid'],
|
||||
'valide': '1',
|
||||
'locked': '0'
|
||||
} )
|
||||
|
||||
|
||||
|
||||
return True, " La évaluation a été correctement supprimée"
|
||||
|
||||
|
||||
|
||||
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 l'évaluation "
|
|
@ -717,7 +717,7 @@ def Get_List_Class_Evaluation(diction):
|
|||
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 évaluation de la formation "
|
||||
return False, " Impossible de récupérer la liste des évaluations de la formation "
|
||||
|
||||
|
||||
|
||||
|
@ -859,7 +859,6 @@ def Delete_Class_UE_Evaluation(diction):
|
|||
'locked': '0'
|
||||
} )
|
||||
|
||||
print(" ")
|
||||
|
||||
return True, " La évaluation a été correctement supprimée"
|
||||
|
||||
|
|
|
@ -1449,9 +1449,9 @@ def partner_login(diction):
|
|||
"""
|
||||
return_data['user_access_right'] = []
|
||||
qry = {'valide':'1', 'locked':'0','partner_owner_recid':str(partner_recid),'user_id':str(ressource_humaine_id)}
|
||||
#print(" #### qry = ", qry)
|
||||
print(" #### partner_login user_access_right qry = ", qry)
|
||||
|
||||
for retval in MYSY_GV.dbname['user_access_right'].find(qry):
|
||||
for retval in MYSY_GV.dbname['user_access_right'].find(qry).sort([("_id", pymongo.DESCENDING), ]):
|
||||
local_access_right = {}
|
||||
if( 'module' in retval.keys()):
|
||||
local_access_right['module'] = retval['module']
|
||||
|
@ -1462,12 +1462,13 @@ def partner_login(diction):
|
|||
if ('write' in retval.keys()):
|
||||
local_access_right['write'] = retval['write']
|
||||
|
||||
|
||||
return_data['user_access_right'].append(local_access_right)
|
||||
|
||||
|
||||
RetObject = []
|
||||
|
||||
#print(" #### partner_login : return_data = ", return_data)
|
||||
print(" #### partner_login : return_data = ", return_data)
|
||||
RetObject.append(JSONEncoder().encode(return_data))
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue