Elyos_FI_Back_Office/note_evaluation_mgt.py

792 lines
31 KiB
Python

"""
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 "