01/04/24 - 23h30

master
cherif 2024-04-01 23:25:51 +02:00
parent 918df47b52
commit 7da010b1ec
7 changed files with 4084 additions and 15 deletions

View File

@ -1,12 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="26/03/2024 - 21h30">
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="fff">
<change afterPath="$PROJECT_DIR$/competence.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Inscription_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/Inscription_mgt.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Log/log_file.log" beforeDir="false" afterPath="$PROJECT_DIR$/Log/log_file.log" afterDir="false" />
<change beforePath="$PROJECT_DIR$/emargement.py" beforeDir="false" afterPath="$PROJECT_DIR$/emargement.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/crm_opportunite.py" beforeDir="false" afterPath="$PROJECT_DIR$/crm_opportunite.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/prj_common.py" beforeDir="false" afterPath="$PROJECT_DIR$/prj_common.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/ressources_humaines.py" beforeDir="false" afterPath="$PROJECT_DIR$/ressources_humaines.py" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -76,13 +78,6 @@
<option name="presentableId" value="Default" />
<updated>1680804787304</updated>
</task>
<task id="LOCAL-00202" summary="rrr">
<created>1706219904725</created>
<option name="number" value="00202" />
<option name="presentableId" value="LOCAL-00202" />
<option name="project" value="LOCAL" />
<updated>1706219904725</updated>
</task>
<task id="LOCAL-00203" summary="rrrf">
<created>1706302326449</created>
<option name="number" value="00203" />
@ -419,7 +414,14 @@
<option name="project" value="LOCAL" />
<updated>1711484853705</updated>
</task>
<option name="localTasksCounter" value="251" />
<task id="LOCAL-00251" summary="fff">
<created>1711656774534</created>
<option name="number" value="00251" />
<option name="presentableId" value="LOCAL-00251" />
<option name="project" value="LOCAL" />
<updated>1711656774535</updated>
</task>
<option name="localTasksCounter" value="252" />
<servers />
</component>
<component name="Vcs.Log.Tabs.Properties">
@ -461,7 +463,6 @@
</option>
</component>
<component name="VcsManagerConfiguration">
<MESSAGE value="23/02/2024 - 22h30" />
<MESSAGE value="24/02/2024 - 22h30" />
<MESSAGE value="25/02/2024 - 22h30" />
<MESSAGE value="26/02/2024 - 11h30" />
@ -486,6 +487,7 @@
<MESSAGE value="20/03/2024 - 22h30dss" />
<MESSAGE value="25/03/2024 - 18h30" />
<MESSAGE value="26/03/2024 - 21h30" />
<option name="LAST_COMMIT_MESSAGE" value="26/03/2024 - 21h30" />
<MESSAGE value="fff" />
<option name="LAST_COMMIT_MESSAGE" value="fff" />
</component>
</project>

File diff suppressed because it is too large Load Diff

344
competence.py Normal file
View File

