Elyos_FI_Back_Office/jury_mgt.py

2342 lines
92 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

"""
Ce fichier permet de gerer les jurys qui delibere sur l'optention des diplome
use case cherif :
Le jury affiche les note de l'apprenant a l'ecran, discute, donne un avis et modifie la note si besoin
memo :
0 - Le Président du jury et un suppléant sont clairement designés
1 - un jury, en examinant un candidat doit voir les evaluations concernée
2 - Il est compétent pour modifier, à la hausse ou à la baisse, les notes proposées par les correcteurs. Seules les notes arrêtées par le jury sont définitives.
3 - À lissue de la délibération, le président et les membres du jury présents, signent le procès-verbal de délibération. (PV de sceance doit etre securisé)
4 - Il faudra jouter le seceancs planifié avec session concernées (une vue agenda serait sympa)
"""
import ast
from zipfile import ZipFile
import bson
import pymongo
import xlsxwriter
from pymongo import MongoClient
import json
from bson import ObjectId
import re
from datetime import datetime, date
import partner_client
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
import attached_file_mgt
"""
Ajout d'un jury
"""
def Add_Jury(diction):
try:
diction = mycommon.strip_dictionary(diction)
"""
Verification des input acceptés
"""
field_list = ['token', 'code', 'description', 'comment', 'responsable_id',
'session_id', 'email_jury', 'chef_jury_id', 'session_id',
'ue_id', 'cible']
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', ]
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 la liste des arguments ")
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
"""
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 si le chef d'equipe existe
if ("chef_jury_id" in diction.keys() and diction['chef_jury_id']):
# Verifier que l'id du chef d'equipe est valide
is_chef_equipe_id_count = MYSY_GV.dbname['ressource_humaine'].count_documents(
{'_id': ObjectId(str(diction['chef_jury_id'])),
'valide': '1',
'locked': '0',
'partner_recid': str(my_partner['recid'])})
if (is_chef_equipe_id_count != 1):
mycommon.myprint(
str(inspect.stack()[0][3]) + " L'identifiant du chef du jury est invalide ")
return False, " L'identifiant du chef du jury est invalide "
# Verifier si l'UE existe
if ("ue_id" in diction.keys() and diction['ue_id']):
# Verifier que l'id du chef d'equipe est valide
is_ue_id_id_count = MYSY_GV.dbname['unite_enseignement'].count_documents(
{'_id': ObjectId(str(diction['ue_id'])),
'valide': '1',
'locked': '0',
'partner_owner_recid': str(my_partner['recid'])})
if (is_ue_id_id_count != 1):
mycommon.myprint(
str(inspect.stack()[0][3]) + " L'identifiant de l'UE est invalide ")
return False, " L'identifiant de l'UE est invalide "
if ("email_jury" in diction.keys() and diction['email_jury']):
if (mycommon.isEmailValide(str(diction['email_jury'])) is False):
mycommon.myprint(
str(inspect.stack()[0][3]) + " L'adresse email du jury est invalide ")
return False, " L'adresse email du jury est invalide "
mytoken = diction['token']
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['create_date'] = str(datetime.now())
new_data['created_by'] = str(my_partner['_id'])
new_data['partner_owner_recid'] = str(my_partner['recid'])
inserted_id = MYSY_GV.dbname['jury'].insert_one(new_data).inserted_id
if (not inserted_id):
mycommon.myprint(
" Impossible de créer le jury (2) ")
return False, " Impossible de créer le jury (2) "
"""
Après la création du jury, on ajoute le chef d'équipe dans liste de membres
"""
if( "chef_jury_id" in diction.keys() and diction['chef_jury_id']):
new_data = {}
new_data['jury_id'] = str(inserted_id)
new_data['rh_id'] = str(diction['chef_jury_id'])
now = str(datetime.now())
mytoday = datetime.today()
new_data['date_ajout_jury'] = str(mytoday)
new_data['date_update'] = now
new_data['valide'] = "1"
new_data['locked'] = "0"
new_data['partner_owner_recid'] = str(my_partner['recid'])
new_data['update_by'] = str(my_partner['_id'])
new_data['leader'] = "1"
data_cle = {}
data_cle['partner_owner_recid'] = str(my_partner['recid'])
data_cle['jury_id'] = str(diction['_id'])
data_cle['rh_id'] = str(diction['chef_jury_id'])
data_cle['valide'] = "1"
data_cle['locked'] = "0"
result = MYSY_GV.dbname['jury_membre'].find_one_and_update(
data_cle,
{"$set": new_data},
upsert=True,
return_document=ReturnDocument.AFTER
)
if (result is None or "_id" not in result.keys()):
mycommon.myprint(
" WARNING : Impossible d'ajouter le chef d'équipe")
"""
## Add to log history
"""
now = str(datetime.now().strftime("%d/%m/%Y %H:%M:%S"))
# Pour la collection inscription
history_event_dict = {}
history_event_dict['token'] = mytoken
history_event_dict['related_collection'] = "jury"
history_event_dict['related_collection_recid'] = str(inserted_id)
history_event_dict['action_date'] = str(now)
history_event_dict['action_description'] = "Creation jury "
local_status, local_retval = mycommon.Collection_Historique.Add_Historique_Event(history_event_dict)
if (local_status is False):
mycommon.myprint(
" WARNING : Impossible de logguer l'historique pour l'évènement : " + str(history_event_dict))
return True, " Le jury 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 le jury "
"""
Ajouter une liste de membres à un jury
"""
def Add_Update_Jury_Membres(diction):
try:
diction = mycommon.strip_dictionary(diction)
"""
Verification des input acceptés
"""
field_list = ['token', '_id', 'tab_ressource_humaine_ids', 'role']
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', '_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 la liste des arguments ")
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
new_data = diction
# Verifier que l'équipe existe et est valide
qry = {'_id': ObjectId(str(diction['_id'])),
'valide': '1',
'partner_owner_recid': str(my_partner['recid'])}
is_existe_groupe = MYSY_GV.dbname['jury'].count_documents(
{'_id': ObjectId(str(diction['_id'])),
'valide': '1',
'partner_owner_recid': str(my_partner['recid'])})
if (is_existe_groupe != 1):
mycommon.myprint(
str(inspect.stack()[0][3]) + " L'identifiant du jury est invalide ")
return False, " L'identifiant du jury est invalide "
tab_ressource_humaine_ids = ""
if ("tab_ressource_humaine_ids" in diction.keys()):
if diction['tab_ressource_humaine_ids']:
tab_ressource_humaine_ids = diction['tab_ressource_humaine_ids']
tab_ressource_humaine_ids_splited = str(tab_ressource_humaine_ids).split(",")
# Controle de validité des ressource_humaine
for my_ressource_humaine in tab_ressource_humaine_ids_splited:
# Verifier que l'inscription est valide
my_ressource_humaine_is_valide = MYSY_GV.dbname['ressource_humaine'].count_documents(
{'_id': ObjectId(str(my_ressource_humaine)), 'valide': '1', 'locked':'0',
'partner_recid': str(my_partner['recid'])})
if (my_ressource_humaine_is_valide != 1):
mycommon.myprint(
str(inspect.stack()[0][3]) + " L'identifiant de la ressource humaine '" + my_ressource_humaine + "' est invalide ")
return False, " L'identifiant de la ressource humaine '" + my_ressource_humaine + "' est invalide "
cpt = 0
for my_ressource_humaine in tab_ressource_humaine_ids_splited:
new_data = {}
new_data['jury_id'] = str(diction['_id'])
new_data['rh_id'] = str(my_ressource_humaine)
if( "role" in diction.keys()):
new_data['role'] = str(diction['role'])[0:255]
else:
new_data['role'] = ""
now = str(datetime.now())
mytoday = datetime.today()
new_data['date_ajout_jury'] = str(mytoday)
new_data['date_update'] = now
new_data['valide'] = "1"
new_data['locked'] = "0"
new_data['partner_owner_recid'] = str(my_partner['recid'])
new_data['update_by'] = str(my_partner['_id'])
data_cle = {}
data_cle['partner_owner_recid'] = str(my_partner['recid'])
data_cle['jury_id'] = str(diction['_id'])
data_cle['rh_id'] = str(my_ressource_humaine)
data_cle['valide'] = "1"
data_cle['locked'] = "0"
result = MYSY_GV.dbname['jury_membre'].find_one_and_update(
data_cle,
{"$set": new_data},
upsert=True,
return_document=ReturnDocument.AFTER
)
if (result is None or "_id" not in result.keys()):
mycommon.myprint(
" Impossible d'inscrire les personnes au jury (2) ")
return False, " Impossible d'inscrire les personnes au jury (2) "
cpt = cpt + 1
"""
## Add to log history
"""
now = str(datetime.now().strftime("%d/%m/%Y %H:%M:%S"))
# Pour la collection inscription
history_event_dict = {}
history_event_dict['token'] = str(diction['token'])
history_event_dict['related_collection'] = "jury"
history_event_dict['related_collection_recid'] = str(diction['_id'])
history_event_dict['action_date'] = str(now)
history_event_dict['action_description'] = "Mise à jour des membres "
local_status, local_retval = mycommon.Collection_Historique.Add_Historique_Event(history_event_dict)
if (local_status is False):
mycommon.myprint(
" WARNING : Impossible de logguer l'historique pour l'évènement : " + str(history_event_dict))
return True, str(cpt)+ " Membre(s) inscrit(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 d'inscrire les personnes du jury "
"""
Cette fonction permet de supprimer des membres d'un jury
"""
def Delete_Jury_Membre(diction):
try:
diction = mycommon.strip_dictionary(diction)
"""
Verification des input acceptés
"""
field_list = ['token', 'jury_id', 'tab_ids']
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', 'jury_id', 'tab_ids']
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 la liste des arguments ")
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
new_data = diction
# Verifier que l'equipe existe et est valide
is_existe_groupe = MYSY_GV.dbname['jury'].count_documents(
{'_id': ObjectId(str(diction['jury_id'])),
'valide': '1',
'partner_owner_recid': str(my_partner['recid'])})
if (is_existe_groupe != 1):
mycommon.myprint(
str(inspect.stack()[0][3]) + " L'identifiant de l'équipe est invalide ")
return False, " L'identifiant de l'équipe est invalide "
is_existe_groupe = MYSY_GV.dbname['jury'].find_one(
{'_id': ObjectId(str(diction['jury_id'])),
'valide': '1',
'partner_owner_recid': str(my_partner['recid'])})
update_team_leader = "0"
jury_chef_jury_id = ""
if (is_existe_groupe and "chef_jury_id" in is_existe_groupe):
jury_chef_jury_id = is_existe_groupe['chef_jury_id']
tab_jury_membre_ids = ""
if ("tab_ids" in diction.keys()):
if diction['tab_ids']:
tab_jury_membre_ids = diction['tab_ids']
tab_jury_membre_ids_splited = str(tab_jury_membre_ids).split(",")
tab_jury_membre_ids_splited_ObjectID = []
for tmp in tab_jury_membre_ids_splited:
tab_jury_membre_ids_splited_ObjectID.append(ObjectId(str(tmp)))
qery_delete = {'_id': {'$in': tab_jury_membre_ids_splited_ObjectID},
'jury_id': str(diction['jury_id']),
'partner_owner_recid': str(my_partner['recid']),
'locked': '0'}
"""
Pour les log d'historique, recuperation des information sur les membres supprimés
- rh_id,
- email
et
Si la personne supprimée est le responsable, il faut alors mettre à vide le champ responsable sur la formation
"""
tab_delete_rh = []
for val in MYSY_GV.dbname['jury_membre'].find(qery_delete):
if (val and "rh_id" in val.keys()):
rh_id_data = MYSY_GV.dbname['ressource_humaine'].find_one({'_id': ObjectId(val['rh_id']),
'valide': '1', 'locked': '0',
'partner_recid': str(my_partner['recid']), })
node_delete_rh_id_data = {}
if (rh_id_data and '_id' in rh_id_data.keys() and 'email' in rh_id_data.keys()):
node_delete_rh_id_data['rh_id'] = rh_id_data['_id']
node_delete_rh_id_data['email'] = rh_id_data['email']
if (rh_id_data and 'nom' in rh_id_data.keys()):
node_delete_rh_id_data['nom'] = rh_id_data['nom']
if (rh_id_data and 'prenom' in rh_id_data.keys()):
node_delete_rh_id_data['prenom'] = rh_id_data['prenom']
tab_delete_rh.append(node_delete_rh_id_data)
"""
Si la personne supprimée est le responsable, il faut alors mettre à vide le champ responsable sur la formation
"""
if (str(rh_id_data['_id']) == jury_chef_jury_id):
result = MYSY_GV.dbname['jury'].find_one_and_update(
{'_id': ObjectId(str(diction['jury_id'])),
'valide': '1',
'partner_owner_recid': str(my_partner['recid'])},
{"$set": {"chef_jury_id": ""}},
upsert=False,
return_document=ReturnDocument.AFTER
)
history_massage_light = ""
for val in tab_delete_rh:
if ("email" in val):
history_massage_light = str(val['email']) + ", " + str(history_massage_light)
# print(" ### qery_delete = ", qery_delete)
delete = MYSY_GV.dbname['jury_membre'].delete_many(qery_delete)
"""
## Add to log history
"""
now = str(datetime.now().strftime("%d/%m/%Y %H:%M:%S"))
# Pour la collection inscription
history_event_dict = {}
history_event_dict['token'] = diction['token']
history_event_dict['related_collection'] = "jury"
history_event_dict['related_collection_recid'] = str(diction['jury_id'])
history_event_dict['action_date'] = str(now)
history_event_dict['technical_comment'] = "Suppression membre(s) " + str(tab_delete_rh)
history_event_dict['action_description'] = "Suppression membre(s) " + str(history_massage_light)
local_status, local_retval = mycommon.Collection_Historique.Add_Historique_Event(history_event_dict)
if (local_status is False):
mycommon.myprint(
" WARNING : Impossible de logguer l'historique pour l'évènement : " + str(history_event_dict))
return True, str(delete.deleted_count) + " Membre(s) désinscrit(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 désinscrire les personnes du jury "
"""
Mise à jour d'un jury
"""
def Update_Jury(diction):
try:
diction = mycommon.strip_dictionary(diction)
"""
Verification des input acceptés
"""
field_list = ['token', 'code', 'description', 'email_jury', 'chef_jury_id', '_id',
'session_id', 'cible', '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', '_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 la liste des arguments ")
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
new_data = diction
# Verifier que l'équipe existe
is_existe_cdtion_paiement = MYSY_GV.dbname['jury'].count_documents(
{'_id': ObjectId(str(diction['_id'])),
'valide': '1',
'partner_owner_recid': str(my_partner['recid'])})
if (is_existe_cdtion_paiement != 1):
mycommon.myprint(
str(inspect.stack()[0][3]) + " L'identifiant de l'équipe est invalide ")
return False, " L'identifiant l'équipe est invalide "
# Verifier que ce code n'existe pas déjà
is_existe_jury = MYSY_GV.dbname['jury'].count_documents({'code': str(diction['code']),
'valide': '1',
'partner_owner_recid': str(
my_partner['recid']),
"_id": {"$ne": ObjectId(str(diction['_id']))}
})
if (is_existe_jury > 0):
mycommon.myprint(
str(inspect.stack()[0][3]) + " Une équipe avec le code '" + str(diction['code']) + "' existe déjà ")
return False, " Une équipe avec le code '" + str(diction['code']) + "' existe déjà "
# Verifier si le chef d'equipe existe
if ("chef_jury_id" in diction.keys() and diction['chef_jury_id']):
# Verifier que l'id du chef d'equipe est valide
is_chef_jury_id_count = MYSY_GV.dbname['ressource_humaine'].count_documents(
{'_id': ObjectId(str(diction['chef_jury_id'])),
'valide': '1',
'locked': '0',
'partner_recid': str(my_partner['recid'])})
if (is_chef_jury_id_count != 1):
mycommon.myprint(
str(inspect.stack()[0][3]) + " L'identifiant du chef d'équipe est invalide ")
return False, " L'identifiant du chef d'équipe est invalide "
# Verifier si l'UE existe
if ("ue_id" in diction.keys() and diction['ue_id']):
# Verifier que l'id du chef d'equipe est valide
is_ue_id_id_count = MYSY_GV.dbname['unite_enseignement'].count_documents(
{'_id': ObjectId(str(diction['ue_id'])),
'valide': '1',
'locked': '0',
'partner_owner_recid': str(my_partner['recid'])})
if (is_ue_id_id_count != 1):
mycommon.myprint(
str(inspect.stack()[0][3]) + " L'identifiant de l'UE est invalide ")
return False, " L'identifiant de l'UE est invalide "
if ("email_jury" in diction.keys() and diction['email_jury']):
if (mycommon.isEmailValide(str(diction['email_jury'])) is False):
mycommon.myprint(
str(inspect.stack()[0][3]) + " L'adresse email du jury est invalide ")
return False, " L'adresse email du jury 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 "
local_id = str(diction['_id'])
mytoken = diction['token']
del diction['token']
del diction['_id']
new_data['date_update'] = str(datetime.now())
new_data['update_by'] = str(my_partner['_id'])
data_cle = {}
data_cle['partner_owner_recid'] = str(my_partner['recid'])
data_cle['_id'] = ObjectId(local_id)
data_cle['valide'] = "1"
data_cle['locked'] = "0"
result = MYSY_GV.dbname['jury'].find_one_and_update(
data_cle,
{"$set": new_data},
upsert=False,
return_document=ReturnDocument.AFTER
)
if ("_id" not in result.keys()):
mycommon.myprint(
" Impossible de mettre à jour le jury (2) ")
return False, " Impossible de mettre à jour le jury (2) "
"""
Après la création du jury, on ajoute le chef d'équipe dans liste de membres
"""
if ("chef_jury_id" in diction.keys() and diction['chef_jury_id']):
new_data = {}
new_data['jury_id'] = str(local_id)
new_data['rh_id'] = str(diction['chef_jury_id'])
now = str(datetime.now())
mytoday = datetime.today()
new_data['date_ajout_jury'] = str(mytoday)
new_data['date_update'] = now
new_data['valide'] = "1"
new_data['locked'] = "0"
new_data['partner_owner_recid'] = str(my_partner['recid'])
new_data['update_by'] = str(my_partner['_id'])
new_data['leader'] = "1"
data_cle = {}
data_cle['partner_owner_recid'] = str(my_partner['recid'])
data_cle['jury_id'] = str(local_id)
data_cle['rh_id'] = str(diction['chef_jury_id'])
data_cle['valide'] = "1"
data_cle['locked'] = "0"
"""
D'abord enlever le statut de leader si qq'un d'autre l'avait
"""
update = MYSY_GV.dbname['jury_membre'].update_many(
{ "partner_owner_recid": str(my_partner['recid']), "jury_id": str(local_id) },
{"$unset": {'leader':''}},
)
"""
A présent mise à jour du leader, avec potentiel ajout s'il n'existe pas
"""
result = MYSY_GV.dbname['jury_membre'].find_one_and_update(
data_cle,
{"$set": new_data},
upsert=True,
return_document=ReturnDocument.AFTER
)
if (result is None or "_id" not in result.keys()):
mycommon.myprint(
" WARNING : Impossible d'ajouter le chef d'équipe")
"""
## Add to log history
"""
now = str(datetime.now().strftime("%d/%m/%Y %H:%M:%S"))
# Pour la collection inscription
history_event_dict = {}
history_event_dict['token'] = mytoken
history_event_dict['related_collection'] = "jury"
history_event_dict['related_collection_recid'] = str(local_id)
history_event_dict['action_date'] = str(now)
history_event_dict['action_description'] = "Mise à jour "
local_status, local_retval = mycommon.Collection_Historique.Add_Historique_Event(history_event_dict)
if (local_status is False):
mycommon.myprint(
" WARNING : Impossible de logguer l'historique pour l'évènement : " + str(history_event_dict))
return True, " Le jury a été correctement mis à jour"
except Exception as e:
exc_type, exc_obj, exc_tb = sys.exc_info()
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - Line : " + str(exc_tb.tb_lineno))
return False, " Impossible de mettre à jour le jury "
"""
Suppression d'une équipe
regles :
Si la condition (_id) n'est pas utiliser dans les collections
- jury a deja fait une deliberation
- pas de suppression si groupe à des membres. L'utilisateur devra supprimer les membres d'abord
"""
def Delete_Jury(diction):
try:
diction = mycommon.strip_dictionary(diction)
"""
Verification des input acceptés
"""
field_list = ['token', '_id',]
incom_keys = diction.keys()
for val in incom_keys:
if val not in field_list and val.startswith('my_') is False:
mycommon.myprint(str(
inspect.stack()[0][3]) + " Le champ '" + val + "' n'est pas autorisé")
return False, " Les informations fournies sont incorrectes"
"""
Verification des champs obligatoires
"""
field_list_obligatoire = ['token', '_id',]
for val in field_list_obligatoire:
if val not in diction:
mycommon.myprint(
str(inspect.stack()[0][3]) + " - La valeur '" + val + "' n'est pas presente dans la liste des arguments ")
return False, " Les informations fournies sont incorrectes"
"""
Verification de l'identité et autorisation de l'entité qui
appelle cette API
"""
token = ""
if ("token" in diction.keys()):
if diction['token']:
token = diction['token']
local_status, my_partner = mycommon.Check_Connexion_And_Return_Partner_Data(diction)
if (local_status is not True):
return local_status, my_partner
is_existe_jury = MYSY_GV.dbname['jury'].count_documents(
{'_id': ObjectId(str(diction['_id'])),
'valide': '1',
'partner_owner_recid': str(my_partner['recid'])})
if (is_existe_jury != 1):
mycommon.myprint(
str(inspect.stack()[0][3]) + " L'identifiant du jury est invalide ")
return False, " L'identifiant du jury est invalide "
nb_membres = MYSY_GV.dbname['jury_membre'].count_documents({'jury_id': str(diction['_id']),
'partner_owner_recid': str(
my_partner['recid']),
}, )
if( nb_membres > 0 ):
mycommon.myprint(
str(inspect.stack()[0][3]) + " Ce groupe à "+str(nb_membres)+" membre(s) actif(s). Vous devez supprimer les membres avant de supprimer le jury ")
return False, " Ce groupe à "+str(nb_membres)+" membre(s) actif(s). Vous devez supprimer les membres avant de supprimer le jury "
is_existe_jury_date = MYSY_GV.dbname['jury'].find_one(
{'_id': ObjectId(str(diction['_id'])),
'valide': '1',
'partner_owner_recid': str(my_partner['recid'])})
"""
Verifier que le domaine de formation n'est pas utilisé (collection : myclass)
"" "
is_domaine_in_myclass = MYSY_GV.dbname['myclass'].count_documents({'partner_owner_recid':my_partner['recid'],
'valide':'1',
'class_domaine_id':str(diction['_id'])})
if( is_domaine_in_myclass > 0 ):
mycommon.myprint(
str(inspect.stack()[0][3]) + " Cette catégorie de formation est utilisée dans "+str(is_domaine_in_myclass)+" formations ")
return False, " Cette catégorie de formation est utilisée dans "+str(is_domaine_in_myclass)+" formations "
"""
# Suppression des membres
delete_membres = MYSY_GV.dbname['jury_membre'].delete_one({'jury_id': str(diction['_id']),
'partner_owner_recid': str(my_partner['recid']),
}, )
delete = MYSY_GV.dbname['jury'].delete_one({'_id': ObjectId(str(diction['_id'])),
'partner_owner_recid': str(my_partner['recid']),
}, )
"""
## Add to log history
"""
now = str(datetime.now().strftime("%d/%m/%Y %H:%M:%S"))
# Pour la collection inscription
history_event_dict = {}
history_event_dict['token'] = diction['token']
history_event_dict['related_collection'] = "jury"
history_event_dict['related_collection_recid'] = str(diction['_id'])
history_event_dict['action_date'] = str(now)
history_event_dict['action_description'] = "Suppression du jury : _id = " + str(is_existe_jury_date['_id'])+", code = "+ str(is_existe_jury_date['code'])
local_status, local_retval = mycommon.Collection_Historique.Add_Historique_Event(history_event_dict)
if (local_status is False):
mycommon.myprint(
" WARNING : Impossible de logguer l'historique pour l'évènement : " + str(history_event_dict))
return True, " Le jury 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 le jury "
"""
Cette fonction supprime une séance du jury
elle desinscrit egalement les membre
"""
def Delete_Jury_Seance(diction):
try:
diction = mycommon.strip_dictionary(diction)
"""
Verification des input acceptés
"""
field_list = ['token', 'jury_id', 'jury_seance_agenda_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', 'jury_id', 'jury_seance_agenda_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 la liste des arguments ")
return False, " Les informations fournies sont incorrectes"
"""
Verification de l'identité et autorisation de l'entité qui
appelle cette API
"""
token = ""
if ("token" in diction.keys()):
if diction['token']:
token = diction['token']
local_status, my_partner = mycommon.Check_Connexion_And_Return_Partner_Data(diction)
if (local_status is not True):
return local_status, my_partner
is_existe_jury = MYSY_GV.dbname['jury'].count_documents(
{'_id': ObjectId(str(diction['jury_id'])),
'valide': '1',
'partner_owner_recid': str(my_partner['recid'])})
if (is_existe_jury != 1):
mycommon.myprint(
str(inspect.stack()[0][3]) + " L'identifiant du jury est invalide ")
return False, " L'identifiant du jury est invalide "
# Supprenant des apprenants associée à cette seance du jury
jury_seance_apprenant = MYSY_GV.dbname['jury_apprenant'].delete_many({'jury_id': str(diction['jury_id']),
'partner_owner_recid': str(
my_partner['recid']),
}, )
# Suppression de l'entrée agenda associée
jury_seance_agenda_data = MYSY_GV.dbname['agenda'].find_one({'related_collection': 'jury',
'related_collection_recid': str(diction['jury_id']),
'partner_owner_recid': str(my_partner['recid']),
}, )
jury_seance_agenda = MYSY_GV.dbname['agenda'].delete_one({'related_collection':'jury',
'related_collection_recid': str(diction['jury_id']),
'partner_owner_recid': str( my_partner['recid']),
}, )
"""
## Add to log history
"""
now = str(datetime.now().strftime("%d/%m/%Y %H:%M:%S"))
# Pour la collection inscription
history_event_dict = {}
history_event_dict['token'] = diction['token']
history_event_dict['related_collection'] = "jury"
history_event_dict['related_collection_recid'] = str(diction['jury_id'])
history_event_dict['action_date'] = str(now)
history_event_dict['action_description'] = "Suppression de la séance du jury Titre : "+str(jury_seance_agenda_data['event_title'])+" du " + str(jury_seance_agenda_data['event_start'])+", au = "+ str(jury_seance_agenda_data['event_end'])
local_status, local_retval = mycommon.Collection_Historique.Add_Historique_Event(history_event_dict)
if (local_status is False):
mycommon.myprint(
" WARNING : Impossible de logguer l'historique pour l'évènement : " + str(history_event_dict))
return True, " La séance du jury 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 la séance du jury "
"""
Recuperer la liste des jury d'un partenaire
"""
def Get_List_Jury(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 la liste des arguments ")
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['jury'].find(data_cle).sort([("_id", pymongo.DESCENDING), ]):
user = retval
user['id'] = str(val_tmp)
val_tmp = val_tmp + 1
# Recuperer le nombre de membre
nb_membre = MYSY_GV.dbname['jury_membre'].count_documents({'partner_owner_recid':str(my_partner['recid']),
'valide':'1',
'locked':'0',
'jury_id':str(retval['_id'])})
user['nb_membre'] = str(nb_membre)
#Recuperation des nom et prenom du responsable (chef d'equipe)
chef_jury_nom_prenom = ""
if( "chef_jury_id" in retval.keys() and retval['chef_jury_id']):
chef_jury_id_data = MYSY_GV.dbname['ressource_humaine'].find_one({'partner_recid':str(my_partner['recid']),
'valide':'1',
'locked':'0',
'_id':ObjectId(str(retval['chef_jury_id']))})
if( chef_jury_id_data and 'nom' in chef_jury_id_data.keys()):
chef_jury_nom_prenom = chef_jury_id_data['nom']
if (chef_jury_id_data and 'prenom' in chef_jury_id_data.keys()):
chef_jury_nom_prenom = chef_jury_nom_prenom+ " "+chef_jury_id_data['prenom']
user['chef_jury_nom_prenom'] = str(chef_jury_nom_prenom)
if( "cible" not in user.keys() ):
user['cible'] = ""
if ("ue_id" not in user.keys()):
user['ue_id'] = ""
user['ue_code'] = ""
elif ( user['ue_id']):
ue_id_data = MYSY_GV.dbname['unite_enseignement'].find_one({'_id':ObjectId(str(user['ue_id'])),
'valide':'1',
'locked':'0',
'partner_owner_recid':str(my_partner['recid'])})
if( ue_id_data and "code" in ue_id_data.keys() ):
user['ue_code'] = ue_id_data['code']
code_session = ""
if( "session_id" in user.keys() and user['session_id'] ):
session_id_data = MYSY_GV.dbname['session_formation'].find_one({'_id': ObjectId(str(user['session_id'])),
'valide': '1',
'partner_owner_recid': str(
my_partner['recid'])})
if (session_id_data and "code_session" in session_id_data.keys()):
code_session= session_id_data['code_session']
user['code_session'] = code_session
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 équipes "
"""
Recuperer les données d'un donné, y compris les membres
"""
def Get_Given_Jury_With_Members(diction):
try:
diction = mycommon.strip_dictionary(diction)
"""
Verification des input acceptés
"""
field_list = ['token', '_id']
incom_keys = diction.keys()
for val in incom_keys:
if val not in field_list and val.startswith('my_') is False:
mycommon.myprint(str(
inspect.stack()[0][3]) + " Le champ '" + val + "' n'existe pas")
return False, " Les informations fournies sont incorrectes",
"""
Verification des champs obligatoires
"""
field_list_obligatoire = ['token', '_id' ]
for val in field_list_obligatoire:
if val not in diction:
mycommon.myprint(
str(inspect.stack()[0][3]) + " - La valeur '" + val + "' n'est pas presente dans la liste des arguments ")
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['_id']))
RetObject = []
val_tmp = 0
for retval in MYSY_GV.dbname['jury'].find(data_cle):
user = retval
user['id'] = str(val_tmp)
# Aller chercher les membres
list_membre = []
for team_membre in MYSY_GV.dbname['jury_membre'].find({"partner_owner_recid": str(my_partner['recid']),
'valide':'1',
'locked':'0',
'jury_id':str(diction['_id'])}):
membre_rh_data = MYSY_GV.dbname['ressource_humaine'].find_one({'partner_recid':str(my_partner['recid']),
'valide':'1',
'locked':'0',
'_id':ObjectId(str(team_membre['rh_id']))})
if(membre_rh_data and '_id' in membre_rh_data.keys() ):
node_membre = {}
node_membre['_id'] = str(team_membre['_id'])
node_membre['jury_id'] = str(retval['_id'])
node_membre['rh_id'] = str(membre_rh_data['_id'])
if( "nom" in membre_rh_data.keys()):
node_membre['nom'] = str(membre_rh_data['nom'])
else:
node_membre['nom'] = ""
if ("prenom" in membre_rh_data.keys()):
node_membre['prenom'] = str(membre_rh_data['prenom'])
else:
node_membre['prenom'] = ""
if ("civilite" in membre_rh_data.keys()):
node_membre['civilite'] = str(membre_rh_data['civilite'])
else:
node_membre['civilite'] = ""
if ("email" in membre_rh_data.keys()):
node_membre['email'] = str(membre_rh_data['email'])
else:
node_membre['email'] = ""
if ("telephone" in membre_rh_data.keys()):
node_membre['telephone'] = str(membre_rh_data['telephone'])
else:
node_membre['telephone'] = ""
if ("comment" in membre_rh_data.keys()):
node_membre['comment'] = str(membre_rh_data['comment'])
else:
node_membre['comment'] = ""
if ("role" in team_membre.keys()):
node_membre['role'] = str(team_membre['role'])
else:
node_membre['role'] = ""
if ("leader" in team_membre.keys()):
node_membre['leader'] = str(team_membre['leader'])
else:
node_membre['leader'] = ""
list_membre.append(node_membre)
user['list_membre'] = list_membre
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 les données du jury "
"""
Recuperer la liste des équipes d'un partenaire avec des filtres sur :
- code
- description
- membre (nom ou prenom ) equipe
"""
def Get_List_jury_With_Filter(diction):
try:
diction = mycommon.strip_dictionary(diction)
"""
Verification des input acceptés
"""
field_list = ['token', 'code', 'description', 'membre', ]
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 la liste des arguments ")
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_description = {}
if ("description" in diction.keys()):
filt_description = {'description': {'$regex': str(diction['description']), "$options": "i"}}
filt_code = {}
if ("code" in diction.keys()):
filt_code = {
'code': {'$regex': str(diction['code']), "$options": "i"}}
filt_membre_ressource_humaine_id = {}
list_membre_ressource_humaine_id = []
if ("membre" in diction.keys()):
filt_membre_qry = { '$or': [
{ 'nom': {'$regex': str(diction['membre']), "$options": "i"}, 'partner_recid':str(my_partner['recid']), 'valide':'1', 'locked':'0' },
{ 'prenom': {'$regex': str(diction['membre']), "$options": "i"}, 'partner_recid':str(my_partner['recid']), 'valide':'1', 'locked':'0' }
] }
for tmp_val in MYSY_GV.dbname['ressource_humaine'].find(filt_membre_qry):
list_membre_ressource_humaine_id.append(str(tmp_val['_id']))
print(" ### liste des Id des ressources humaine sont = ", list_membre_ressource_humaine_id)
filt_membre_ressource_humaine_id = {'rh_id': {'$in': list_membre_ressource_humaine_id, }}
####
RetObject = []
val_tmp = 0
find_qry = {
'$and': [{'partner_owner_recid': str(my_partner['recid']), 'valide': '1', 'locked': '0'}, filt_description,
filt_code, ]}
local_new_myquery_find_team = ""
if ("membre" in diction.keys()):
local_new_myquery_find_team = [{'$match': find_qry},
{'$sort': {'_id': -1}},
{"$addFields": {"jury_header_id": {"$toString": "$_id"}}},
{'$lookup':
{
'from': 'jury_membre',
'localField': "jury_header_id",
'foreignField': 'jury_id',
'pipeline': [
{'$match':
{'$and':
[
filt_membre_ressource_humaine_id,
{'partner_owner_recid': str(my_partner['recid']),'valide': '1', 'locked':'0' },
]
}
}, ],
'as': 'jury_membre_collection'
}
},
{
"$unwind": "$jury_membre_collection"
}
]
else:
local_new_myquery_find_team = [{'$match': find_qry},
{'$sort': {'_id': -1}},
{"$addFields": {"jury_header_id": {"$toString": "$_id"}}},
{'$lookup':
{
'from': 'jury_membre',
'localField': "jury_header_id",
'foreignField': 'jury_id',
'pipeline': [
{'$match':
{'$and':
[
filt_membre_ressource_humaine_id,
{'partner_owner_recid': str(my_partner['recid']),
'valide': '1', 'locked': '0'},
]
}
}, ],
'as': 'jury_membre_collection'
}
},
]
print(" ### local_new_myquery_find_team = ", local_new_myquery_find_team)
###
for local_New_retVal in MYSY_GV.dbname['jury'].aggregate(local_new_myquery_find_team):
user = {}
user['id'] = str(val_tmp)
user['_id'] = str(local_New_retVal['_id'])
if( "code" in local_New_retVal.keys()):
user['code'] = local_New_retVal['code']
else:
user['code'] = ""
if ("description" in local_New_retVal.keys()):
user['description'] = local_New_retVal['description']
else:
user['description'] = ""
if ("email_jury" in local_New_retVal.keys()):
user['email_jury'] = local_New_retVal['email_jury']
else:
user['email_jury'] = ""
if ("chef_jury_id" in local_New_retVal.keys()):
user['chef_jury_id'] = local_New_retVal['chef_jury_id']
else:
user['chef_jury_id'] = ""
if ("cible" in local_New_retVal.keys()):
user['cible'] = local_New_retVal['cible']
else:
user['cible'] = ""
if ("ue_id" in local_New_retVal.keys()):
user['ue_id'] = local_New_retVal['ue_id']
else:
user['ue_id'] = ""
nb_membre = "0"
if( "jury_membre_collection" in local_New_retVal.keys() ):
nb_membre = len(local_New_retVal['jury_membre_collection'])
user['nb_membre'] = str(nb_membre)
# Recuperation des nom et prenom du responsable (chef d'equipe)
chef_jury_nom_prenom = ""
if ("chef_jury_id" in local_New_retVal.keys() and local_New_retVal['chef_jury_id']):
chef_jury_id_data = MYSY_GV.dbname['ressource_humaine'].find_one(
{'partner_recid': str(my_partner['recid']),
'valide': '1',
'locked': '0',
'_id': ObjectId(str(local_New_retVal['chef_jury_id']))})
if (chef_jury_id_data and 'nom' in chef_jury_id_data.keys()):
chef_jury_nom_prenom = chef_jury_id_data['nom']
if (chef_jury_id_data and 'prenom' in chef_jury_id_data.keys()):
chef_jury_nom_prenom = chef_jury_nom_prenom + " " + chef_jury_id_data['prenom']
user['chef_jury_nom_prenom'] = str(chef_jury_nom_prenom)
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 jury "
"""
Cette fonction permet d'inscrire un apprenant 'inscrit_id' à un jury
/!\ : A un jury peux etre inscrit un apprenant dont l'inscription n'est pas totalement validé
par exemple le cas de jury d'admission
Les jury etant liée à des aganda, on va ajouté l'id de l'agenda a 'jury_apprenant'
/!\ : Cette fonction permet de gerer aussi l'entrée dans l'agenda
"""
def Add_Update_Apprenant_To_Jury(diction):
try:
diction = mycommon.strip_dictionary(diction)
"""
Verification des input acceptés
"""
field_list = ['token', '_id', 'tab_inscriptions_ids', 'agenda_id', 'jury_seance_ue_id',
'event_start', 'event_end']
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", False
"""
Verification des champs obligatoires
"""
field_list_obligatoire = ['token', '_id',]
for val in field_list_obligatoire:
if val not in diction:
mycommon.myprint(
str(inspect.stack()[0][3]) + " - La valeur '" + val + "' n'est pas presente dans la liste des arguments ")
return False, " Les informations fournies sont incorrectes", False
"""
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, False
new_data = diction
# Verifier que le groupe existe et est valide
qry = {'_id': ObjectId(str(diction['_id'])),
'valide': '1',
'partner_owner_recid': str(my_partner['recid'])}
is_existe_groupe = MYSY_GV.dbname['jury'].count_documents(
{'_id': ObjectId(str(diction['_id'])),
'valide': '1',
'partner_owner_recid': str(my_partner['recid'])})
if (is_existe_groupe != 1):
mycommon.myprint(
str(inspect.stack()[0][3]) + " L'identifiant du jury est invalide ")
return False, " L'identifiant du jury est invalide ", False
jury_data = MYSY_GV.dbname['jury'].find_one(
{'_id': ObjectId(str(diction['_id'])),
'valide': '1',
'partner_owner_recid': str(my_partner['recid'])})
tab_inscriptions_ids = ""
if ("tab_inscriptions_ids" in diction.keys()):
if diction['tab_inscriptions_ids']:
tab_inscriptions_ids = diction['tab_inscriptions_ids']
tab_inscriptions_ids_splited = str(tab_inscriptions_ids).split(",")
# Controle de validité des inscriptions
for my_inscription in tab_inscriptions_ids_splited:
# Verifier que l'inscription est valide
my_inscription_is_valide = MYSY_GV.dbname['inscription'].count_documents(
{'_id': ObjectId(str(my_inscription)),
'partner_owner_recid': str(my_partner['recid'])})
if (my_inscription_is_valide != 1):
mycommon.myprint(
str(inspect.stack()[0][3]) + " L'inscription_id '" + my_inscription + "' est invalide ")
return False, " L'inscription_id '" + my_inscription + "' est invalide ", False
# Verfifier la validité de l'agenda
if( "agenda_id" in diction.keys() and diction['agenda_id']):
is_agenda_valide = MYSY_GV.dbname['agenda'].count_documents(
{'_id': ObjectId(str(diction['agenda_id'])),
'partner_owner_recid': str(my_partner['recid'])})
if (is_agenda_valide != 1):
mycommon.myprint(
str(inspect.stack()[0][3]) + " L'identifiant de l'agenda est invalide ")
return False, " L'identifiant de l'agenda est invalide ", False
# Verfifier la validité de l'unité d'enseignement
if ("jury_seance_ue_id" in diction.keys() and diction['jury_seance_ue_id']):
is_ue_valide = MYSY_GV.dbname['unite_enseignement'].count_documents(
{'_id': ObjectId(str(diction['jury_seance_ue_id'])),
'valide':'1',
'locked':'0',
'partner_owner_recid': str(my_partner['recid'])})
if (is_ue_valide != 1):
mycommon.myprint(
str(inspect.stack()[0][3]) + " L'identifiant de l'unité d'enseignement est invalide ")
return False, " L'identifiant de l'unité d'enseignement est invalide ", False
final_agenda_id = ""
# Vu que l'ID de l'agenda est valide, on va faire une mise à jour du creneau (on le fait dans tous les cas)
if (datetime.strptime(str(diction['event_start'])[0:16], '%Y-%m-%dT%H:%M') >= datetime.strptime(
str(diction['event_end'])[0:16],
'%Y-%m-%dT%H:%M')):
mycommon.myprint(
str(inspect.stack()[0][
3]) + " La date de fin " + str(
diction['event_end']) + " doit être postérieure à la date de début " + str(
diction['event_start']) + " ")
return False, " La date de fin " + str(
diction['event_end']) + " doit être postérieure à la date de début " + str(
diction['event_start']) + " ", False
my_even_data = {}
my_even_data['related_collection'] = "jury"
my_even_data['related_collection_recid'] = str(diction['_id'])
my_even_data['event_title'] = "Jury : " + str(jury_data['code'])
my_even_data['event_start'] = str(diction['event_start'])
my_even_data['event_end'] = str(diction['event_end'])
my_even_data['valide'] = "1"
my_even_data['locked'] = "0"
my_even_data['partner_owner_recid'] = str(my_partner['recid'])
if ("agenda_id" in diction.keys() and diction['agenda_id']):
my_even_data['date_update'] = str(datetime.now())
my_even_data['update_by'] = str(my_partner['_id'])
update_agenda = MYSY_GV.dbname['agenda'].find_one_and_update(
{'_id': ObjectId(str(diction['agenda_id'])), 'partner_owner_recid': str(my_partner['recid'])},
{"$set": my_even_data},
return_document=ReturnDocument.AFTER,
upsert=False,
)
final_agenda_id = str(diction['agenda_id'])
else:
my_even_data['create_date'] = str(datetime.now())
my_even_data['created_by'] = str(my_partner['_id'])
inserted_id = MYSY_GV.dbname['agenda'].insert_one(my_even_data).inserted_id
final_agenda_id = str(inserted_id)
cpt = 0
for my_inscription in tab_inscriptions_ids_splited:
new_data = {}
new_data['jury_id'] = str(diction['_id'])
new_data['inscription_id'] = str(my_inscription)
new_data['agenda_id'] = str(final_agenda_id)
new_data['jury_seance_ue_id'] = str(diction['jury_seance_ue_id'])
now = str(datetime.now())
mytoday = datetime.today()
new_data['date_ajout_jury'] = str(mytoday)
new_data['date_update'] = now
new_data['valide'] = "1"
new_data['locked'] = "0"
new_data['partner_owner_recid'] = str(my_partner['recid'])
new_data['update_by'] = str(my_partner['_id'])
data_cle = {}
data_cle['partner_owner_recid'] = str(my_partner['recid'])
data_cle['jury_id'] = str(diction['_id'])
data_cle['inscription_id'] = str(my_inscription)
data_cle['valide'] = "1"
data_cle['locked'] = "0"
if( "agenda_id" in diction.keys() and diction['agenda_id']):
data_cle['agenda_id'] = str(diction['agenda_id'])
result = MYSY_GV.dbname['jury_apprenant'].find_one_and_update(
data_cle,
{"$set": new_data},
upsert=True,
return_document=ReturnDocument.AFTER
)
if (result is None or "_id" not in result.keys()):
mycommon.myprint(
" Impossible d'inscrire les personnes au groupe (2) ")
return False, " Impossible d'inscrire les personnes au groupe (2) ", False
cpt = cpt + 1
return True, str(cpt)+ " Membre(s) inscrit(s)", str(final_agenda_id)
except Exception as e:
exc_type, exc_obj, exc_tb = sys.exc_info()
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - Line : " + str(exc_tb.tb_lineno))
return False, " Impossible d'inscrire les personnes au jury ", False
"""
Recuperer les apprenants inscrit à un jury
"""
def Get_Given_Jury_Apprenant_With_Filter(diction):
try:
diction = mycommon.strip_dictionary(diction)
"""
Verification des input acceptés
"""
field_list = ['token', '_id', 'agenda_id', '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', '_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 la liste des arguments ")
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
qry = {}
qry['jury_id'] = str(diction['_id'])
qry['valide'] = "1"
qry['locked'] = "0"
qry['partner_owner_recid'] = str(my_partner['recid'])
if( "agenda_id" in diction.keys() and diction['agenda_id']):
qry["agenda_id"] = str(diction['agenda_id'])
if ("ue_id" in diction.keys() and diction['ue_id']):
qry["ue_id"] = str(diction['ue_id'])
#print(" ### Get_Given_Jury_Apprenant_With_Filter QRY = ",qry )
RetObject = []
val_tmp = 0
for retval in MYSY_GV.dbname['jury_apprenant'].find(qry):
user = retval
user['id'] = str(val_tmp)
val_tmp = val_tmp + 1
local_new_dict = {}
local_new_dict['token'] = diction['token']
local_new_dict['inscrit_id'] = retval['inscription_id']
local_inscrit_data_status, local_inscrit_data_retval = mycommon.Get_Inscrit_And_Apprenant_Data(
local_new_dict)
if (local_inscrit_data_status is False):
return local_inscrit_data_status, local_inscrit_data_retval
nom = ""
prenom = ""
email = ""
if ("inscrit_data" in local_inscrit_data_retval.keys()):
user['inscrit_data'] = local_inscrit_data_retval['inscrit_data']
nom = local_inscrit_data_retval['inscrit_data']['nom']
prenom = local_inscrit_data_retval['inscrit_data']['prenom']
email = local_inscrit_data_retval['inscrit_data']['email']
if ("apprenant_data" in local_inscrit_data_retval.keys()):
user['apprenant_data'] = local_inscrit_data_retval['apprenant_data']
# Si on a un dossier apprenant, alors on écrase les variables ci-dessous
nom = local_inscrit_data_retval['apprenant_data']['nom']
prenom = local_inscrit_data_retval['apprenant_data']['prenom']
email = local_inscrit_data_retval['apprenant_data']['email']
user['nom'] = nom
user['prenom'] = prenom
user['email'] = email
ue_code = ""
# Recuperation du code d'unite d'enseignement
if( "jury_seance_ue_id" in retval.keys() and retval['jury_seance_ue_id']):
ue_data = MYSY_GV.dbname['unite_enseignement'].find_one({'_id':ObjectId(str(retval['jury_seance_ue_id'])),
'valide':'1',
'locked':'0',
'partner_owner_recid': str(my_partner['recid'])
})
if( ue_data and "code" in ue_data.keys() ):
ue_code = str(ue_data['code'])
user['ue_code'] = ue_code
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 membres du groupe "
"""
Cette fonction permet de supprimer des inscrits à un jury (membre d'un groupe)
"""
def Delete_Jury_Apprenant_Membres(diction):
try:
diction = mycommon.strip_dictionary(diction)
"""
Verification des input acceptés
"""
field_list = ['token', 'jury_id', 'tab_ids']
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', 'jury_id', 'tab_ids' ]
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 la liste des arguments ")
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
new_data = diction
# Verifier que le groupe existe et est valide
print(" QR ", {'_id': ObjectId(str(diction['jury_id'])),
'valide': '1',
'partner_owner_recid': str(my_partner['recid'])})
is_existe_groupe = MYSY_GV.dbname['jury'].count_documents(
{'_id': ObjectId(str(diction['jury_id'])),
'valide': '1',
'partner_owner_recid': str(my_partner['recid'])})
if (is_existe_groupe != 1):
mycommon.myprint(
str(inspect.stack()[0][3]) + " L'identifiant du jury est invalide 77 ")
return False, " L'identifiant du jury est invalide "
tab_inscriptions_ids = ""
if ("tab_ids" in diction.keys()):
if diction['tab_ids']:
tab_inscriptions_ids = diction['tab_ids']
tab_inscriptions_ids_splited = str(tab_inscriptions_ids).split(",")
tab_inscriptions_ids_splited_ObjectID = []
for tmp in tab_inscriptions_ids_splited :
tab_inscriptions_ids_splited_ObjectID.append(ObjectId(str(tmp)))
qery_delete = {'_id': {'$in': tab_inscriptions_ids_splited_ObjectID},
'jury_id':str(diction['jury_id']),
'partner_owner_recid': str(my_partner['recid']),
'locked': '0'}
#print(" ### qery_delete = ", qery_delete)
delete = MYSY_GV.dbname['jury_apprenant'].delete_many(qery_delete )
return True, str(delete.deleted_count) + " Membre(s) désinscrit(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 désinscrire les personnes au jury "
"""
Cette fonction permet de gerer les jury de type non examen, c'est a dire
les jury d'admission, les jury pour une UE....
En gros tous les jury pour lequel il a un sujet et un deliberation
Ici on a pas besoin des antécedents, donc les jury a SOUTENANCE
"""
def Add_Update_Jury_Soutenance(diction):
try:
diction = mycommon.strip_dictionary(diction)
"""
Verification des input acceptés
"""
field_list = ['token', 'jury_id', 'agenda_id', 'sujet', 'note', 'observation']
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', 'jury_id', 'agenda_id', 'sujet', 'note', 'observation']
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 la liste des arguments ")
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, False
# Verfier la validité du jury
is_jury_valide_count = MYSY_GV.dbname['jury'].count_documents({'_id':ObjectId(str(diction['jury_id'])),
'valide':'1',
'locked':'0',
'partner_owner_recid':str(my_partner['recid'])})
if( is_jury_valide_count != 1 ):
mycommon.myprint(
str(inspect.stack()[0][3]) + " L'identifiant du jury est invalide ")
return False, " L'identifiant du jury est invalide"
# Verfier la validité de la séance (agenda)
is_jury_agenda_valide_count = MYSY_GV.dbname['agenda'].count_documents({'_id': ObjectId(str(diction['agenda_id'])),
'valide': '1',
'locked': '0',
'related_collection':'jury',
'related_collection_recid':str(diction['jury_id']),
'partner_owner_recid': str(
my_partner['recid'])})
if (is_jury_agenda_valide_count != 1):
mycommon.myprint(
str(inspect.stack()[0][3]) + " L'identifiant de la séance du jury est invalide ")
return False, " L'identifiant de la séance du jury est invalide "
my_token = str(diction['token'])
new_data = diction
del new_data['token']
new_data['valide'] = "1"
new_data['locked'] = "0"
new_data['partner_owner_recid'] = str(my_partner['recid'])
new_data['update_by'] = str(my_partner['_id'])
new_data['date_update'] = str(datetime.now())
result = MYSY_GV.dbname['jury_soutenance'].find_one_and_update(
{'agenda_id':str(diction['agenda_id']),
'jury_id':str(diction['jury_id']),
'partner_owner_recid':str(my_partner['recid'])
},
{"$set": new_data},
upsert=True,
return_document=ReturnDocument.AFTER
)
if (result is None or "_id" not in result.keys()):
mycommon.myprint(
" Impossible de mettre à jour la soutenance (2) ")
return False, " Impossible de mettre à jour la soutenance (2) ", False
return True, "La soutenance 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 la soutenance "
"""
Recuperation de la liste des soutenances d'un jury
"""
def Get_List_Jury_Soutenenace(diction):
try:
diction = mycommon.strip_dictionary(diction)
"""
Verification des input acceptés
"""
field_list = ['token', 'jury_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', 'jury_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 la liste des arguments ")
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['jury_soutenance'].find(data_cle).sort([("_id", pymongo.DESCENDING), ]):
user = retval
user['id'] = str(val_tmp)
val_tmp = val_tmp + 1
jury_apprenant = []
# Recuperer le nombre de membre
nb_jury_apprenant = MYSY_GV.dbname['jury_apprenant'].count_documents({'partner_owner_recid':str(my_partner['recid']),
'valide':'1',
'locked':'0',
'jury_id':str(retval['jury_id'])})
user['nb_apprenant'] = str(nb_jury_apprenant)
for inscrit in MYSY_GV.dbname['jury_apprenant'].find({'partner_owner_recid': str(my_partner['recid']),
'valide': '1',
'locked': '0',
'jury_id': str(retval['jury_id'])}):
if( inscrit and "inscription_id" in inscrit.keys() and inscrit['inscription_id']):
jury_inscri_data = MYSY_GV.dbname['inscription'].find_one({'_id':ObjectId(str(inscrit['inscription_id'])),
'valide':'1',
'partner_owner_recid':str(my_partner['recid'])},
{'email':1,
'nom':1,
'prenom':1})
jury_apprenant.append(jury_inscri_data)
user['list_inscrit'] = jury_apprenant
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 soutenances "
"""
Recuperer les information d'une soutenance donnée
"""
def Get_Given_Jury_Soutenenace(diction):
try:
diction = mycommon.strip_dictionary(diction)
"""
Verification des input acceptés
"""
field_list = ['token', 'jury_id', 'agenda_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', 'jury_id', 'agenda_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 la liste des arguments ")
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['agenda_id'] = str(diction['agenda_id'])
data_cle['locked'] = "0"
RetObject = []
val_tmp = 0
for retval in MYSY_GV.dbname['jury_soutenance'].find(data_cle).sort([("_id", pymongo.DESCENDING), ]):
user = retval
user['id'] = str(val_tmp)
val_tmp = val_tmp + 1
jury_apprenant = []
# Recuperer le nombre de membre
nb_jury_apprenant = MYSY_GV.dbname['jury_apprenant'].count_documents(
{'partner_owner_recid': str(my_partner['recid']),
'valide': '1',
'locked': '0',
'jury_id': str(retval['jury_id'])})
user['nb_apprenant'] = str(nb_jury_apprenant)
for inscrit in MYSY_GV.dbname['jury_apprenant'].find({'partner_owner_recid': str(my_partner['recid']),
'valide': '1',
'locked': '0',
'jury_id': str(retval['jury_id'])}):
if (inscrit and "inscription_id" in inscrit.keys() and inscrit['inscription_id']):
jury_inscri_data = MYSY_GV.dbname['inscription'].find_one(
{'_id': ObjectId(str(inscrit['inscription_id'])),
'valide': '1',
'partner_owner_recid': str(my_partner['recid'])},
{'email': 1,
'nom': 1,
'prenom': 1})
jury_apprenant.append(jury_inscri_data)
user['list_inscrit'] = jury_apprenant
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 soutenances "
"""
Supprimer une soutenance donnée
"""
def Delete_Given_Jury_Soutenenace(diction):
try:
diction = mycommon.strip_dictionary(diction)
"""
Verification des input acceptés
"""
field_list = ['token', 'jury_id', 'agenda_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', 'jury_id', ' agenda_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 la liste des arguments ")
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['agenda_id'] = str(diction['agenda_id'])
data_cle['locked'] = "0"
RetObject = []
val_tmp = 0
delete = MYSY_GV.dbname['jury_soutenance'].delete_many(data_cle)
return True, "La soutenance 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 la soutenance"