2749 lines
116 KiB
Python
2749 lines
116 KiB
Python
"""
|
|
Ce fichier permet de gerer les admissions à une formation (promotion)
|
|
dans le cadre d'une formation initiale.
|
|
|
|
Le sessions d'admission sont géré dans une collection appelée admission_session
|
|
"""
|
|
import ast
|
|
from zipfile import ZipFile
|
|
|
|
import bson
|
|
import pymongo
|
|
import xlsxwriter
|
|
from dateutil.relativedelta import relativedelta
|
|
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
|
|
|
|
"""
|
|
Creation d'une session d'admission
|
|
"""
|
|
def Add_Admission_Session(diction):
|
|
try:
|
|
diction = mycommon.strip_dictionary(diction)
|
|
|
|
"""
|
|
Verification des input acceptés
|
|
"""
|
|
field_list = ['token', 'date_debut', 'date_fin', 'nb_participant', 'adresse',
|
|
'code_postal', 'ville', 'code_session',
|
|
'tab_class_id', 'session_status', 'date_debut_inscription',
|
|
'date_fin_inscription', "prix_session",'session_ondemande', 'source', 'session_etape', 'pays', 'formateur_id',
|
|
'titre', 'location_type', 'site_formation_id', 'mode_animation', 'archive',
|
|
'entre_scolaire',
|
|
'memo', 'comment', 'class_session_id', 'process_inscription_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_session', ]
|
|
|
|
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
|
|
|
|
|
|
|
|
"""
|
|
Verifier la validité des formation
|
|
"""
|
|
tab_class_ids = []
|
|
tab_class_ids_ObjectId = []
|
|
if ("tab_class_id" in diction.keys()):
|
|
tab_class_ids = str(diction['tab_class_id']).split(",")
|
|
|
|
for tmp in tab_class_ids:
|
|
if (tmp):
|
|
is_valide_class = MYSY_GV.dbname['myclass'].count_documents({'_id':ObjectId(tmp), 'valide':'1', 'partner_owner_recid':str(my_partner['recid'])})
|
|
if( is_valide_class != 1):
|
|
mycommon.myprint(
|
|
str(inspect.stack()[0][
|
|
3]) + " La formation '" + tmp + "' est invalide ")
|
|
return False, " La formation '" + tmp + "' est invalide "
|
|
tab_class_ids_ObjectId.append(ObjectId(tmp))
|
|
|
|
"""
|
|
Si cette admission à lié à une promotion
|
|
"""
|
|
if ("class_session_id" in diction.keys() and diction['class_session_id']):
|
|
is_valide_promotion = MYSY_GV.dbname['session_formation'].count_documents(
|
|
{'_id': ObjectId(str(diction['class_session_id'])),
|
|
'partner_owner_recid': str(my_partner['recid']),
|
|
'valide': '1'})
|
|
|
|
if (is_valide_promotion != 1):
|
|
mycommon.myprint(
|
|
str(inspect.stack()[0][
|
|
3]) + " L'identifiant de la promotion est invalide ")
|
|
return False, " L'identifiant de la promotion est invalide "
|
|
|
|
"""
|
|
Pour le mode d'animation d'une session de formation, on a :
|
|
0 => Présentiel
|
|
1 => Distanciel
|
|
2 => Hybride
|
|
"""
|
|
if ("mode_animation" in diction.keys() and diction['mode_animation'] not in ['0', '1', '2', '']):
|
|
mycommon.myprint(
|
|
str(inspect.stack()[0][
|
|
3]) + " Le mode d'animation est invalide ")
|
|
return False, " Le mode d'animation est invalide "
|
|
|
|
"""
|
|
Si cette admission à lié à une promotion
|
|
"""
|
|
if ("class_session_id" in diction.keys() and diction['class_session_id']):
|
|
is_valide_promotion = MYSY_GV.dbname['session_formation'].count_documents(
|
|
{'_id': ObjectId(str(diction['class_session_id'])),
|
|
'partner_owner_recid': str(my_partner['recid']),
|
|
'valide': '1'})
|
|
|
|
if (is_valide_promotion != 1):
|
|
mycommon.myprint(
|
|
str(inspect.stack()[0][
|
|
3]) + " L'identifiant de la promotion est invalide ")
|
|
return False, " L'identifiant de la promotion est invalide "
|
|
|
|
|
|
"""
|
|
Si cette admission à lié à un process d'admission
|
|
"""
|
|
if ("process_inscription_id" in diction.keys() and diction['process_inscription_id']):
|
|
is_valide_process_admiss = MYSY_GV.dbname['admission_setup'].count_documents(
|
|
{'_id': ObjectId(str(diction['process_inscription_id'])),
|
|
'partner_owner_recid': str(my_partner['recid']),
|
|
'valide': '1'})
|
|
|
|
if (is_valide_process_admiss != 1):
|
|
mycommon.myprint(
|
|
str(inspect.stack()[0][
|
|
3]) + " L'identifiant du processus d'admission est invalide ")
|
|
return False, " L'identifiant du processus d'admission est invalide "
|
|
|
|
|
|
if ("price_by" in diction.keys()):
|
|
if( str(diction['price_by']) not in MYSY_GV.TRAINING_PRICE):
|
|
mycommon.myprint(str(inspect.stack()[0][3]) + " Le prix par "+str(diction['price_by'])+" n'est valide. Les valeurs autorisées sont "+str(MYSY_GV.TRAINING_PRICE) )
|
|
return False, " Le prix par "+str(diction['price_by'])+" n'est valide. Les valeurs autorisées sont "+str(MYSY_GV.TRAINING_PRICE)+" "
|
|
|
|
|
|
if ("location_type" in diction.keys()):
|
|
if (str(diction['location_type']).lower() not in MYSY_GV.TRAINING_LOCATION_TYPE):
|
|
mycommon.myprint(str(inspect.stack()[0][3]) + " - Le champ 'location_type' est incorrecte.")
|
|
return False, "Le champ 'location_type' est incorrect."
|
|
|
|
|
|
if ("entre_scolaire" in diction.keys()):
|
|
if (str(diction['entre_scolaire']).lower() not in MYSY_GV.TRAINING_ENTREE_SCOLAIRE):
|
|
mycommon.myprint(str(inspect.stack()[0][3]) + " - Le champ 'Entrée scolaire' est incorrecte.")
|
|
return False, "Le champ 'Entrée scolaire' est incorrect."
|
|
|
|
formateur_id = ""
|
|
if ("formateur_id" in diction.keys() and diction['formateur_id']):
|
|
formateur_id = diction['formateur_id']
|
|
# Verification de la validité du formateur (collection employé)
|
|
is_formateur_id_ok = MYSY_GV.dbname['ressource_humaine'].count_documents(
|
|
{'_id': ObjectId(str(formateur_id)),
|
|
'partner_recid': str(my_partner['recid']),
|
|
'valide': '1',
|
|
'locked': '0'
|
|
})
|
|
|
|
if (is_formateur_id_ok <= 0):
|
|
mycommon.myprint(str(inspect.stack()[0][3]) + " - L'identifiant du responsable est invalide")
|
|
return False, " L'identifiant du responsable est invalide "
|
|
|
|
|
|
if (datetime.strptime(str(diction['date_debut'])[0:10], '%d/%m/%Y') > datetime.strptime(str(diction['date_fin'])[0:10], '%d/%m/%Y')):
|
|
mycommon.myprint(
|
|
str(inspect.stack()[0][
|
|
3]) + " La date debut " + str(
|
|
diction['date_debut'])[0:10] +
|
|
" est postérieure à la date de fin " + str(diction['date_fin'])[0:10] )
|
|
|
|
return False, " La date debut de formation " + str(diction['date_debut'])[0:10] + \
|
|
" est postérieure à la date de fin de formation " + str(diction['date_fin'])[0:10] + " "
|
|
|
|
# Verification de la cohérence des dates d'inscription si on a bien une date debut et une date de fin
|
|
if ("date_debut_inscription" in diction.keys() and "date_fin_inscription" in diction.keys()):
|
|
if (str(diction['date_debut_inscription']).strip() != "" and str(
|
|
diction['date_fin_inscription']).strip() != ""):
|
|
local_status = mycommon.CheckisDate(str(diction['date_debut_inscription'])[0:10])
|
|
if (local_status is False):
|
|
mycommon.myprint(
|
|
str(inspect.stack()[0][
|
|
3]) + " La date_debut_inscription n'est pas au format jj/mm/aaaa ")
|
|
|
|
return False, " La date de début d'inscription n'est pas au format jj/mm/aaaa "
|
|
|
|
local_status = mycommon.CheckisDate(str(diction['date_fin_inscription'])[0:10])
|
|
if (local_status is False):
|
|
mycommon.myprint(
|
|
str(inspect.stack()[0][
|
|
3]) + " La date de fin d'inscription n'est pas au format jj/mm/aaaa ")
|
|
|
|
return False, " La date de fin d'inscription n'est pas au format jj/mm/aaaa "
|
|
|
|
if (datetime.strptime(str(diction['date_debut_inscription'])[0:10], '%d/%m/%Y') > datetime.strptime(
|
|
str(diction['date_fin_inscription'])[0:10], '%d/%m/%Y')):
|
|
mycommon.myprint(
|
|
str(inspect.stack()[0][
|
|
3]) + " La date de début d'inscription " + str(
|
|
diction['date_debut_inscription'])[0:10] + \
|
|
" est postérieure à la date de fin d'inscription " + str(diction['date_fin_inscription'])[
|
|
0:10] + " ")
|
|
|
|
return False, " La date de début d'inscription " + str(
|
|
diction['date_debut_inscription'])[0:10] + \
|
|
" est postérieure à la date de fin d'inscription " + str(
|
|
diction['date_fin_inscription'])[0:10] + " "
|
|
|
|
# Verification : Date de debut inscription n'est pas > date de fin de formation
|
|
if (datetime.strptime(str(diction['date_debut_inscription'])[0:10], '%d/%m/%Y') > datetime.strptime(
|
|
str(diction['date_fin'])[0:10], '%d/%m/%Y')):
|
|
mycommon.myprint(
|
|
str(inspect.stack()[0][
|
|
3]) + " La date de debut d'inscription " + str(diction['date_debut_inscription']) + " est postérieure à la date de fin de formation " + str(
|
|
diction['date_fin']))
|
|
|
|
return False, " La date de debut d'inscription " + str(
|
|
diction['date_debut_inscription'])[0:10] + " est postérieure à la date de fin de formation " + str(
|
|
diction['date_fin'])[0:10] + " "
|
|
|
|
# Verification : Date de fin inscription n'est pas > date de fin de formation
|
|
if (datetime.strptime(str(diction['date_fin_inscription'])[0:10], '%d/%m/%Y') > datetime.strptime(
|
|
str(diction['date_fin'])[0:10], '%d/%m/%Y')):
|
|
mycommon.myprint(
|
|
str(inspect.stack()[0][3]) + " La date de fin d'inscription " + str(diction['date_fin_inscription'])[0:10] + " est postérieure à la date de fin de la formation " + str(diction['date_fin'])[0:10])
|
|
|
|
return False, " La date de fin d'inscription " + str(diction['date_fin_inscription'])[0:10] + " est postérieure à la date de fin de la formation " + str(
|
|
diction['date_fin'])[0:10] + " "
|
|
|
|
|
|
|
|
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['creation_date'] = str(datetime.now())
|
|
new_data['creation_by'] = str(my_partner['_id'])
|
|
new_data['partner_owner_recid'] = str(my_partner['recid'])
|
|
new_data['valide'] = "1"
|
|
new_data['locked'] = "0"
|
|
|
|
inserted_id = MYSY_GV.dbname['admission_session'].insert_one(new_data).inserted_id
|
|
if (not inserted_id):
|
|
mycommon.myprint(
|
|
" Impossible de créer la session d'admission (2) ")
|
|
return False, " Impossible de créer la session d'admission (2) "
|
|
|
|
now = str(datetime.now().strftime("%d/%m/%Y %H:%M:%S"))
|
|
history_event_dict = {}
|
|
history_event_dict['token'] = str(token)
|
|
history_event_dict['related_collection'] = "admission_session"
|
|
history_event_dict['related_collection_recid'] = str(inserted_id)
|
|
history_event_dict['action_date'] = str(now)
|
|
history_event_dict['action_description'] = "Création "
|
|
|
|
|
|
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 session d'admission 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 la session d'admission (2) "
|
|
|
|
|
|
|
|
"""
|
|
Mise à jour d'une session d'admission
|
|
"""
|
|
|
|
def Update_Admission_Session(diction):
|
|
try:
|
|
diction = mycommon.strip_dictionary(diction)
|
|
|
|
"""
|
|
Verification des input acceptés
|
|
"""
|
|
field_list = ['token', '_id', 'date_debut', 'date_fin', 'nb_participant', 'adresse',
|
|
'code_postal', 'ville', 'code_session',
|
|
'tab_class_id', 'session_status', 'date_debut_inscription', 'date_fin_inscription',
|
|
'attestation_certif', "distantiel", "presentiel", "prix_session", 'contenu_ftion',
|
|
'session_ondemande', 'source', 'session_etape', 'pays', 'formateur_id',
|
|
'titre', 'location_type', 'site_formation_id', 'mode_animation', 'archive',
|
|
'entre_scolaire',
|
|
'memo', 'comment', 'class_session_id', 'process_inscription_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 la configuration de l'admission
|
|
is_existe_admis_session = MYSY_GV.dbname['admission_session'].count_documents(
|
|
{'_id': ObjectId(str(diction['_id'])),
|
|
'valide': '1',
|
|
'partner_owner_recid': str(my_partner['recid'])})
|
|
|
|
if (is_existe_admis_session < 0):
|
|
mycommon.myprint(
|
|
str(inspect.stack()[0][3]) + " L'identifiant de la session d'admission est invalide ")
|
|
return False, " L'identifiant de la session d'admission est invalide "
|
|
|
|
"""
|
|
Verifier la validité des formation
|
|
"""
|
|
tab_class_ids = []
|
|
tab_class_ids_ObjectId = []
|
|
if ("tab_class_id" in diction.keys()):
|
|
tab_class_ids = str(diction['tab_class_id']).split(",")
|
|
|
|
for tmp in tab_class_ids:
|
|
if (tmp):
|
|
is_valide_class = MYSY_GV.dbname['myclass'].count_documents(
|
|
{'_id': ObjectId(tmp), 'valide': '1', 'partner_owner_recid': str(my_partner['recid'])})
|
|
if (is_valide_class != 1):
|
|
mycommon.myprint(
|
|
str(inspect.stack()[0][
|
|
3]) + " La formation '" + tmp + "' est invalide ")
|
|
return False, " La formation '" + tmp + "' est invalide "
|
|
tab_class_ids_ObjectId.append(ObjectId(tmp))
|
|
|
|
"""
|
|
Pour le mode d'animation d'une session de formation, on a :
|
|
0 => Présentiel
|
|
1 => Distanciel
|
|
2 => Hybride
|
|
"""
|
|
if ("mode_animation" in diction.keys() and diction['mode_animation'] not in ['0', '1', '2', '']):
|
|
mycommon.myprint(
|
|
str(inspect.stack()[0][
|
|
3]) + " Le mode d'animation est invalide ")
|
|
return False, " Le mode d'animation est invalide "
|
|
|
|
|
|
"""
|
|
Si cette admission à lié à une promotion
|
|
"""
|
|
if( "class_session_id" in diction.keys() and diction['class_session_id']):
|
|
is_valide_promotion = MYSY_GV.dbname['session_formation'].count_documents({'_id':ObjectId(str(diction['class_session_id'])),
|
|
'partner_owner_recid':str(my_partner['recid']),
|
|
'valide':'1'})
|
|
|
|
if( is_valide_promotion != 1):
|
|
mycommon.myprint(
|
|
str(inspect.stack()[0][
|
|
3]) + " L'identifiant de la promotion est invalide ")
|
|
return False, " L'identifiant de la promotion est invalide "
|
|
|
|
"""
|
|
Si cette admission à lié à un process d'admission
|
|
"""
|
|
if ("process_inscription_id" in diction.keys() and diction['process_inscription_id']):
|
|
is_valide_process_admiss = MYSY_GV.dbname['admission_setup'].count_documents(
|
|
{'_id': ObjectId(str(diction['process_inscription_id'])),
|
|
'partner_owner_recid': str(my_partner['recid']),
|
|
'valide': '1'})
|
|
|
|
if (is_valide_process_admiss != 1):
|
|
mycommon.myprint(
|
|
str(inspect.stack()[0][
|
|
3]) + " L'identifiant du processus d'admission est invalide ")
|
|
return False, " L'identifiant du processus d'admission est invalide "
|
|
|
|
|
|
if ("price_by" in diction.keys()):
|
|
if (str(diction['price_by']) not in MYSY_GV.TRAINING_PRICE):
|
|
mycommon.myprint(str(inspect.stack()[0][3]) + " Le prix par " + str(
|
|
diction['price_by']) + " n'est valide. Les valeurs autorisées sont " + str(MYSY_GV.TRAINING_PRICE))
|
|
return False, " Le prix par " + str(
|
|
diction['price_by']) + " n'est valide. Les valeurs autorisées sont " + str(
|
|
MYSY_GV.TRAINING_PRICE) + " "
|
|
|
|
if ("location_type" in diction.keys()):
|
|
if (str(diction['location_type']).lower() not in MYSY_GV.TRAINING_LOCATION_TYPE):
|
|
mycommon.myprint(str(inspect.stack()[0][3]) + " - Le champ 'location_type' est incorrecte.")
|
|
return False, "Le champ 'location_type' est incorrect."
|
|
|
|
if ("entre_scolaire" in diction.keys()):
|
|
if (str(diction['entre_scolaire']).lower() not in MYSY_GV.TRAINING_ENTREE_SCOLAIRE):
|
|
mycommon.myprint(str(inspect.stack()[0][3]) + " - Le champ 'Entrée scolaire' est incorrecte.")
|
|
return False, "Le champ 'Entrée scolaire' est incorrect."
|
|
|
|
|
|
if ("formateur_id" in diction.keys() and diction['formateur_id']):
|
|
formateur_id = diction['formateur_id']
|
|
# Verification de la validité du formateur (collection employé)
|
|
is_formateur_id_ok = MYSY_GV.dbname['ressource_humaine'].count_documents(
|
|
{'_id': ObjectId(str(formateur_id)),
|
|
'partner_recid': str(my_partner['recid']),
|
|
'valide': '1',
|
|
'locked': '0'
|
|
})
|
|
|
|
if (is_formateur_id_ok <= 0):
|
|
mycommon.myprint(str(inspect.stack()[0][3]) + " - L'identifiant du responsable est invalide")
|
|
return False, " L'identifiant du responsable est invalide "
|
|
|
|
if (datetime.strptime(str(diction['date_debut'])[0:10], '%d/%m/%Y') > datetime.strptime(
|
|
str(diction['date_fin'])[0:10], '%d/%m/%Y')):
|
|
mycommon.myprint(
|
|
str(inspect.stack()[0][
|
|
3]) + " La date debut " + str(
|
|
diction['date_debut'])[0:10] +
|
|
" est postérieure à la date de fin " + str(diction['date_fin'])[0:10])
|
|
|
|
return False, " La date debut de formation " + str(diction['date_debut'])[0:10] + \
|
|
" est postérieure à la date de fin de formation " + str(diction['date_fin'])[0:10] + " "
|
|
|
|
# Verification de la cohérence des dates d'inscription si on a bien une date debut et une date de fin
|
|
if ("date_debut_inscription" in diction.keys() and "date_fin_inscription" in diction.keys()):
|
|
if (str(diction['date_debut_inscription']).strip() != "" and str(
|
|
diction['date_fin_inscription']).strip() != ""):
|
|
local_status = mycommon.CheckisDate(str(diction['date_debut_inscription'])[0:10])
|
|
if (local_status is False):
|
|
mycommon.myprint(
|
|
str(inspect.stack()[0][
|
|
3]) + " La date_debut_inscription n'est pas au format jj/mm/aaaa ")
|
|
|
|
return False, " La date de début d'inscription n'est pas au format jj/mm/aaaa "
|
|
|
|
local_status = mycommon.CheckisDate(str(diction['date_fin_inscription'])[0:10])
|
|
if (local_status is False):
|
|
mycommon.myprint(
|
|
str(inspect.stack()[0][
|
|
3]) + " La date de fin d'inscription n'est pas au format jj/mm/aaaa ")
|
|
|
|
return False, " La date de fin d'inscription n'est pas au format jj/mm/aaaa "
|
|
|
|
if (datetime.strptime(str(diction['date_debut_inscription'])[0:10], '%d/%m/%Y') > datetime.strptime(
|
|
str(diction['date_fin_inscription'])[0:10], '%d/%m/%Y')):
|
|
mycommon.myprint(
|
|
str(inspect.stack()[0][
|
|
3]) + " La date de début d'inscription " + str(
|
|
diction['date_debut_inscription'])[0:10] + \
|
|
" est postérieure à la date de fin d'inscription " + str(diction['date_fin_inscription'])[
|
|
0:10] + " ")
|
|
|
|
return False, " La date de début d'inscription " + str(
|
|
diction['date_debut_inscription'])[0:10] + \
|
|
" est postérieure à la date de fin d'inscription " + str(
|
|
diction['date_fin_inscription'])[0:10] + " "
|
|
|
|
# Verification : Date de debut inscription n'est pas > date de fin de formation
|
|
if (datetime.strptime(str(diction['date_debut_inscription'])[0:10], '%d/%m/%Y') > datetime.strptime(
|
|
str(diction['date_fin'])[0:10], '%d/%m/%Y')):
|
|
mycommon.myprint(
|
|
str(inspect.stack()[0][
|
|
3]) + " La date de debut d'inscription " + str(diction[
|
|
'date_debut_inscription']) + " est postérieure à la date de fin de formation " + str(
|
|
diction['date_fin']))
|
|
|
|
return False, " La date de debut d'inscription " + str(
|
|
diction['date_debut_inscription'])[
|
|
0:10] + " est postérieure à la date de fin de formation " + str(
|
|
diction['date_fin'])[0:10] + " "
|
|
|
|
# Verification : Date de fin inscription n'est pas > date de fin de formation
|
|
if (datetime.strptime(str(diction['date_fin_inscription'])[0:10], '%d/%m/%Y') > datetime.strptime(
|
|
str(diction['date_fin'])[0:10], '%d/%m/%Y')):
|
|
mycommon.myprint(
|
|
str(inspect.stack()[0][3]) + " La date de fin d'inscription " + str(
|
|
diction['date_fin_inscription'])[
|
|
0:10] + " est postérieure à la date de fin de la formation " + str(
|
|
diction['date_fin'])[0:10])
|
|
|
|
return False, " La date de fin d'inscription " + str(diction['date_fin_inscription'])[
|
|
0:10] + " est postérieure à la date de fin de la formation " + str(
|
|
diction['date_fin'])[0:10] + " "
|
|
|
|
|
|
local_id = str(diction['_id'])
|
|
|
|
del diction['token']
|
|
del diction['_id']
|
|
|
|
|
|
new_data['update_date'] = 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)
|
|
|
|
result = MYSY_GV.dbname['admission_session'].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 la session d'admission (2) ")
|
|
return False, " Impossible de mettre à jour la session d'admission (2) "
|
|
|
|
now = str(datetime.now().strftime("%d/%m/%Y %H:%M:%S"))
|
|
history_event_dict = {}
|
|
history_event_dict['token'] = str(token)
|
|
history_event_dict['related_collection'] = "admission_session"
|
|
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, " La session 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 session d'admission "
|
|
|
|
|
|
"""
|
|
Suppression d'une session d'admission
|
|
regles :
|
|
- supprimer les inscrits
|
|
"""
|
|
|
|
def Delete_Admission_Session(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
|
|
|
|
|
|
|
|
delete = MYSY_GV.dbname['admission_session'].delete_one({'_id': ObjectId(str(diction['_id'])),
|
|
'partner_owner_recid': str(my_partner['recid']),
|
|
}, )
|
|
|
|
|
|
return True, " La session d'admission 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 session d'admission "
|
|
|
|
|
|
"""
|
|
Recuperer la liste des session d'admission d'un partenaire
|
|
"""
|
|
def Get_List_Admission_Session(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'est pas autorisé ")
|
|
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['admission_session'].find(data_cle).sort([("_id", pymongo.DESCENDING), ]):
|
|
user = retval
|
|
user['id'] = str(val_tmp)
|
|
val_tmp = val_tmp + 1
|
|
|
|
class_session_id_code = ""
|
|
if( "class_session_id" in retval.keys() and retval['class_session_id'] ):
|
|
promo_data = MYSY_GV.dbname['session_formation'].find_one({'_id':ObjectId(str(retval['class_session_id'])),
|
|
'partner_owner_recid':str(my_partner['recid']),
|
|
'valide':'1'})
|
|
|
|
if(promo_data and "code_session" in promo_data.keys() ):
|
|
class_session_id_code = promo_data['code_session']
|
|
|
|
user['class_session_id_code'] = class_session_id_code
|
|
|
|
process_inscription_id_code = ""
|
|
if ("process_inscription_id" in retval.keys() and retval['process_inscription_id']):
|
|
process_admiss_data = MYSY_GV.dbname['admission_setup'].find_one(
|
|
{'_id': ObjectId(str(retval['process_inscription_id'])),
|
|
'partner_owner_recid': str(my_partner['recid']),
|
|
'valide': '1'})
|
|
|
|
if (process_admiss_data and "code" in process_admiss_data.keys()):
|
|
process_inscription_id_code = process_admiss_data['code']
|
|
|
|
user['process_inscription_id_code'] = process_inscription_id_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 sessions d'admission "
|
|
|
|
|
|
|
|
"""
|
|
Recuperer les données d'une session d'admission donnée
|
|
"""
|
|
def Get_Given_Admission_Session(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
|
|
|
|
"""
|
|
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['admission_session'].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 les données de la session d'admission "
|
|
|
|
|
|
"""
|
|
Inscrire une personne à une session d'admission
|
|
"""
|
|
|
|
def Add_Stagiaire_To_Admission_Session(diction):
|
|
try:
|
|
# Dictionnaire des champs utilisables
|
|
'''
|
|
# 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', 'nom', 'prenom', 'email', 'telephone', 'modefinancement',
|
|
'session_id', 'employeur', 'status', 'price',
|
|
'client_rattachement_id', 'adresse', 'code_postal', 'ville', 'pays',
|
|
'type_apprenant', 'civilite', 'date_naissance', 'memo', 'comment',
|
|
"num_secu", "is_rgpd", "situation_famille", "piece_identite_type", "piece_identite_num",
|
|
"type_mobilite", "telephone_bis", "nationalite", "is_handicap", "is_handicap", "is_droit_image",
|
|
'naissance_lieu', 'naissance_departement', 'naissance_pays', 'session_etape'
|
|
]
|
|
|
|
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, "Toutes les informations fournies ne sont pas valables"
|
|
|
|
"""
|
|
Verification de la liste des champs obligatoires
|
|
"""
|
|
field_list_obligatoire = ['nom', 'prenom', 'email', 'telephone',
|
|
'session_id', '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, "Impossible de créer le stagiaire. La valeur '" + val + "' n'est pas presente dans la liste des arguments"
|
|
|
|
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
|
|
|
|
|
|
"""
|
|
Verififier l'existance et la valididé de la session
|
|
"""
|
|
my_session_data_qry = {"_id": ObjectId(str(diction['session_id'])), 'valide': '1'}
|
|
# print(" AddStagiairetoClass my_session_data_qry = ", my_session_data_qry)
|
|
|
|
my_session_data = MYSY_GV.dbname['admission_session'].find_one(my_session_data_qry)
|
|
if (my_session_data is None):
|
|
mycommon.myprint(
|
|
str(inspect.stack()[0][3]) + " L'identifiant de la session est invalide ")
|
|
return False, " L'identifiant de la session est invalide"
|
|
|
|
"""
|
|
Verifier qu'il n'y pas déjà une presonne inscrite avec le meme email pour la meme session
|
|
"""
|
|
is_inscrit_exist = MYSY_GV.dbname['admission_session_inscrit'].count_documents({'email':diction['email'],
|
|
'session_id':diction['session_id'],
|
|
'partner_owner_recid':my_partner['recid']})
|
|
|
|
if( is_inscrit_exist > 0 ):
|
|
mycommon.myprint(
|
|
str(inspect.stack()[0][3]) + " Une personne est déjà inscrite à cette session avec la même adresse email ")
|
|
return False, " Une personne est déjà inscrite à cette session avec la même adresse email "
|
|
|
|
"""
|
|
Verifier la validité de l'etape
|
|
"""
|
|
if ("session_etape" in diction.keys() and str(diction['session_etape'])):
|
|
session_etape_id = MYSY_GV.dbname['admission_setup_etape'].count_documents(
|
|
{"_id": ObjectId(str(diction['session_etape'])),
|
|
'valide': '1', 'partner_owner_recid': str(my_partner['recid'])})
|
|
|
|
if (session_etape_id != 1):
|
|
mycommon.myprint(
|
|
str(inspect.stack()[0][3]) + " L'identifiant de l'etape est invalide ")
|
|
return False, " L'identifiant de l'etape est invalide "
|
|
|
|
|
|
if ("is_handicap" in diction.keys() and str(diction['is_handicap']) not in ['0', '1', '']):
|
|
mycommon.myprint(
|
|
str(inspect.stack()[0][3]) + " Le champ 'is_handicap' est invalide ")
|
|
return False, " Le champ 'is_handicap' est invalide "
|
|
|
|
if ("is_droit_image" in diction.keys() and str(diction['is_droit_image']) not in ['0', '1', '']):
|
|
mycommon.myprint(
|
|
str(inspect.stack()[0][3]) + " Le champ 'is_droit_image' est invalide ")
|
|
return False, " Le champ 'is_droit_image' est invalide "
|
|
|
|
if ("is_rgpd" in diction.keys() and str(diction['is_rgpd']) not in ['0', '1', '']):
|
|
mycommon.myprint(
|
|
str(inspect.stack()[0][3]) + " Le champ 'is_rgpd' est invalide ")
|
|
return False, " Le champ 'is_rgpd' est invalide "
|
|
|
|
|
|
if ("date_naissance" in diction.keys()):
|
|
if diction['date_naissance']:
|
|
date_naissance = str(diction['date_naissance']).strip()
|
|
local_status = mycommon.CheckisDate(date_naissance)
|
|
if (local_status is False):
|
|
mycommon.myprint(
|
|
str(inspect.stack()[0][
|
|
3]) + " La date de naissance n'est pas au format 'jj/mm/aaaa' ")
|
|
return False, " La date de naissance n'est pas au format 'jj/mm/aaaa' "
|
|
|
|
|
|
|
|
if ("type_apprenant" in diction.keys() and diction['type_apprenant']):
|
|
type_apprenant = str(mycommon.tryInt(diction['type_apprenant']))
|
|
if (type_apprenant not in MYSY_GV.INSCRIPTION_TYPE_APPRENANT):
|
|
mycommon.myprint(
|
|
str(inspect.stack()[0][3]) + " Le type d'apprenant est invalide ")
|
|
return False, " Le type d'apprenant est invalide. Valeurs autorisées" + str(
|
|
MYSY_GV.INSCRIPTION_TYPE_APPRENANT)
|
|
|
|
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['creation_date'] = str(datetime.now())
|
|
new_data['creation_by'] = str(my_partner['_id'])
|
|
new_data['partner_owner_recid'] = str(my_partner['recid'])
|
|
new_data['valide'] = "1"
|
|
new_data['locked'] = "0"
|
|
|
|
if ("date_naissance" in new_data.keys() and new_data['date_naissance'] == ""):
|
|
new_data['date_naissance'] = "01/01/1900"
|
|
|
|
if ("date_naissance" not in new_data.keys()):
|
|
new_data['date_naissance'] = "01/01/1900"
|
|
|
|
inserted_data = MYSY_GV.dbname['admission_session_inscrit'].insert_one(new_data)
|
|
if (not inserted_data.inserted_id):
|
|
mycommon.myprint(
|
|
" Impossible d'ajouter le candidat à la session d'admission (2) ")
|
|
return False, " Impossible d'ajouter le candidat à la session d'admission (2) "
|
|
|
|
|
|
|
|
now = str(datetime.now().strftime("%d/%m/%Y %H:%M:%S"))
|
|
history_event_dict = {}
|
|
history_event_dict['token'] = str(token)
|
|
history_event_dict['related_collection'] = "admission_session_inscrit"
|
|
history_event_dict['related_collection_recid'] = str(inserted_data.inserted_id)
|
|
history_event_dict['action_date'] = str(now)
|
|
history_event_dict['action_description'] = "Inscription du candidat "+str(new_data['nom'])+" "+str(new_data['prenom'])+" "+str(inserted_data.inserted_id)
|
|
|
|
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 candidat a été correctement ajouté"
|
|
|
|
|
|
except Exception as e:
|
|
exc_type, exc_obj, exc_tb = sys.exc_info()
|
|
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
|
|
return False, "Impossible d'ajouter le candidat à la session d'admission"
|
|
|
|
|
|
"""
|
|
Mettre à jour le session_etape d'une personne à une session d'admission
|
|
"""
|
|
|
|
def Update_Stagiaire_Only_Process_Step_Admission_Session(diction):
|
|
try:
|
|
# Dictionnaire des champs utilisables
|
|
'''
|
|
# 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', '_id', 'new_session_etape_code' ]
|
|
|
|
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, "Toutes les informations fournies ne sont pas valables"
|
|
|
|
"""
|
|
Verification de la liste des champs obligatoires
|
|
"""
|
|
field_list_obligatoire = ['token', '_id', 'new_session_etape_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, "Impossible de créer le stagiaire. La valeur '" + val + "' n'est pas presente dans la liste des arguments"
|
|
|
|
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 la validé de l'inscrit
|
|
"""
|
|
is_existe_inscrit = MYSY_GV.dbname['admission_session_inscrit'].count_documents(
|
|
{'_id': ObjectId(str(diction['_id'])),
|
|
'valide': '1',
|
|
'partner_owner_recid': str(my_partner['recid'])})
|
|
|
|
if (is_existe_inscrit != 1):
|
|
mycommon.myprint(
|
|
str(inspect.stack()[0][3]) + " L'identifiant du candidat est invalide ")
|
|
return False, " L'identifiant du candidat est invalide "
|
|
|
|
|
|
|
|
"""
|
|
Verifier la validité de l'etape
|
|
"""
|
|
session_etape_id = MYSY_GV.dbname['admission_setup_etape'].count_documents({"code":str(diction['new_session_etape_code']),
|
|
'valide':'1', 'partner_owner_recid': str(my_partner['recid'])})
|
|
|
|
if (session_etape_id <= 0):
|
|
mycommon.myprint(
|
|
str(inspect.stack()[0][3]) + " L'identifiant de l'etape est invalide ")
|
|
return False, " L'identifiant de l'etape est invalide "
|
|
|
|
session_etape_id_data = MYSY_GV.dbname['admission_setup_etape'].find_one({"code":str(diction['new_session_etape_code']),
|
|
'valide':'1', 'partner_owner_recid': str(my_partner['recid'])})
|
|
|
|
|
|
|
|
|
|
local_id = str(diction['_id'])
|
|
|
|
del diction['token']
|
|
del diction['_id']
|
|
|
|
new_data = {}
|
|
new_data['update_by'] = str(my_partner['_id'])
|
|
new_data['update_date'] = str(datetime.now())
|
|
new_data['session_etape'] = str(session_etape_id_data['_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['admission_session_inscrit'].find_one_and_update(
|
|
data_cle,
|
|
{"$set": new_data},
|
|
upsert=False,
|
|
return_document=ReturnDocument.AFTER
|
|
)
|
|
|
|
|
|
if (not result or "_id" not in result.keys()):
|
|
mycommon.myprint(
|
|
" Impossible de mettre à jour le candidat (2) ")
|
|
return False, " Impossible de mettre à jour le candidat (2) "
|
|
|
|
now = str(datetime.now().strftime("%d/%m/%Y %H:%M:%S"))
|
|
history_event_dict = {}
|
|
history_event_dict['token'] = str(token)
|
|
history_event_dict['related_collection'] = "admission_session_inscrit"
|
|
history_event_dict['related_collection_recid'] = str(local_id)
|
|
history_event_dict['action_date'] = str(now)
|
|
history_event_dict['action_description'] = "Changement étape pour " + str(result['nom']) + " " + str(
|
|
result['prenom']) + " " + str(result['_id'])
|
|
|
|
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 candidat 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) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
|
|
return False, "Impossible de mettre à jour le candidat "
|
|
|
|
|
|
|
|
"""
|
|
Mettre à jour le statut d'acceptation d'une personne à une session d'admission (PROCESS_ADMISSION_STATUS)
|
|
- accepté
|
|
- rejeté
|
|
- liste attente
|
|
"""
|
|
|
|
def Update_Stagiaire_Only_Status_Admission_Session(diction):
|
|
try:
|
|
# Dictionnaire des champs utilisables
|
|
'''
|
|
# 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', '_id', 'new_status' ]
|
|
|
|
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, "Toutes les informations fournies ne sont pas valables"
|
|
|
|
"""
|
|
Verification de la liste des champs obligatoires
|
|
"""
|
|
field_list_obligatoire = ['token', '_id', 'new_status' ]
|
|
|
|
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, "Impossible de créer le stagiaire. La valeur '" + val + "' n'est pas presente dans la liste des arguments"
|
|
|
|
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 la validé de l'inscrit
|
|
"""
|
|
is_existe_inscrit = MYSY_GV.dbname['admission_session_inscrit'].count_documents(
|
|
{'_id': ObjectId(str(diction['_id'])),
|
|
'valide': '1',
|
|
'partner_owner_recid': str(my_partner['recid'])})
|
|
|
|
if (is_existe_inscrit != 1):
|
|
mycommon.myprint(
|
|
str(inspect.stack()[0][3]) + " L'identifiant du candidat est invalide ")
|
|
return False, " L'identifiant du candidat est invalide "
|
|
|
|
is_existe_inscrit_data = MYSY_GV.dbname['admission_session_inscrit'].find_one(
|
|
{'_id': ObjectId(str(diction['_id'])),
|
|
'valide': '1',
|
|
'partner_owner_recid': str(my_partner['recid'])})
|
|
|
|
old_statut = is_existe_inscrit_data['status']
|
|
|
|
if( diction['new_status'] not in MYSY_GV.PROCESS_ADMISSION_STATUS):
|
|
mycommon.myprint(
|
|
str(inspect.stack()[0][3]) + " Le statut est invalide ")
|
|
return False, " Le statut est invalide "
|
|
|
|
|
|
|
|
|
|
local_id = str(diction['_id'])
|
|
|
|
del diction['token']
|
|
del diction['_id']
|
|
|
|
new_data = {}
|
|
new_data['update_by'] = str(my_partner['_id'])
|
|
new_data['update_date'] = str(datetime.now())
|
|
new_data['status'] = str(diction['new_status'])
|
|
|
|
|
|
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['admission_session_inscrit'].find_one_and_update(
|
|
data_cle,
|
|
{"$set": new_data},
|
|
upsert=False,
|
|
return_document=ReturnDocument.AFTER
|
|
)
|
|
|
|
|
|
if (not result or "_id" not in result.keys()):
|
|
mycommon.myprint(
|
|
" Impossible de mettre à jour le candidat (2) ")
|
|
return False, " Impossible de mettre à jour le candidat (2) "
|
|
|
|
now = str(datetime.now().strftime("%d/%m/%Y %H:%M:%S"))
|
|
history_event_dict = {}
|
|
history_event_dict['token'] = str(token)
|
|
history_event_dict['related_collection'] = "admission_session_inscrit"
|
|
history_event_dict['related_collection_recid'] = str(local_id)
|
|
history_event_dict['action_date'] = str(now)
|
|
history_event_dict['action_description'] = "Changement statut pour " + str(result['nom']) + " " + str(
|
|
result['prenom']) + " " + str(result['_id'])+" ==> de "+str(old_statut) +" => "+diction['new_status']
|
|
|
|
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 statut 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) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
|
|
return False, "Impossible de mettre à jour le candidat "
|
|
|
|
|
|
|
|
"""
|
|
Mettre à jour une personne à une session d'admission
|
|
"""
|
|
|
|
def Update_Stagiaire_To_Admission_Session(diction):
|
|
try:
|
|
# Dictionnaire des champs utilisables
|
|
'''
|
|
# 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', '_id', 'nom', 'prenom', 'email', 'telephone', 'modefinancement',
|
|
'session_id', 'employeur', 'status', 'price',
|
|
'client_rattachement_id', 'adresse', 'code_postal', 'ville', 'pays',
|
|
'type_apprenant', 'civilite', 'date_naissance', 'memo', 'comment',
|
|
"num_secu", "is_rgpd", "situation_famille", "piece_identite_type", "piece_identite_num",
|
|
"type_mobilite", "telephone_bis", "nationalite", "is_handicap", "is_droit_image",
|
|
'naissance_lieu', 'naissance_departement', 'naissance_pays', 'session_etape'
|
|
]
|
|
|
|
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, "Toutes les informations fournies ne sont pas valables"
|
|
|
|
"""
|
|
Verification de la liste des champs obligatoires
|
|
"""
|
|
field_list_obligatoire = ['nom', 'prenom', 'email', 'telephone',
|
|
'session_id', '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, "Impossible de créer le stagiaire. La valeur '" + val + "' n'est pas presente dans la liste des arguments"
|
|
|
|
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 la validé de l'inscrit
|
|
"""
|
|
is_existe_inscrit = MYSY_GV.dbname['admission_session_inscrit'].count_documents(
|
|
{'_id': ObjectId(str(diction['_id'])),
|
|
'valide': '1',
|
|
'partner_owner_recid': str(my_partner['recid'])})
|
|
|
|
if (is_existe_inscrit != 1):
|
|
mycommon.myprint(
|
|
str(inspect.stack()[0][3]) + " L'identifiant du candidat est invalide ")
|
|
return False, " L'identifiant du candidat est invalide "
|
|
|
|
"""
|
|
Verififier l'existance et la valididé de la session
|
|
"""
|
|
my_session_data_qry = {"_id": ObjectId(str(diction['session_id'])), 'valide': '1'}
|
|
# print(" AddStagiairetoClass my_session_data_qry = ", my_session_data_qry)
|
|
|
|
my_session_data = MYSY_GV.dbname['admission_session'].find_one(my_session_data_qry)
|
|
if (my_session_data is None):
|
|
mycommon.myprint(
|
|
str(inspect.stack()[0][3]) + " L'identifiant de la session est invalide ")
|
|
return False, " L'identifiant de la session est invalide"
|
|
|
|
"""
|
|
Verifier la validité de l'etape
|
|
"""
|
|
if("session_etape" in diction.keys() and str(diction['session_etape']) ):
|
|
session_etape_id = MYSY_GV.dbname['admission_setup_etape'].count_documents(
|
|
{"_id": ObjectId(str(diction['session_etape'])),
|
|
'valide': '1', 'partner_owner_recid': str(my_partner['recid'])})
|
|
|
|
if (session_etape_id != 1):
|
|
mycommon.myprint(
|
|
str(inspect.stack()[0][3]) + " L'identifiant de l'etape est invalide ")
|
|
return False, " L'identifiant de l'etape est invalide "
|
|
|
|
|
|
if ("is_handicap" in diction.keys() and str(diction['is_handicap']) not in ['0', '1', '']):
|
|
mycommon.myprint(
|
|
str(inspect.stack()[0][3]) + " Le champ 'is_handicap' est invalide ")
|
|
return False, " Le champ 'is_handicap' est invalide "
|
|
|
|
if ("is_droit_image" in diction.keys() and str(diction['is_droit_image']) not in ['0', '1', '']):
|
|
mycommon.myprint(
|
|
str(inspect.stack()[0][3]) + " Le champ 'is_droit_image' est invalide ")
|
|
return False, " Le champ 'is_droit_image' est invalide "
|
|
|
|
if ("is_rgpd" in diction.keys() and str(diction['is_rgpd']) not in ['0', '1', '']):
|
|
mycommon.myprint(
|
|
str(inspect.stack()[0][3]) + " Le champ 'is_rgpd' est invalide ")
|
|
return False, " Le champ 'is_rgpd' est invalide "
|
|
|
|
if ("date_naissance" in diction.keys()):
|
|
if diction['date_naissance']:
|
|
date_naissance = str(diction['date_naissance']).strip()
|
|
local_status = mycommon.CheckisDate(date_naissance)
|
|
if (local_status is False):
|
|
mycommon.myprint(
|
|
str(inspect.stack()[0][
|
|
3]) + " La date de naissance n'est pas au format 'jj/mm/aaaa' ")
|
|
return False, " La date de naissance n'est pas au format 'jj/mm/aaaa' "
|
|
|
|
|
|
|
|
if ("type_apprenant" in diction.keys() and diction['type_apprenant']):
|
|
type_apprenant = str(mycommon.tryInt(diction['type_apprenant']))
|
|
if (type_apprenant not in MYSY_GV.INSCRIPTION_TYPE_APPRENANT):
|
|
mycommon.myprint(
|
|
str(inspect.stack()[0][3]) + " Le type d'apprenant est invalide ")
|
|
return False, " Le type d'apprenant est invalide. Valeurs autorisées" + str(
|
|
MYSY_GV.INSCRIPTION_TYPE_APPRENANT)
|
|
|
|
local_id = str(diction['_id'])
|
|
|
|
del diction['token']
|
|
del diction['_id']
|
|
|
|
new_data = diction
|
|
new_data['update_date'] = str(datetime.now())
|
|
new_data['update_by'] = str(my_partner['_id'])
|
|
|
|
if( "date_naissance" in new_data.keys() and new_data['date_naissance'] == ""):
|
|
new_data['date_naissance'] = "01/01/1900"
|
|
|
|
if( "date_naissance" not in new_data.keys() ):
|
|
new_data['date_naissance'] = "01/01/1900"
|
|
|
|
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"
|
|
|
|
print(" ### data_cle = ", data_cle)
|
|
|
|
|
|
result = MYSY_GV.dbname['admission_session_inscrit'].find_one_and_update(
|
|
data_cle,
|
|
{"$set": new_data},
|
|
upsert=False,
|
|
return_document=ReturnDocument.AFTER
|
|
)
|
|
|
|
|
|
if (not result or "_id" not in result.keys()):
|
|
mycommon.myprint(
|
|
" Impossible de mettre à jour le candidat (2) ")
|
|
return False, " Impossible de mettre à jour le candidat (2) "
|
|
|
|
now = str(datetime.now().strftime("%d/%m/%Y %H:%M:%S"))
|
|
history_event_dict = {}
|
|
history_event_dict['token'] = str(token)
|
|
history_event_dict['related_collection'] = "admission_session_inscrit"
|
|
history_event_dict['related_collection_recid'] = str(local_id)
|
|
history_event_dict['action_date'] = str(now)
|
|
history_event_dict['action_description'] = "Inscription du candidat " + str(result['nom']) + " " + str(
|
|
result['prenom']) + " " + str(result['_id'])
|
|
|
|
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 candidat 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) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
|
|
return False, "Impossible de mettre à jour le candidat "
|
|
|
|
|
|
|
|
"""
|
|
Suppression de l'inscription d'une personne à une session d'admission
|
|
"""
|
|
def Delete_Stagiaire_To_Admission_Session(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
|
|
|
|
delete = MYSY_GV.dbname['admission_session_inscrit'].delete_one({'_id': ObjectId(str(diction['_id'])),
|
|
'partner_owner_recid': str(my_partner['recid']),
|
|
}, )
|
|
|
|
return True, " L'inscription 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'inscription "
|
|
|
|
|
|
"""
|
|
Recuperer la liste des personne à une session d'admission
|
|
"""
|
|
def Get_List_Stagiaire_Admission_Session(diction):
|
|
try:
|
|
diction = mycommon.strip_dictionary(diction)
|
|
|
|
"""
|
|
Verification des input acceptés
|
|
"""
|
|
field_list = ['token', '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', 'session_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['session_id'] = str(diction['session_id'])
|
|
data_cle['valide'] = "1"
|
|
data_cle['locked'] = "0"
|
|
|
|
|
|
RetObject = []
|
|
val_tmp = 0
|
|
|
|
for retval in MYSY_GV.dbname['admission_session_inscrit'].find(data_cle).sort([("_id", pymongo.DESCENDING), ]):
|
|
user = retval
|
|
user['id'] = str(val_tmp)
|
|
val_tmp = val_tmp + 1
|
|
|
|
|
|
if ("date_naissance" not in retval.keys() or retval['date_naissance'] == ""):
|
|
retval['date_naissance'] = "01/01/1900"
|
|
|
|
if ("civilite" not in retval.keys() or retval['civilite'] == ""):
|
|
retval['civilite'] = "neutre"
|
|
|
|
|
|
age = relativedelta( date.today(), datetime.strptime(str(retval['date_naissance']), '%d/%m/%Y') )
|
|
retval['age'] = str(age.years)
|
|
|
|
session_etape_code = ""
|
|
if( "session_etape" in retval.keys() and retval['session_etape'] ):
|
|
admiss_session_etape_data = MYSY_GV.dbname['admission_setup_etape'].find_one(({'_id':ObjectId(str(retval['session_etape'])),
|
|
'valide':'1',
|
|
'partner_owner_recid':str(my_partner['recid'])}))
|
|
if( admiss_session_etape_data and "code" in admiss_session_etape_data.keys()):
|
|
session_etape_code = admiss_session_etape_data['code']
|
|
|
|
retval['session_etape_code'] = str(session_etape_code)
|
|
|
|
local_status, local_retval = Internal_Get_Pourcentage_Candidat_Document({'partner_recid':str(my_partner['recid']), 'inscrit_id':str(retval['_id'])})
|
|
if(local_status ):
|
|
retval['document_satatus'] = local_retval
|
|
if( "pourcentage_accepted" in local_retval.keys()):
|
|
retval['document_pourcentage_accepted'] = str(local_retval['pourcentage_accepted'])
|
|
|
|
if ("pourcentage_send" in local_retval.keys()):
|
|
retval['taux_document_pourcentage_received'] = str(local_retval['pourcentage_send'])
|
|
|
|
else:
|
|
retval['document_pourcentage_accepted'] = "0"
|
|
retval['taux_document_pourcentage_received'] = "0"
|
|
|
|
if( retval['document_pourcentage_accepted'] != "1"):
|
|
retval['document_alert_message'] = "Tous les documents ne sont pas validés"
|
|
else:
|
|
retval['document_alert_message'] = ""
|
|
|
|
|
|
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 inscrits"
|
|
|
|
"""
|
|
Recuperer les données d'une personne inscrite à une session d'admission
|
|
"""
|
|
def Get_Given_Stagiaire_Admission_Session(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
|
|
|
|
"""
|
|
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
|
|
|
|
print(" ## data_cle = ", data_cle)
|
|
|
|
for retval in MYSY_GV.dbname['admission_session_inscrit'].find(data_cle):
|
|
user = retval
|
|
user['id'] = str(val_tmp)
|
|
|
|
if ("date_naissance" not in retval.keys() or retval['date_naissance'] == ""):
|
|
retval['date_naissance'] = "01/01/1900"
|
|
|
|
if ("civilite" not in retval.keys() or retval['civilite'] == ""):
|
|
retval['civilite'] = "neutre"
|
|
|
|
age = relativedelta(date.today(), datetime.strptime(str(retval['date_naissance']), '%d/%m/%Y'))
|
|
retval['age'] = str(age.years)
|
|
|
|
session_etape_code = ""
|
|
if ("session_etape" in retval.keys() and retval['session_etape']):
|
|
admiss_session_etape_data = MYSY_GV.dbname['admission_setup_etape'].find_one(
|
|
({'_id': ObjectId(str(retval['session_etape'])),
|
|
'valide': '1',
|
|
'partner_owner_recid': str(my_partner['recid'])}))
|
|
if (admiss_session_etape_data and "code" in admiss_session_etape_data.keys()):
|
|
session_etape_code = admiss_session_etape_data['code']
|
|
|
|
retval['session_etape_code'] = str(session_etape_code)
|
|
|
|
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 de l'inscrit "
|
|
|
|
|
|
|
|
"""
|
|
Cette fonction ajoute ou met à jour une image de profil d'un inscrit à une session d'admission
|
|
"""
|
|
def Add_Update_Inscrit_Admiss_Session_Image(file_img=None, Folder=None, diction=None):
|
|
try:
|
|
|
|
# Dictionnaire des champs utilisables
|
|
'''
|
|
# 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', 'file_img_recid', 'inscrit_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, " Le champ '" + val + "' n'est pas accepté "
|
|
|
|
'''
|
|
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', 'file_img_recid', 'inscrit_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, " La valeur '" + val + "' n'est pas presente dans la liste des arguments "
|
|
|
|
# recuperation des paramettre
|
|
token = ""
|
|
if ("token" in diction.keys()):
|
|
if diction['token']:
|
|
token = diction['token']
|
|
|
|
local_status, my_partner = mycommon.Check_Connexion_And_Return_Partner_Data(diction)
|
|
if (local_status is not True):
|
|
return local_status, my_partner
|
|
|
|
# Verifier que l'apprenant est valide
|
|
is_inscrit_id_valide_count = MYSY_GV.dbname['admission_session_inscrit'].count_documents({'_id':ObjectId(diction['inscrit_id']),
|
|
'valide':'1',
|
|
'locked':'0',
|
|
'partner_owner_recid':str(my_partner['recid'])})
|
|
|
|
if( is_inscrit_id_valide_count != 1):
|
|
mycommon.myprint(str(inspect.stack()[0][3]) + " L'identifiant du candidat est invalide ")
|
|
return False, " L'identifiant du candidat est invalide "
|
|
|
|
inscrit_id_data = MYSY_GV.dbname['admission_session_inscrit'].find_one(
|
|
{'_id': ObjectId(diction['inscrit_id']),
|
|
'valide': '1',
|
|
'locked': '0',
|
|
'partner_owner_recid': str(my_partner['recid'])})
|
|
|
|
if( file_img ):
|
|
recordimage_diction = {}
|
|
recordimage_diction['token'] = diction['token']
|
|
recordimage_diction['related_collection'] = "admission_session_inscrit"
|
|
recordimage_diction['type_img'] = "user"
|
|
recordimage_diction['related_collection_recid'] = str(inscrit_id_data['_id'])
|
|
recordimage_diction['image_recid'] = diction['file_img_recid']
|
|
|
|
#print(" ### recordimage_diction stagaire = ", recordimage_diction)
|
|
local_status, local_message = mycommon.recordClassImage_v2(file_img, MYSY_GV.upload_folder, recordimage_diction)
|
|
if( local_status is False):
|
|
return local_status, local_message
|
|
|
|
return True, "L'image a été correctement enregistrée"
|
|
|
|
except Exception as e:
|
|
exc_type, exc_obj, exc_tb = sys.exc_info()
|
|
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
|
|
return False, "Impossible d'enregistrer l'image"
|
|
|
|
|
|
""" Recuperation de l'image d'un inscrit
|
|
|
|
Important : important : on prend le 'related_collection_recid' comme le '_id' de la collection de l'apprenant
|
|
"""
|
|
def Get_Inscrit_Admiss_Session_Recorded_Image_from_front(diction=None):
|
|
try:
|
|
# Dictionnaire des champs utilisables
|
|
field_list = ['token', 'inscrit_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, requete annulée")
|
|
return False, " Impossible de récupérer les informations"
|
|
|
|
'''
|
|
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', 'inscrit_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, " Impossible de récupérer les informations"
|
|
|
|
|
|
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 le candidat est valide
|
|
is_inscrit_id_valide_count = MYSY_GV.dbname['admission_session_inscrit'].count_documents(
|
|
{'_id': ObjectId(diction['inscrit_id']),
|
|
'valide': '1',
|
|
'locked': '0',
|
|
'partner_owner_recid': str(my_partner['recid'])})
|
|
|
|
if (is_inscrit_id_valide_count != 1):
|
|
mycommon.myprint(str(inspect.stack()[0][3]) + " L'identifiant du candidat est invalide ")
|
|
return False, " L'identifiant du candidat est invalide "
|
|
|
|
inscrit_id_data = MYSY_GV.dbname['admission_session_inscrit'].find_one(
|
|
{'_id': ObjectId(diction['inscrit_id']),
|
|
'valide': '1',
|
|
'locked': '0',
|
|
'partner_owner_recid': str(my_partner['recid'])})
|
|
|
|
|
|
|
|
qery_images = {'locked': '0', 'valide': '1', 'related_collection': 'admission_session_inscrit',
|
|
'related_collection_recid': str(inscrit_id_data['_id'])}
|
|
|
|
|
|
RetObject = []
|
|
partner_images = {}
|
|
# Recuperation des image 'logo' et 'cachet' si le partenaire en a
|
|
for retVal in MYSY_GV.dbname['mysy_images'].find(qery_images):
|
|
if ('type_img' in retVal.keys()):
|
|
if (retVal['type_img'] == "user"):
|
|
partner_images['logo_img'] = retVal['img'].decode()
|
|
partner_images['logo_img_recid'] = retVal['recid']
|
|
|
|
|
|
RetObject.append(mycommon.JSONEncoder().encode(partner_images))
|
|
|
|
return True, RetObject
|
|
|
|
except Exception as e:
|
|
exc_type, exc_obj, exc_tb = sys.exc_info()
|
|
print(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
|
|
return False, " Impossible de recupérer l'image"
|
|
|
|
"""
|
|
Suppression d'un image d'un inscrit à une session d'admission
|
|
"""
|
|
def Delete_Inscrit_Admiss_Session_Image(diction=None):
|
|
try:
|
|
|
|
# Dictionnaire des champs utilisables
|
|
field_list = ['token', 'image_recid', ]
|
|
incom_keys = diction.keys()
|
|
|
|
'''
|
|
# 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.
|
|
'''
|
|
for val in incom_keys:
|
|
if str(val).lower() not in str(field_list).lower():
|
|
mycommon.myprint(
|
|
str(inspect.stack()[0][3]) + " Le champ '" + val + "' n'est pas accepté dans cette API")
|
|
return False, " Le champ '" + val + "' n'est pas accepté "
|
|
|
|
'''
|
|
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', 'image_recid']
|
|
for val in field_list_obligatoire:
|
|
if str(val).lower() not in diction:
|
|
mycommon.myprint(
|
|
str(inspect.stack()[0][3]) + " La valeur '" + val + "' n'est pas presente dans la liste des arguments des champs")
|
|
return False, " La valeur '" + val + "' n'est pas presente dans la liste des arguments "
|
|
|
|
mydata = {}
|
|
mytoken = ""
|
|
|
|
# recuperation des paramettre
|
|
if ("token" in diction.keys()):
|
|
if diction['token']:
|
|
mytoken = diction['token']
|
|
|
|
image_recid = ""
|
|
if ("image_recid" in diction.keys()):
|
|
if diction['image_recid']:
|
|
image_recid = diction['image_recid']
|
|
|
|
local_status, my_partner = mycommon.Check_Connexion_And_Return_Partner_Data(diction)
|
|
if (local_status is not True):
|
|
return local_status, my_partner
|
|
|
|
# " Lecture du fichier "
|
|
# print(" Lecture du fichier : " + saved_file + ". le token est :" + str(mytoken))
|
|
nb_line = 0
|
|
coll_name = MYSY_GV.dbname['mysy_images']
|
|
|
|
query_delete = {"recid": image_recid,}
|
|
|
|
|
|
ret_val = coll_name.delete_one({"recid": image_recid,}, )
|
|
|
|
|
|
|
|
#print(" ### recordClassImage_v2 :L'image a été correctement supprimée ")
|
|
return True, "L'image a été correctement supprimée"
|
|
|
|
|
|
except Exception as e:
|
|
exc_type, exc_obj, exc_tb = sys.exc_info()
|
|
print(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
|
|
return False, "Impossible de supprimer l'image "
|
|
|
|
|
|
"""
|
|
Recuperer les document fournis par un candidat dans le cadre d'un process d'inscription
|
|
"""
|
|
|
|
def Get_List_Candidat_Document(diction=None):
|
|
try:
|
|
|
|
# Dictionnaire des champs utilisables
|
|
field_list = ['token', 'inscrit_id', ]
|
|
incom_keys = diction.keys()
|
|
|
|
'''
|
|
# 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.
|
|
'''
|
|
for val in incom_keys:
|
|
if str(val).lower() not in str(field_list).lower():
|
|
mycommon.myprint(
|
|
str(inspect.stack()[0][3]) + " Le champ '" + val + "' n'est pas accepté dans cette API")
|
|
return False, " Le champ '" + val + "' n'est pas accepté "
|
|
|
|
'''
|
|
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', 'inscrit_id', ]
|
|
for val in field_list_obligatoire:
|
|
if str(val).lower() not in diction:
|
|
mycommon.myprint(
|
|
str(inspect.stack()[0][3]) + " La valeur '" + val + "' n'est pas presente dans la liste des arguments des champs")
|
|
return False, " La valeur '" + val + "' n'est pas presente dans la liste des arguments "
|
|
|
|
mydata = {}
|
|
mytoken = ""
|
|
|
|
# recuperation des paramettre
|
|
if ("token" in diction.keys()):
|
|
if diction['token']:
|
|
mytoken = diction['token']
|
|
|
|
image_recid = ""
|
|
if ("image_recid" in diction.keys()):
|
|
if diction['image_recid']:
|
|
image_recid = diction['image_recid']
|
|
|
|
local_status, my_partner = mycommon.Check_Connexion_And_Return_Partner_Data(diction)
|
|
if (local_status is not True):
|
|
return local_status, my_partner
|
|
|
|
candidat_data = MYSY_GV.dbname['admission_session_inscrit'].find_one(
|
|
{'_id': ObjectId(str(diction['inscrit_id'])),
|
|
'valide': '1',
|
|
'partner_owner_recid': str(my_partner['recid'])})
|
|
|
|
tab_relance_doc = []
|
|
if( "relances_document" in candidat_data.keys()):
|
|
tab_relance_doc = candidat_data['relances_document']
|
|
|
|
print(" ## tab_relance_doc = ", tab_relance_doc)
|
|
|
|
qry_match = {"partner_owner_recid": str(my_partner['recid']), 'valide': '1', 'locked': '0'}
|
|
|
|
pipe_qry = ([
|
|
{"$addFields": {"admission_setup_document_id": {"$toString": "$_id"}}},
|
|
{'$match': qry_match},
|
|
{'$sort': {'_id': -1}},
|
|
{'$lookup': {
|
|
'from': 'download_files',
|
|
"let": {'admission_setup_document_id': "$admission_setup_document_id", 'partner_owner_recid': '$partner_owner_recid'},
|
|
'pipeline': [
|
|
{'$match':
|
|
{'$expr':
|
|
{'$and':
|
|
[
|
|
{'$eq': ["$admission_setup_document_id", '$$admission_setup_document_id']},
|
|
{'$eq': ["$valide", "1"]},
|
|
{'$eq': ["$partner_owner_recid", '$$partner_owner_recid']},
|
|
|
|
{'$eq': ["$object_owner_id", str(diction['inscrit_id'])]},
|
|
{'$eq': ["$object_owner_collection", 'admission_session_inscrit_document']},
|
|
|
|
]
|
|
}
|
|
}
|
|
},
|
|
],
|
|
'as': 'collection_download_files'
|
|
}
|
|
},
|
|
|
|
])
|
|
|
|
print(" #### Get_List_Candidat_Document pipe_qry = ", pipe_qry)
|
|
|
|
RetObject = []
|
|
val_tmp = 0
|
|
for New_retVal in MYSY_GV.dbname['admission_setup_document'].aggregate(pipe_qry):
|
|
#print(" ## New_retVal = ",New_retVal)
|
|
|
|
if( "collection_download_files" in New_retVal.keys()):
|
|
for tmp_data in New_retVal['collection_download_files']:
|
|
if( "acceptance_status" not in tmp_data.keys()):
|
|
tmp_data['acceptance_status'] = ''
|
|
|
|
"""
|
|
Recuperer la dernière date de relance si il y a déja eu de la relance
|
|
"""
|
|
last_relance = ""
|
|
list_relance = []
|
|
|
|
for tmp in tab_relance_doc :
|
|
|
|
if( "document_id" in tmp.keys() and
|
|
"document_id" in New_retVal.keys() and
|
|
tmp['document_id'] == New_retVal['admission_setup_document_id']):
|
|
|
|
list_relance.append(tmp)
|
|
last_relance = "Dernière relance : "+str(tmp['document_date_relance'])[0:16]+" - Email"
|
|
|
|
|
|
|
|
user = New_retVal
|
|
user['id'] = str(val_tmp)
|
|
user['relances_document'] = list_relance
|
|
user['last_relance'] = last_relance
|
|
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()
|
|
print(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
|
|
return False, "Impossible de recuperer la liste des documents du candidat "
|
|
|
|
|
|
"""
|
|
Cette fonction definit la completude des pièce jointe jointe d'un candidat
|
|
% de pièce validé
|
|
"""
|
|
def Get_Pourcentage_Candidat_Document(diction=None):
|
|
try:
|
|
|
|
# Dictionnaire des champs utilisables
|
|
field_list = ['token', 'inscrit_id', ]
|
|
incom_keys = diction.keys()
|
|
|
|
'''
|
|
# 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.
|
|
'''
|
|
for val in incom_keys:
|
|
if str(val).lower() not in str(field_list).lower():
|
|
mycommon.myprint(
|
|
str(inspect.stack()[0][3]) + " Le champ '" + val + "' n'est pas accepté dans cette API")
|
|
return False, " Le champ '" + val + "' n'est pas accepté "
|
|
|
|
'''
|
|
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', 'inscrit_id', ]
|
|
for val in field_list_obligatoire:
|
|
if str(val).lower() not in diction:
|
|
mycommon.myprint(
|
|
str(inspect.stack()[0][3]) + " La valeur '" + val + "' n'est pas presente dans la liste des arguments des champs")
|
|
return False, " La valeur '" + val + "' n'est pas presente dans la liste des arguments "
|
|
|
|
mydata = {}
|
|
mytoken = ""
|
|
|
|
# recuperation des paramettre
|
|
if ("token" in diction.keys()):
|
|
if diction['token']:
|
|
mytoken = diction['token']
|
|
|
|
image_recid = ""
|
|
if ("image_recid" in diction.keys()):
|
|
if diction['image_recid']:
|
|
image_recid = diction['image_recid']
|
|
|
|
local_status, my_partner = mycommon.Check_Connexion_And_Return_Partner_Data(diction)
|
|
if (local_status is not True):
|
|
return local_status, my_partner
|
|
|
|
qry_match = {"partner_owner_recid": str(my_partner['recid']), 'valide': '1', 'locked': '0'}
|
|
|
|
pipe_qry = ([
|
|
{"$addFields": {"admission_setup_document_id": {"$toString": "$_id"}}},
|
|
{'$match': qry_match},
|
|
{'$sort': {'_id': -1}},
|
|
{'$lookup': {
|
|
'from': 'download_files',
|
|
"let": {'admission_setup_document_id': "$admission_setup_document_id", 'partner_owner_recid': '$partner_owner_recid'},
|
|
'pipeline': [
|
|
{'$match':
|
|
{'$expr':
|
|
{'$and':
|
|
[
|
|
{'$eq': ["$admission_setup_document_id", '$$admission_setup_document_id']},
|
|
{'$eq': ["$valide", "1"]},
|
|
{'$eq': ["$partner_owner_recid", '$$partner_owner_recid']},
|
|
|
|
{'$eq': ["$object_owner_id", str(diction['inscrit_id'])]},
|
|
{'$eq': ["$object_owner_collection", 'admission_session_inscrit_document']},
|
|
|
|
]
|
|
}
|
|
}
|
|
},
|
|
],
|
|
'as': 'collection_download_files'
|
|
}
|
|
},
|
|
|
|
])
|
|
|
|
print(" #### Get_List_Candidat_Document pipe_qry = ", pipe_qry)
|
|
RetObject = []
|
|
nb_document_accepted = 0
|
|
nb_document_rejected = 0
|
|
nb_document_send = 0
|
|
nb_document_no_status = 0
|
|
nb_document_not_send = 0
|
|
|
|
total_document_waited = 0
|
|
|
|
node_status = {}
|
|
|
|
RetObject = []
|
|
val_tmp = 0
|
|
for New_retVal in MYSY_GV.dbname['admission_setup_document'].aggregate(pipe_qry):
|
|
#print(" ## New_retVal = ",New_retVal
|
|
total_document_waited = total_document_waited + 1
|
|
|
|
if( "collection_download_files" in New_retVal.keys()):
|
|
|
|
for tmp_data in New_retVal['collection_download_files']:
|
|
|
|
|
|
if( "acceptance_status" not in tmp_data.keys()):
|
|
tmp_data['acceptance_status'] = ''
|
|
nb_document_no_status = nb_document_no_status + 1
|
|
nb_document_send = nb_document_send + 1
|
|
|
|
elif ( tmp_data['acceptance_status'] == "1"):
|
|
nb_document_accepted = nb_document_accepted + 1
|
|
nb_document_send = nb_document_send + 1
|
|
|
|
elif (tmp_data['acceptance_status'] == "-1"):
|
|
nb_document_rejected = nb_document_rejected + 1
|
|
nb_document_send = nb_document_send + 1
|
|
|
|
elif (tmp_data['acceptance_status'] == ""):
|
|
nb_document_no_status = nb_document_no_status + 1
|
|
nb_document_send = nb_document_send + 1
|
|
|
|
|
|
nb_document_not_send = total_document_waited - nb_document_send
|
|
|
|
pourcentage_accepted = ""
|
|
pourcentage_rejected = ""
|
|
pourcentage_send = ""
|
|
|
|
if( total_document_waited > 0 ):
|
|
pourcentage_accepted = round(float(nb_document_accepted) / float(total_document_waited), 2)
|
|
pourcentage_rejected = round(float(nb_document_rejected) / float(total_document_waited), 2)
|
|
pourcentage_send = round(float(nb_document_send) / float(total_document_waited), 2)
|
|
|
|
|
|
node_status['nb_document_accepted'] = str(nb_document_accepted)
|
|
node_status['nb_document_rejected'] = str(nb_document_rejected)
|
|
node_status['nb_document_send'] = str(nb_document_send)
|
|
node_status['nb_document_no_status'] = str(nb_document_no_status)
|
|
node_status['nb_document_not_send'] = str(nb_document_not_send)
|
|
node_status['total_document_waited'] = str(total_document_waited)
|
|
|
|
node_status['pourcentage_accepted'] = str(pourcentage_accepted)
|
|
node_status['pourcentage_rejected'] = str(pourcentage_rejected)
|
|
node_status['pourcentage_send'] = str(pourcentage_send)
|
|
|
|
|
|
RetObject.append(mycommon.JSONEncoder().encode(node_status))
|
|
|
|
return True, RetObject
|
|
|
|
|
|
except Exception as e:
|
|
exc_type, exc_obj, exc_tb = sys.exc_info()
|
|
print(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
|
|
return False, "Impossible de recuperer la liste des documents du candidat "
|
|
|
|
|
|
"""
|
|
Pour usage interne
|
|
"""
|
|
def Internal_Get_Pourcentage_Candidat_Document(diction=None):
|
|
try:
|
|
|
|
# Dictionnaire des champs utilisables
|
|
field_list = ['partner_recid', 'inscrit_id', ]
|
|
incom_keys = diction.keys()
|
|
|
|
'''
|
|
# 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.
|
|
'''
|
|
for val in incom_keys:
|
|
if str(val).lower() not in str(field_list).lower():
|
|
mycommon.myprint(
|
|
str(inspect.stack()[0][3]) + " Le champ '" + val + "' n'est pas accepté dans cette API")
|
|
return False, " Le champ '" + val + "' n'est pas accepté "
|
|
|
|
'''
|
|
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 = ['partner_recid', 'inscrit_id', ]
|
|
for val in field_list_obligatoire:
|
|
if str(val).lower() not in diction:
|
|
mycommon.myprint(
|
|
str(inspect.stack()[0][3]) + " La valeur '" + val + "' n'est pas presente dans la liste des arguments des champs")
|
|
return False, " La valeur '" + val + "' n'est pas presente dans la liste des arguments "
|
|
|
|
mydata = {}
|
|
mytoken = ""
|
|
|
|
|
|
|
|
qry_match = {"partner_owner_recid": str(diction['partner_recid']), 'valide': '1', 'locked': '0'}
|
|
|
|
pipe_qry = ([
|
|
{"$addFields": {"admission_setup_document_id": {"$toString": "$_id"}}},
|
|
{'$match': qry_match},
|
|
{'$sort': {'_id': -1}},
|
|
{'$lookup': {
|
|
'from': 'download_files',
|
|
"let": {'admission_setup_document_id': "$admission_setup_document_id", 'partner_owner_recid': '$partner_owner_recid'},
|
|
'pipeline': [
|
|
{'$match':
|
|
{'$expr':
|
|
{'$and':
|
|
[
|
|
{'$eq': ["$admission_setup_document_id", '$$admission_setup_document_id']},
|
|
{'$eq': ["$valide", "1"]},
|
|
{'$eq': ["$partner_owner_recid", '$$partner_owner_recid']},
|
|
|
|
{'$eq': ["$object_owner_id", str(diction['inscrit_id'])]},
|
|
{'$eq': ["$object_owner_collection", 'admission_session_inscrit_document']},
|
|
|
|
]
|
|
}
|
|
}
|
|
},
|
|
],
|
|
'as': 'collection_download_files'
|
|
}
|
|
},
|
|
|
|
])
|
|
|
|
|
|
RetObject = []
|
|
nb_document_accepted = 0
|
|
nb_document_rejected = 0
|
|
nb_document_send = 0
|
|
nb_document_no_status = 0
|
|
nb_document_not_send = 0
|
|
|
|
total_document_waited = 0
|
|
|
|
node_status = {}
|
|
|
|
RetObject = []
|
|
val_tmp = 0
|
|
for New_retVal in MYSY_GV.dbname['admission_setup_document'].aggregate(pipe_qry):
|
|
#print(" ## New_retVal = ",New_retVal
|
|
total_document_waited = total_document_waited + 1
|
|
|
|
if( "collection_download_files" in New_retVal.keys()):
|
|
|
|
for tmp_data in New_retVal['collection_download_files']:
|
|
|
|
|
|
if( "acceptance_status" not in tmp_data.keys()):
|
|
tmp_data['acceptance_status'] = ''
|
|
nb_document_no_status = nb_document_no_status + 1
|
|
nb_document_send = nb_document_send + 1
|
|
|
|
elif ( tmp_data['acceptance_status'] == "1"):
|
|
nb_document_accepted = nb_document_accepted + 1
|
|
nb_document_send = nb_document_send + 1
|
|
|
|
elif (tmp_data['acceptance_status'] == "-1"):
|
|
nb_document_rejected = nb_document_rejected + 1
|
|
nb_document_send = nb_document_send + 1
|
|
|
|
elif (tmp_data['acceptance_status'] == ""):
|
|
nb_document_no_status = nb_document_no_status + 1
|
|
nb_document_send = nb_document_send + 1
|
|
|
|
|
|
nb_document_not_send = total_document_waited - nb_document_send
|
|
|
|
pourcentage_accepted = ""
|
|
pourcentage_rejected = ""
|
|
pourcentage_send = ""
|
|
|
|
if( total_document_waited > 0 ):
|
|
pourcentage_accepted = round(float(nb_document_accepted) / float(total_document_waited), 2)
|
|
pourcentage_rejected = round(float(nb_document_rejected) / float(total_document_waited), 2)
|
|
pourcentage_send = round(float(nb_document_send) / float(total_document_waited), 2)
|
|
|
|
|
|
node_status['nb_document_accepted'] = str(nb_document_accepted)
|
|
node_status['nb_document_rejected'] = str(nb_document_rejected)
|
|
node_status['nb_document_send'] = str(nb_document_send)
|
|
node_status['nb_document_no_status'] = str(nb_document_no_status)
|
|
node_status['nb_document_not_send'] = str(nb_document_not_send)
|
|
node_status['total_document_waited'] = str(total_document_waited)
|
|
|
|
node_status['pourcentage_accepted'] = str(pourcentage_accepted)
|
|
node_status['pourcentage_rejected'] = str(pourcentage_rejected)
|
|
node_status['pourcentage_send'] = str(pourcentage_send)
|
|
|
|
|
|
|
|
|
|
return True, node_status
|
|
|
|
|
|
except Exception as e:
|
|
exc_type, exc_obj, exc_tb = sys.exc_info()
|
|
print(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
|
|
return False, "Impossible de recuperer la liste des documents du candidat "
|
|
|
|
|
|
"""
|
|
Cette fonction retourne une synthèse
|
|
des candidats à une session d'admission.
|
|
|
|
Cette synthèse est un outil d'aide à l'acceptation du candidat
|
|
"""
|
|
|
|
def Get_Synthese_Candidat_Process_Admission(diction):
|
|
try:
|
|
diction = mycommon.strip_dictionary(diction)
|
|
|
|
"""
|
|
Verification des input acceptés
|
|
"""
|
|
field_list = ['token', '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', 'session_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['session_id'] = str(diction['session_id'])
|
|
data_cle['valide'] = "1"
|
|
data_cle['locked'] = "0"
|
|
|
|
|
|
RetObject = []
|
|
val_tmp = 0
|
|
|
|
for retval in MYSY_GV.dbname['admission_session_inscrit'].find(data_cle).sort([("_id", pymongo.DESCENDING), ]):
|
|
user = retval
|
|
user['id'] = str(val_tmp)
|
|
val_tmp = val_tmp + 1
|
|
|
|
|
|
if ("date_naissance" not in retval.keys() or retval['date_naissance'] == ""):
|
|
retval['date_naissance'] = "01/01/1900"
|
|
|
|
if ("civilite" not in retval.keys() or retval['civilite'] == ""):
|
|
retval['civilite'] = "neutre"
|
|
|
|
|
|
age = relativedelta( date.today(), datetime.strptime(str(retval['date_naissance']), '%d/%m/%Y') )
|
|
retval['age'] = str(age.years)
|
|
|
|
session_etape_code = ""
|
|
if( "session_etape" in retval.keys() and retval['session_etape'] ):
|
|
admiss_session_etape_data = MYSY_GV.dbname['admission_setup_etape'].find_one(({'_id':ObjectId(str(retval['session_etape'])),
|
|
'valide':'1',
|
|
'partner_owner_recid':str(my_partner['recid'])}))
|
|
if( admiss_session_etape_data and "code" in admiss_session_etape_data.keys()):
|
|
session_etape_code = admiss_session_etape_data['code']
|
|
|
|
retval['session_etape_code'] = str(session_etape_code)
|
|
|
|
local_status, local_retval = Internal_Get_Pourcentage_Candidat_Document({'partner_recid':str(my_partner['recid']), 'inscrit_id':str(retval['_id'])})
|
|
if(local_status ):
|
|
#retval['document_satatus'] = local_retval
|
|
if( "pourcentage_accepted" in local_retval.keys()):
|
|
retval['document_pourcentage_accepted'] = str(local_retval['pourcentage_accepted'])
|
|
|
|
if ("pourcentage_send" in local_retval.keys()):
|
|
retval['taux_document_pourcentage_received'] = str(local_retval['pourcentage_send'])
|
|
|
|
else:
|
|
retval['document_pourcentage_accepted'] = "0"
|
|
retval['taux_document_pourcentage_received'] = "0"
|
|
|
|
if( retval['document_pourcentage_accepted'] != "1"):
|
|
retval['document_alert_message'] = "Tous les documents ne sont pas validés"
|
|
else:
|
|
retval['document_alert_message'] = ""
|
|
|
|
|
|
"""
|
|
Recuperer les notes et observation pour chacun des jury et examen de session pour ce candidat
|
|
"""
|
|
|
|
tab_jury_exam_note_obser = []
|
|
|
|
tab_entete_exam_jury = []
|
|
|
|
for local_jury_examen_data in MYSY_GV.dbname['jury'].find(
|
|
{'partner_owner_recid': str(my_partner['recid']), 'valide': '1', 'locked': '0',
|
|
'cible': 'admission', 'session_id': str(diction['session_id'])}, ):
|
|
|
|
for jury_apprenant_data in MYSY_GV.dbname['jury_apprenant'].find({'inscription_id':str(retval['_id']),
|
|
'jury_id':str(local_jury_examen_data['_id']),
|
|
'partner_owner_recid':str(my_partner['recid'])}):
|
|
|
|
retval[str(local_jury_examen_data['code'])+"_note"] = jury_apprenant_data['jury_note']
|
|
retval[str(local_jury_examen_data['code']) + "_obs."] = jury_apprenant_data['jury_observation']
|
|
|
|
tab_entete_exam_jury.append(str(local_jury_examen_data['code'])+"_note");
|
|
tab_entete_exam_jury.append(str(local_jury_examen_data['code']) + "_obs.")
|
|
|
|
|
|
|
|
#retval['tab_jury_exam_note_observation'] = tab_jury_exam_note_obser
|
|
|
|
user['tab_entete_exam_jury'] = tab_entete_exam_jury
|
|
|
|
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 inscrits"
|
|
|
|
|
|
"""
|
|
Cette fonction permet d'envoyer un email de relance manuelle
|
|
use case : relancer un candidat sur l'envoie d'un document
|
|
"""
|
|
def Candidat_Relance_Given_Document(diction=None):
|
|
try:
|
|
|
|
# Dictionnaire des champs utilisables
|
|
field_list = ['token', 'inscrit_id', 'admission_setup_document_id' ]
|
|
incom_keys = diction.keys()
|
|
|
|
'''
|
|
# 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.
|
|
'''
|
|
for val in incom_keys:
|
|
if str(val).lower() not in str(field_list).lower():
|
|
mycommon.myprint(
|
|
str(inspect.stack()[0][3]) + " Le champ '" + val + "' n'est pas accepté dans cette API")
|
|
return False, " Le champ '" + val + "' n'est pas accepté "
|
|
|
|
'''
|
|
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', 'inscrit_id', 'admission_setup_document_id' ]
|
|
for val in field_list_obligatoire:
|
|
if str(val).lower() not in diction:
|
|
mycommon.myprint(
|
|
str(inspect.stack()[0][3]) + " La valeur '" + val + "' n'est pas presente dans la liste des arguments des champs")
|
|
return False, " La valeur '" + val + "' n'est pas presente dans la liste des arguments "
|
|
|
|
mydata = {}
|
|
mytoken = ""
|
|
|
|
# recuperation des paramettre
|
|
if ("token" in diction.keys()):
|
|
if diction['token']:
|
|
mytoken = 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 la validé de l'inscrit
|
|
"""
|
|
is_existe_candidat = MYSY_GV.dbname['admission_session_inscrit'].count_documents(
|
|
{'_id': ObjectId(str(diction['inscrit_id'])),
|
|
'valide': '1',
|
|
'partner_owner_recid': str(my_partner['recid'])})
|
|
|
|
if (is_existe_candidat != 1):
|
|
mycommon.myprint(
|
|
str(inspect.stack()[0][3]) + " L'identifiant du candidat est invalide ")
|
|
return False, " L'identifiant du candidat est invalide "
|
|
|
|
candidat_data = MYSY_GV.dbname['admission_session_inscrit'].find_one(
|
|
{'_id': ObjectId(str(diction['inscrit_id'])),
|
|
'valide': '1',
|
|
'partner_owner_recid': str(my_partner['recid'])})
|
|
|
|
|
|
"""
|
|
verifier la validité du document a relancer
|
|
"""
|
|
is_valide_admission_setup_document_id = MYSY_GV.dbname['admission_setup_document'].count_documents({'_id':ObjectId(str(diction['admission_setup_document_id'])),
|
|
'valide':'1',
|
|
'locked':'0',
|
|
'partner_owner_recid':str(my_partner['recid'])})
|
|
|
|
if( is_valide_admission_setup_document_id != 1):
|
|
mycommon.myprint(
|
|
str(inspect.stack()[0][
|
|
3]) + " L'identifiant du document à relancer est invalide ")
|
|
return False, " L'identifiant du document à relancer est invalide "
|
|
|
|
admission_setup_document_data = MYSY_GV.dbname['admission_setup_document'].find_one(
|
|
{'_id': ObjectId(str(diction['admission_setup_document_id'])),
|
|
'valide': '1',
|
|
'locked': '0',
|
|
'partner_owner_recid': str(my_partner['recid'])}, {'_id':1, 'code':1, 'description':1, 'type':1})
|
|
|
|
|
|
"""
|
|
Recuperer le modèle de document
|
|
"""
|
|
local_diction = {}
|
|
local_diction['ref_interne'] = "ADMISSION_RELANCE_DOCUMENT"
|
|
local_diction['type_doc'] = "email"
|
|
local_diction['partner_owner_recid'] = str(my_partner['recid'])
|
|
|
|
courrier_data_status, courrier_data_retval = mycommon.Get_Courrier_Template_Include_Default_Data(local_diction)
|
|
if (courrier_data_status is False):
|
|
return courrier_data_status, courrier_data_retval
|
|
|
|
if ("contenu_doc" not in courrier_data_retval.keys() or str(courrier_data_retval['contenu_doc']) == ""):
|
|
mycommon.myprint(
|
|
str(inspect.stack()[0][
|
|
3]) + " Le modèle de courrier 'ADMISSION_RELANCE_DOCUMENT' n'est pas correctement configuré ")
|
|
return False, " Le modèle de courrier 'ADMISSION_RELANCE_DOCUMENT' n'est pas correctement configuré "
|
|
|
|
tab_candidat = []
|
|
tab_candidat.append(ObjectId(str(diction['inscrit_id'])))
|
|
|
|
convention_dictionnary_data = {}
|
|
new_diction = {}
|
|
new_diction['token'] = str(mytoken)
|
|
new_diction['list_stagiaire_id'] = []
|
|
new_diction['list_session_id'] = []
|
|
new_diction['list_class_id'] = []
|
|
new_diction['list_client_id'] = []
|
|
new_diction['list_candidat_admission_id'] = tab_candidat
|
|
|
|
local_status, local_retval = mycommon.Get_Dictionnary_data_For_Template(new_diction)
|
|
|
|
if (local_status is False):
|
|
return local_status, local_retval
|
|
|
|
local_retval['relance_document'] = admission_setup_document_data
|
|
|
|
|
|
body = {
|
|
"params": local_retval,
|
|
}
|
|
|
|
# Recuperation des donnes smtp
|
|
local_stpm_status, partner_SMTP_COUNT_smtpsrv, partner_own_smtp_value, partner_SMTP_COUNT_password, partner_SMTP_COUNT_user, partner_SMTP_COUNT_From_User, partner_SMTP_COUNT_port = mycommon.Get_Partner_SMTP_Param(
|
|
my_partner['recid'])
|
|
|
|
if (local_stpm_status is False):
|
|
return local_stpm_status, partner_SMTP_COUNT_smtpsrv
|
|
|
|
## Creation du mail au format email
|
|
corps_mail_Template = jinja2.Template(str(courrier_data_retval['contenu_doc']))
|
|
sourceHtml = corps_mail_Template.render(params=body["params"])
|
|
html_mime = MIMEText(sourceHtml, 'html')
|
|
|
|
# Traitement du sujet du mail
|
|
sujet_mail_Template = jinja2.Template(str(courrier_data_retval['sujet']))
|
|
sujetHtml = sujet_mail_Template.render(params=body["params"])
|
|
|
|
# Creation de l'email à enoyer
|
|
msg = MIMEMultipart("alternative")
|
|
|
|
msg.attach(html_mime)
|
|
msg['From'] = partner_SMTP_COUNT_From_User
|
|
msg['Bcc'] = 'contact@mysy-training.com'
|
|
msg['Subject'] = sujetHtml
|
|
# Attacher l'eventuelle pièces jointes
|
|
|
|
|
|
msg['to'] = str(candidat_data['email'])
|
|
|
|
smtpserver = smtplib.SMTP(partner_SMTP_COUNT_smtpsrv, partner_SMTP_COUNT_port)
|
|
|
|
smtpserver.ehlo()
|
|
smtpserver.starttls()
|
|
smtpserver.login(partner_SMTP_COUNT_user, partner_SMTP_COUNT_password)
|
|
|
|
val = smtpserver.send_message(msg)
|
|
smtpserver.close()
|
|
|
|
print(" Email envoyé " + str(val))
|
|
|
|
"""
|
|
Mettre à jour les relances
|
|
"""
|
|
|
|
node = {}
|
|
document_code = ""
|
|
document_desc = ""
|
|
if( "code" in admission_setup_document_data.keys()):
|
|
document_code = admission_setup_document_data['code']
|
|
|
|
if ("description" in admission_setup_document_data.keys()):
|
|
document_desc = admission_setup_document_data['description']
|
|
|
|
now = str(datetime.now().strftime("%d/%m/%Y %H:%M:%S"))
|
|
|
|
node['document_id'] = str(admission_setup_document_data['_id'])
|
|
node['document_code'] = document_code
|
|
node['document_desc'] = document_desc
|
|
node['document_date_relance'] = now
|
|
node['document_type_relance'] = "email"
|
|
node['document_relance_by'] = str(my_partner['_id'])
|
|
|
|
relance_by_nom = ""
|
|
if( "nom" in my_partner.keys()):
|
|
relance_by_nom = my_partner['nom']
|
|
|
|
relance_by_email = ""
|
|
if ("email" in my_partner.keys()):
|
|
relance_by_email = my_partner['email']
|
|
|
|
node['relance_by_nom'] = str(relance_by_nom)
|
|
node['relance_by_email'] = str(relance_by_email)
|
|
|
|
|
|
update = MYSY_GV.dbname['admission_session_inscrit'].update_one( {'_id': ObjectId(str(diction['inscrit_id'])),
|
|
'valide': '1',
|
|
'partner_owner_recid': str(my_partner['recid'])},
|
|
|
|
{
|
|
'$push': {
|
|
"relances_document": {'$each': [node]},
|
|
|
|
}
|
|
},
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
return True, "L'email de relance a été correctement envoyé "
|
|
|
|
|
|
|
|
except Exception as e:
|
|
exc_type, exc_obj, exc_tb = sys.exc_info()
|
|
print(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
|
|
return False, "Impossible d'envoyer l'email de relance "
|