@ -0,0 +1,344 @@
"""
Ce document permet de gerer les compétence pour des employé.
Dans la configuration, le partenaire enregistrer la liste de compétences
ex : Programmation JAVA, Management, etc
Ensuite pour chaque employé le systeme ira checher la liste de compétence depuis cette liste stockée
dans la collection : "competence_liste".
Une compétence est defini par :
- description
- commentaire
- domaine
- metier
"""
import bson
import pymongo
from pymongo import MongoClient
import json
from bson import ObjectId
import re
from datetime import datetime
import prj_common as mycommon
import secrets
import inspect
import sys, os
import csv
import pandas as pd
from pymongo import ReturnDocument
import GlobalVariable as MYSY_GV
from math import isnan
import GlobalVariable as MYSY_GV
import ela_index_bdd_classes as eibdd
import email_mgt as email
import jinja2
from flask import send_file
from xhtml2pdf import pisa
from email.message import EmailMessage
from email.mime.text import MIMEText
from email import encoders
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.mime.base import MIMEBase
from email import encoders
"""
Fonction d'ajout d'une compétence
"""
def Add_Competence(diction):
try:
diction = mycommon.strip_dictionary(diction)
"""
Verification des input acceptés
"""
field_list = ['token', 'description', 'domaine', 'metier', 'commentaire', ]
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', 'description', ]
for val in field_list_obligatoire:
if val not in diction:
mycommon.myprint(
str(inspect.stack()[0][3]) + " - La valeur '" + val + "' n'est pas presente dans liste ")
return False, " Les informations fournies sont incorrectes"
"""
Verification de l'identité et autorisation de l'entité qui
appelle cette API
"""
token = ""
if ("token" in diction.keys()):
if diction['token']:
token = diction['token']
local_status, my_partner = mycommon.Check_Connexion_And_Return_Partner_Data(diction)
if (local_status is not True):
return local_status, my_partner
mydata = {}
mydata = diction
del mydata['token']
# Initialisation des champs non envoyés à vide
for val in field_list:
if val not in diction.keys():
mydata[str(val)] = ""
mydata['date_update'] = str(datetime.now())
mydata['update_by'] = str(my_partner['_id'])
mydata['partner_owner_recid'] = str(my_partner['recid'])
mydata['valide'] = "1"
mydata['locked'] = "0"
inserted_id = MYSY_GV.dbname['competence_liste'].insert_one(mydata).inserted_id
if (not inserted_id):
mycommon.myprint(" Impossible de créer la compétence (2) ")
return False, " Impossible de créer la compétence (2) "
return True, " La compétence 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 compétence "
"""
Fonction de mise à jour d'une competence
"""
def Update_Competence(diction):
try:
diction = mycommon.strip_dictionary(diction)
"""
Verification des input acceptés
"""
field_list = ['token', 'description', 'competence_id', 'domaine', 'metier', 'commentaire', ]
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', 'description', 'competence_id', ]
for val in field_list_obligatoire:
if val not in diction:
mycommon.myprint(
str(inspect.stack()[0][3]) + " - La valeur '" + val + "' n'est pas presente dans liste ")
return False, " Les informations fournies sont incorrectes"
"""
Verification de l'identité et autorisation de l'entité qui
appelle cette API
"""
token = ""
if ("token" in diction.keys()):
if diction['token']:
token = diction['token']
competence_id = ""
if ("competence_id" in diction.keys()):
if diction['competence_id']:
competence_id = diction['competence_id']
local_status, my_partner = mycommon.Check_Connexion_And_Return_Partner_Data(diction)
if (local_status is not True):
return local_status, my_partner
# Verifier que la compétence existe et est valide
is_valide_opport = MYSY_GV.dbname['competence_liste'].count_documents({'_id':ObjectId(str(competence_id)),
'valide':'1',
'locked':'0',
'partner_owner_recid':str(my_partner['recid'])})
if( is_valide_opport != 1):
mycommon.myprint(
str(inspect.stack()[0][3]) + " L'identifiant de la compétence est invalide ")
return False, " L'identifiant de la compétence est invalide "
mydata = {}
mydata = diction
del mydata['token']
del mydata['competence_id']
mydata['date_update'] = str(datetime.now())
mydata['update_by'] = str(my_partner['_id'])
result = MYSY_GV.dbname['competence_liste'].find_one_and_update(
{'_id':ObjectId(str(competence_id)),
'partner_owner_recid':str(my_partner['recid'])},
{"$set": mydata},
upsert=False,
return_document=ReturnDocument.AFTER
)
if ("_id" not in result.keys()):
mycommon.myprint(
" Impossible de mettre à jour la compétence (2) ")
return False, " Impossible de mettre à jour la compétence (2) "
return True, " La compétence 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 compétence "
"""
Recuperer la liste des compétences d'un partenaire, sans filtres
"""
def Get_Competence_no_filter(diction):
try:
diction = mycommon.strip_dictionary(diction)
"""
Verification des input acceptés
"""
field_list = ['token' ]
incom_keys = diction.keys()
for val in incom_keys:
if val not in field_list and val.startswith('my_') is False:
mycommon.myprint(str(
inspect.stack()[0][3]) + " Le champ '" + val + "' n'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 liste ")
return False, " Les informations fournies sont incorrectes"
"""
Verification de l'identité et autorisation de l'entité qui
appelle cette API
"""
token = ""
if ("token" in diction.keys()):
if diction['token']:
token = diction['token']
local_status, my_partner = mycommon.Check_Connexion_And_Return_Partner_Data(diction)
if (local_status is not True):
return local_status, my_partner
RetObject = []
val_tmp = 0
qry = {"partner_owner_recid":str(my_partner['recid']), 'valide':'1', 'locked':'0'}
for New_retVal in MYSY_GV.dbname['competence_liste'].find(qry).sort([("_id", pymongo.DESCENDING), ]):
user = New_retVal
user['id'] = str(val_tmp)
val_tmp = val_tmp + 1
RetObject.append(mycommon.JSONEncoder().encode(user))
return True, RetObject
except Exception as e:
exc_type, exc_obj, exc_tb = sys.exc_info()
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - Line : " + str(exc_tb.tb_lineno))
return False, " Impossible de récupérer la liste des compétences "
"""
Suppression d'une compétence
"""
def Delete_Given_Competence(diction):
try:
diction = mycommon.strip_dictionary(diction)
"""
Verification des input acceptés
"""
field_list = ['token', 'competence_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', 'competence_id', ]
for val in field_list_obligatoire:
if val not in diction:
mycommon.myprint(
str(inspect.stack()[0][3]) + " - La valeur '" + val + "' n'est pas presente dans liste ")
return False, " Les informations fournies sont incorrectes"
"""
Verification de l'identité et autorisation de l'entité qui
appelle cette API
"""
token = ""
if ("token" in diction.keys()):
if diction['token']:
token = diction['token']
local_status, my_partner = mycommon.Check_Connexion_And_Return_Partner_Data(diction)
if (local_status is not True):
return local_status, my_partner
# Verifier l'existance de l'opportunité
is_opportunit_valide = MYSY_GV.dbname['competence_liste'].count_documents({'_id':ObjectId(str(diction['competence_id'])),
'partner_owner_recid':str(my_partner['recid'])})
if (is_opportunit_valide != 1):
mycommon.myprint(
str(inspect.stack()[0][3]) + " L'identifiant de la compétence est invalide ")
return False, " L'identifiant de la compétence est invalide "
qry = {'_id':ObjectId(str(diction['competence_id'])), 'partner_owner_recid':str(my_partner['recid'])}
ret_del_competence = MYSY_GV.dbname['competence_liste'].delete_many(qry)
return True, "La compétence 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 compétence "

View File

@ -905,7 +905,7 @@ def Delete_Given_CRM_Opportunite(diction):
except Exception as e:
exc_type, exc_obj, exc_tb = sys.exc_info()
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - Line : " + str(exc_tb.tb_lineno))
return False, " Impossible de récupérer les données de opportunité "
return False, " Impossible de supprimer opportunité "

95
main.py
View File

@ -78,7 +78,7 @@ import crm_opportunite as crm_opportunite
import site_formation as site_formation
import paiement_condition as paiement_condition
import E_Sign_Document as E_Sign_Document
import competence as competence
app = Flask(__name__)
@ -5106,6 +5106,32 @@ def Unlock_partner_account_From_Rh_Id():
return jsonify(status=status, message=retval)
"""
Cette API ajoute ou met à jour une compétence d'un employés
"""
@app.route('/myclass/api/Add_Update_RH_Competence/', methods=['POST','GET'])
@crossdomain(origin='*')
def Add_Update_RH_Competence():
# On recupere le corps (payload) de la requete
payload = mycommon.strip_dictionary (request.form.to_dict())
print(" ### Add_Update_RH_Competence payload = ",payload)
status, retval = ressources_humaines.Add_Update_RH_Competence(payload)
return jsonify(status=status, message=retval)
"""
Cette API qui supprime une compétence d'un employés
"""
@app.route('/myclass/api/Delete_RH_Competence/', methods=['POST','GET'])
@crossdomain(origin='*')
def Delete_RH_Competence():
# On recupere le corps (payload) de la requete
payload = mycommon.strip_dictionary (request.form.to_dict())
print(" ### Delete_RH_Competence payload = ",payload)
status, retval = ressources_humaines.Delete_RH_Competence(payload)
return jsonify(status=status, message=retval)
"""
API qui desactive le compte LMS d'un employé, en parant du rh_id
"""
@ -8082,6 +8108,73 @@ def Audit_Session_Action_Inscrit():
return jsonify(status=localStatus, message=message )
"""
API qui permet de recuperer la liste des niveaux pour les compétences
"""
@app.route('/myclass/api/Get_Competence_Level/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_Competence_Level():
# On recupere le corps (payload) de la requete
payload = mycommon.strip_dictionary (request.form.to_dict())
print(" ### Get_Competence_Level payload = ",payload)
status, retval = mycommon.Get_Competence_Level()
return jsonify(status=status, message=retval)
"""
API pour créer une compétence
"""
@app.route('/myclass/api/Add_Competence/', methods=['POST','GET'])
@crossdomain(origin='*')
def Add_Competence():
# On recupere le corps (payload) de la requete
payload = mycommon.strip_dictionary (request.form.to_dict())
print(" ### Add_Competence payload = ",payload)
status, retval = competence.Add_Competence(payload)
return jsonify(status=status, message=retval)
"""
API pour mettre à jour une compétence
"""
@app.route('/myclass/api/Update_Competence/', methods=['POST','GET'])
@crossdomain(origin='*')
def Update_Competence():
# On recupere le corps (payload) de la requete
payload = mycommon.strip_dictionary (request.form.to_dict())
print(" ### Update_Competence payload = ",payload)
status, retval = competence.Update_Competence(payload)
return jsonify(status=status, message=retval)
"""
API pour recuperer la liste des compétences d'un partenaire
"""
@app.route('/myclass/api/Get_Competence_no_filter/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_Competence_no_filter():
# On recupere le corps (payload) de la requete
payload = mycommon.strip_dictionary (request.form.to_dict())
print(" ### Get_Competence_no_filter payload = ",payload)
status, retval = competence.Get_Competence_no_filter(payload)
return jsonify(status=status, message=retval)
"""
API pour supprimer une compétence
"""
@app.route('/myclass/api/Delete_Given_Competence/', methods=['POST','GET'])
@crossdomain(origin='*')
def Delete_Given_Competence():
# On recupere le corps (payload) de la requete
payload = mycommon.strip_dictionary (request.form.to_dict())
print(" ### Delete_Given_Competence payload = ",payload)
status, retval = competence.Delete_Given_Competence(payload)
return jsonify(status=status, message=retval)
if __name__ == '__main__':
print(" debut api")
context = SSL.Context(SSL.SSLv23_METHOD)

View File

@ -5263,3 +5263,31 @@ def Is_Partnair_Has_Digital_Signature(diction):
myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - Line : " + str(exc_tb.tb_lineno))
return False, " Impossible de verifier si le partenaire dispose de la signature digitale "
"""
Recuperation des differents niveaux de compétence
"""
def Get_Competence_Level():
try:
RetObject = []
val_tmp = 1
for val in MYSY_GV.dbname['base_competence_level'].find({'partner_owner_recid':"default", 'valide':'1', 'locked':'0'}):
user = val
user['id'] = str(val_tmp)
val_tmp = val_tmp + 1
RetObject.append(JSONEncoder().encode(user))
return True,RetObject
except Exception as e:
exc_type, exc_obj, exc_tb = sys.exc_info()
myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
return False, " Impossible de récupérer les niveaux de compétence"

View File

@ -1928,6 +1928,29 @@ def Get_Given_Ressource_Humaine(diction):
user['locked'] = locked
"""
Si on a des compétences associés, alors on va aller cherche la note dans la collection 'base_competence_type'.
/!\ on a volontaire fait ainsi pour garder la gestion de la note coté serveur.
en cas de changement de note (donc d'echelle de note), pas de besoin de faire de la data migration
"""
if( "list_competence" in user.keys() ):
for local_val in user['list_competence'] :
local_niveau = str(local_val['niveau']).lower()
niveau_data = MYSY_GV.dbname['base_competence_level'].find_one({'code':str(local_niveau),
'partner_owner_recid':'default',
'valide':'1',
'locked':'0'})
local_data_note = "0"
if( niveau_data and "note" in niveau_data.keys() ):
local_data_note = niveau_data['note']
local_val['note'] = local_data_note
RetObject.append(mycommon.JSONEncoder().encode(user))
@ -4894,3 +4917,207 @@ def Unlock_partner_account_From_Rh_Id(diction):
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
return False, "Impossible de réactiver le compte utilisateur"
"""
Fonction qui permet d'ajouter ou mettre à jour une competence d'un employe
"""
def Add_Update_RH_Competence(diction):
try:
diction = mycommon.strip_dictionary(diction)
"""
Verification des input acceptés
"""
field_list = ['token', 'competence_id', 'competence', 'niveau', 'rh_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', 'competence_id', 'competence', 'niveau', 'rh_id']
for val in field_list_obligatoire:
if val not in diction:
mycommon.myprint(
str(inspect.stack()[0][3]) + " - La valeur '" + val + "' n'est pas presente dans liste ")
return False, " Les informations fournies sont incorrectes"
"""
Verification de l'identité et autorisation de l'entité qui
appelle cette API
"""
token = ""
if ("token" in diction.keys()):
if diction['token']:
token = diction['token']
local_status, my_partner = mycommon.Check_Connexion_And_Return_Partner_Data(diction)
if (local_status is not True):
return local_status, my_partner
if (len(str(diction['competence_id']).strip()) > 0):
# Verifier si l'id de la compétence existe
is_competence_exist = MYSY_GV.dbname['ressource_humaine'].count_documents({'_id': ObjectId(str(diction['rh_id'])),
'partner_recid': str(
my_partner['recid']),
'valide': '1',
'locked': '0',
'list_competence._id' : str(diction['competence_id'])})
if (is_competence_exist <= 0):
mycommon.myprint(
str(inspect.stack()[0][3]) + " L'identifiant de la compétence est invalide ")
return False, " L'identifiant de la compétence est invalide "
# L'eventement existe est valide, on autorise la mise à jour
update = MYSY_GV.dbname['ressource_humaine'].update_one({'_id': ObjectId(str(diction['rh_id'])),
'partner_recid': str(
my_partner['recid']),
'valide': '1',
'locked': '0',
'list_competence._id' : str(diction['competence_id'])},
{'$set':
{
'list_competence.$[xxx].competence': str(diction['competence']),
'list_competence.$[xxx].niveau': str(diction['niveau']),
'list_competence.$[xxx].date_update': str(datetime.now()),
'list_competence.$[xxx].update_by': str(my_partner['_id']),
}
},
upsert=False,
array_filters=[
{"xxx._id": str(diction['competence_id'])}
]
)
return True, " La compétence a été mise à jour"
else:
# Il s'agit de la creation d'une competence
new_data = {}
new_data['date_update'] = str(datetime.now())
new_data['valide'] = "1"
new_data['update_by'] = str(my_partner['_id'])
new_data['locked'] = "0"
new_data['competence'] = str(diction['competence'])
new_data['niveau'] = str(diction['niveau'])
new_competence_id = secrets.token_hex(5)
new_data['_id'] = new_competence_id
update = MYSY_GV.dbname['ressource_humaine'].update_one({'_id': ObjectId(str(diction['rh_id'])),
'partner_recid': str(
my_partner['recid']),
'valide': '1',
'locked': '0',
},
{
'$push': {
"list_competence": {
'$each': [new_data]
}
}
},
)
return True, " La compétence a été 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 d'ajouter ou mettre à jour la compétence "
"""
Cette fonction supprimer une compétence d'un employé
"""
def Delete_RH_Competence(diction):
try:
diction = mycommon.strip_dictionary(diction)
"""
Verification des input acceptés
"""
field_list = ['token', 'competence_id', 'rh_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', 'competence_id', 'rh_id']
for val in field_list_obligatoire:
if val not in diction:
mycommon.myprint(
str(inspect.stack()[0][3]) + " - La valeur '" + val + "' n'est pas presente dans liste ")
return False, " Les informations fournies sont incorrectes"
"""
Verification de l'identité et autorisation de l'entité qui
appelle cette API
"""
token = ""
if ("token" in diction.keys()):
if diction['token']:
token = diction['token']
local_status, my_partner = mycommon.Check_Connexion_And_Return_Partner_Data(diction)
if (local_status is not True):
return local_status, my_partner
if (len(str(diction['competence_id']).strip()) > 0):
# Verifier si l'id de la compétence existe
is_competence_exist = MYSY_GV.dbname['ressource_humaine'].count_documents({'_id': ObjectId(str(diction['rh_id'])),
'partner_recid': str(
my_partner['recid']),
'valide': '1',
'locked': '0',
'list_competence._id' : str(diction['competence_id'])})
if (is_competence_exist <= 0):
mycommon.myprint(
str(inspect.stack()[0][3]) + " L'identifiant de la compétence est invalide ")
return False, " L'identifiant de la compétence est invalide "
delete = MYSY_GV.dbname['ressource_humaine'].update_one({'_id': ObjectId(str(diction['rh_id'])),
'partner_recid': str(
my_partner['recid']),
'valide': '1',
'locked': '0',
'list_competence._id': str(diction['competence_id'])},
{'$pull': {'list_competence': {"_id": str(diction['competence_id'])}}}
)
return True, " La compétence a été 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 compétence "