26/08/23 - 20h
parent
26166f9533
commit
237f4ff026
|
@ -1,14 +1,11 @@
|
|||
<?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="24/08/23 - 12h">
|
||||
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="25/08/23 - 21h">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/GlobalVariable.py" beforeDir="false" afterPath="$PROJECT_DIR$/GlobalVariable.py" 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$/Session_Formation.py" beforeDir="false" afterPath="$PROJECT_DIR$/Session_Formation.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" />
|
||||
|
@ -72,13 +69,6 @@
|
|||
<option name="presentableId" value="Default" />
|
||||
<updated>1680804787304</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00034" summary="08/06/23 - 21h">
|
||||
<created>1686251029490</created>
|
||||
<option name="number" value="00034" />
|
||||
<option name="presentableId" value="LOCAL-00034" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1686251029490</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00035" summary="13/06/23 - 16h">
|
||||
<created>1686667154704</created>
|
||||
<option name="number" value="00035" />
|
||||
|
@ -415,7 +405,14 @@
|
|||
<option name="project" value="LOCAL" />
|
||||
<updated>1692874458640</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="83" />
|
||||
<task id="LOCAL-00083" summary="25/08/23 - 21h">
|
||||
<created>1692989579922</created>
|
||||
<option name="number" value="00083" />
|
||||
<option name="presentableId" value="LOCAL-00083" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1692989579923</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="84" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="Vcs.Log.Tabs.Properties">
|
||||
|
@ -430,7 +427,6 @@
|
|||
</option>
|
||||
</component>
|
||||
<component name="VcsManagerConfiguration">
|
||||
<MESSAGE value="03/08/23 - 19h" />
|
||||
<MESSAGE value="05/08/23 - 16h" />
|
||||
<MESSAGE value="06/08/23 - 23h" />
|
||||
<MESSAGE value="08/08/2023 - 16h" />
|
||||
|
@ -455,6 +451,7 @@
|
|||
<MESSAGE value="22/08/23 - 20h" />
|
||||
<MESSAGE value="23/08/23 - 20h" />
|
||||
<MESSAGE value="24/08/23 - 12h" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="24/08/23 - 12h" />
|
||||
<MESSAGE value="25/08/23 - 21h" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="25/08/23 - 21h" />
|
||||
</component>
|
||||
</project>
|
1765
Log/log_file.log
1765
Log/log_file.log
File diff suppressed because one or more lines are too long
49
main.py
49
main.py
|
@ -3832,6 +3832,55 @@ def Add_Ressource_Humaine_mass():
|
|||
return jsonify(status=localStatus, message=message)
|
||||
|
||||
|
||||
"""
|
||||
Recuperation de la liste des fonctions occupées par un employé
|
||||
"""
|
||||
@app.route('/myclass/api/Get_List_Ressource_Humaine_Affectation/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Get_List_Ressource_Humaine_Affectation():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Get_List_Ressource_Humaine_Affectation payload = ",payload)
|
||||
status, retval = ressources_humaines.Get_List_Ressource_Humaine_Affectation(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
"""
|
||||
API pour affecter un employé a un poste
|
||||
"""
|
||||
@app.route('/myclass/api/Add_Affectation_Ressource_Humaine_Poste/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Add_Affectation_Ressource_Humaine_Poste():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Add_Affectation_Ressource_Humaine_Poste payload = ",payload)
|
||||
status, retval = ressources_humaines.Add_Affectation_Ressource_Humaine_Poste(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
"""
|
||||
API pour mettre à jour une affectation
|
||||
"""
|
||||
@app.route('/myclass/api/Update_Affectation_Ressource_Humaine_Poste/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Update_Affectation_Ressource_Humaine_Poste():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Update_Affectation_Ressource_Humaine_Poste payload = ",payload)
|
||||
status, retval = ressources_humaines.Update_Affectation_Ressource_Humaine_Poste(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
"""
|
||||
API pour supprimer une affectation
|
||||
"""
|
||||
@app.route('/myclass/api/Delete_Affectation_Ressource_Humaine_Poste/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Delete_Affectation_Ressource_Humaine_Poste():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Delete_Affectation_Ressource_Humaine_Poste payload = ",payload)
|
||||
status, retval = ressources_humaines.Delete_Affectation_Ressource_Humaine_Poste(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1844,3 +1844,493 @@ def Controle_Add_Ressource_Humaine_mass(saved_file=None, Folder=None, diction=No
|
|||
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 controler le fichier des employes à importer en masse "
|
||||
|
||||
|
||||
""""
|
||||
Recuperer les affectations d'un employé
|
||||
"""
|
||||
def Get_List_Ressource_Humaine_Affectation(diction):
|
||||
try:
|
||||
field_list_obligatoire = [ 'token', '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, " Impossible d'imprimer la fiche detaillée"
|
||||
|
||||
my_token = ""
|
||||
if ("token" in diction.keys()):
|
||||
if diction['token']:
|
||||
my_token = diction['token']
|
||||
|
||||
internal_url = ""
|
||||
if ("internal_url" in diction.keys()):
|
||||
if diction['internal_url']:
|
||||
internal_url = diction['internal_url']
|
||||
|
||||
# Recuperation du recid du partenaire
|
||||
partner_recid = mycommon.get_parnter_recid_from_token(str(my_token))
|
||||
if partner_recid is False:
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - Impossible d'imprimer la fiche detaillée")
|
||||
return False, " Les informations d'identification sont invalides"
|
||||
|
||||
local_status, my_partner_data = mycommon.Check_Connexion_And_Return_Partner_Data(diction)
|
||||
if (local_status is not True):
|
||||
return local_status, my_partner_data
|
||||
|
||||
|
||||
|
||||
qry_affectation = {'partner_owner_recid':str(my_partner_data['recid']),
|
||||
'related_collection':'ressource_humaine', 'related_collection_recid':str(diction['rh_id']),
|
||||
'valide':'1', 'locked':'0'}
|
||||
|
||||
|
||||
print(" ### qry_affectation = ",qry_affectation)
|
||||
|
||||
RetObject = []
|
||||
val_tmp = 1
|
||||
|
||||
for retval in MYSY_GV.dbname['ressource_humaine_affectation'].find(qry_affectation):
|
||||
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 recuperer la liste des affectations de l'employé "
|
||||
|
||||
|
||||
"""
|
||||
Ajout d'une affectation d'une ressource humaine à un poste
|
||||
"""
|
||||
|
||||
def Add_Affectation_Ressource_Humaine_Poste(diction):
|
||||
try:
|
||||
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', "rh_id", "poste", "date_du", "date_au", "comment", 'related_target_collection', 'related_target_collection_id']
|
||||
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
if val not in field_list:
|
||||
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', 'rh_id', "poste", 'date_du' ]
|
||||
|
||||
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, " Toutes le information obligatoires n'ont pas été fournies"
|
||||
|
||||
token = ""
|
||||
if ("token" in diction.keys()):
|
||||
if diction['token']:
|
||||
token = diction['token']
|
||||
|
||||
|
||||
|
||||
# Recuperation du recid du partenaire
|
||||
partner_recid = mycommon.get_parnter_recid_from_token(str(token))
|
||||
if partner_recid is False:
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - Impossible de recuperer le partner_recid")
|
||||
return False, " Les informations d'identification sont invalides"
|
||||
|
||||
local_status, my_partner_data = mycommon.Check_Connexion_And_Return_Partner_Data(diction)
|
||||
if (local_status is not True):
|
||||
return local_status, my_partner_data
|
||||
|
||||
rh_id = ""
|
||||
if ("rh_id" in diction.keys()):
|
||||
if diction['rh_id']:
|
||||
rh_id = diction['rh_id']
|
||||
# Verifier que l'employé existe bien
|
||||
employee_existe_count = MYSY_GV.dbname['ressource_humaine'].count_documents({'_id':ObjectId(str(rh_id)), 'partner_recid':str(partner_recid),
|
||||
'valide':'1', 'locked':'0'})
|
||||
|
||||
if( employee_existe_count <= 0 ) :
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - Employé invalide ")
|
||||
return False, " Employé invalide "
|
||||
|
||||
if (employee_existe_count > 1):
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - Employé incohérent. il a plusieurs employés avec le meme id ")
|
||||
return False, " Employé incohérent. il a plusieurs employés avec le meme id "
|
||||
|
||||
|
||||
date_du = ""
|
||||
if ("date_du" in diction.keys()):
|
||||
if diction['date_du']:
|
||||
date_du = str(diction['date_du'])[0:10]
|
||||
|
||||
# la date_du etant obligatoire, donc normal de faire le controle apres le "IF"
|
||||
local_status = mycommon.CheckisDate(date_du)
|
||||
if (local_status is False):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " La date de debut d'affectation n'est pas au format 'j'j/mm/aaaa' ")
|
||||
return False, "La date de debut d'affectation n'est pas au format 'j'j/mm/aaaa'"
|
||||
|
||||
|
||||
date_au = ""
|
||||
if ("date_fin" in diction.keys()):
|
||||
if diction['date_au']:
|
||||
date_au = str(diction['date_fin'])[0:10]
|
||||
local_status = mycommon.CheckisDate(date_au)
|
||||
if (local_status is False):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " La date de fin d'affectation n'est pas au format 'j'j/mm/aaaa' ")
|
||||
return False, "La date de fin d'affectation n'est pas au format 'j'j/mm/aaaa'"
|
||||
|
||||
|
||||
comment = ""
|
||||
if ("comment" in diction.keys()):
|
||||
if diction['comment']:
|
||||
comment = diction['comment']
|
||||
if(len(str(comment)) > 500):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " Le champ 'comment' a plus de 500 caractères ")
|
||||
return False, "Le champ 'comment' a plus de 500 caractères "
|
||||
|
||||
poste = ""
|
||||
if ("poste" in diction.keys()):
|
||||
poste = diction['poste']
|
||||
if (len(str(poste)) > 255):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " Le champ 'poste' a plus de 255 caractères ")
|
||||
return False, "Le champ 'poste' a plus de 255 caractères "
|
||||
|
||||
|
||||
related_target_collection_id = ""
|
||||
related_target_collection = ""
|
||||
if ("related_target_collection_id" in diction.keys() and "related_target_collection" in diction.keys()):
|
||||
if( diction['related_target_collection_id'] and diction['related_target_collection']):
|
||||
related_target_collection_id = diction['related_target_collection_id']
|
||||
related_target_collection = diction['related_target_collection']
|
||||
else:
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " Les données related_target_collection_id et related_target_collection sont incohérentes")
|
||||
return False, "Les données related_target_collection_id et related_target_collection sont incohérentes "
|
||||
|
||||
|
||||
|
||||
|
||||
# Verifier qu'on pas une affectation avec le meme poste qui demarre à la meme date.
|
||||
if_affectation_exist_count_qry = {'related_collection':'ressource_humaine', 'related_collection_recid':str(diction['rh_id']),
|
||||
'partner_owner_recid':str(partner_recid),'valide':'1', 'poste':str(diction['poste']),
|
||||
'date_du':str(date_du)}
|
||||
|
||||
if_affectation_exist_count = MYSY_GV.dbname['ressource_humaine_affectation'].count_documents(if_affectation_exist_count_qry)
|
||||
if(if_affectation_exist_count > 0 ):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " Cet employé occupe déjà ce poste ")
|
||||
return False, "Cet employé occupe déjà ce poste "
|
||||
|
||||
|
||||
my_data = {}
|
||||
my_data['related_collection'] = 'ressource_humaine'
|
||||
my_data['related_collection_recid'] = str(diction['rh_id'])
|
||||
my_data['partner_owner_recid'] = str(partner_recid)
|
||||
my_data['poste'] = str(poste)
|
||||
my_data['related_target_collection_id'] = str(related_target_collection_id)
|
||||
my_data['related_target_collection'] = str(related_target_collection)
|
||||
my_data['comment'] = str(diction['comment'])
|
||||
|
||||
my_data['date_du'] = str(date_du)
|
||||
my_data['date_au'] = str(date_au)
|
||||
my_data['valdie'] = "1"
|
||||
my_data['locked'] = "0"
|
||||
my_data['date_update'] = str(datetime.now().strftime("%d/%m/%Y %H:%M:%S"))
|
||||
|
||||
|
||||
inserted_data = MYSY_GV.dbname['ressource_humaine_affectation'].insert_one(my_data)
|
||||
if( inserted_data is None):
|
||||
return False," Impossible d'affectuer l'employé au poste (2)"
|
||||
|
||||
|
||||
return True, "L'affectation de l'employé a été correctement faite."
|
||||
|
||||
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'affecter l'employé au poste "
|
||||
|
||||
|
||||
"""
|
||||
Mise à jour d'une affectation
|
||||
"""
|
||||
def Update_Affectation_Ressource_Humaine_Poste(diction):
|
||||
try:
|
||||
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', "rh_id", "poste", "date_du", "date_au", "comment", "_id", 'related_target_collection', 'related_target_collection_id']
|
||||
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
if val not in field_list:
|
||||
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', 'date_du', 'poste', "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, " Toutes le information obligatoires n'ont pas été fournies"
|
||||
|
||||
token = ""
|
||||
if ("token" in diction.keys()):
|
||||
if diction['token']:
|
||||
token = diction['token']
|
||||
|
||||
|
||||
|
||||
# Recuperation du recid du partenaire
|
||||
partner_recid = mycommon.get_parnter_recid_from_token(str(token))
|
||||
if partner_recid is False:
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - Impossible de recuperer le partner_recid")
|
||||
return False, " Les informations d'identification sont invalides"
|
||||
|
||||
local_status, my_partner_data = mycommon.Check_Connexion_And_Return_Partner_Data(diction)
|
||||
if (local_status is not True):
|
||||
return local_status, my_partner_data
|
||||
|
||||
update_data = {}
|
||||
|
||||
rh_id = ""
|
||||
if ("rh_id" in diction.keys()):
|
||||
if diction['rh_id']:
|
||||
rh_id = diction['rh_id']
|
||||
# Verifier que l'employé existe bien
|
||||
employee_existe_count = MYSY_GV.dbname['ressource_humaine'].count_documents({'_id':ObjectId(str(rh_id)), 'partner_recid':str(partner_recid),
|
||||
'valide':'1', 'locked':'0'})
|
||||
|
||||
if( employee_existe_count <= 0 ) :
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - Employé invalide ")
|
||||
return False, " Employé invalide "
|
||||
|
||||
if (employee_existe_count > 1):
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - Employé incohérent. il a plusieurs employés avec le meme id ")
|
||||
return False, " Employé incohérent. il a plusieurs employés avec le meme id "
|
||||
|
||||
|
||||
date_du = ""
|
||||
if ("date_du" in diction.keys()):
|
||||
if diction['date_du']:
|
||||
date_du = str(diction['date_du'])[0:10]
|
||||
|
||||
# la date_du etant obligatoire, donc normal de faire le controle apres le "IF"
|
||||
local_status = mycommon.CheckisDate(date_du)
|
||||
if (local_status is False):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " La date de debut d'affectation n'est pas au format 'j'j/mm/aaaa' ")
|
||||
return False, "La date de debut d'affectation n'est pas au format 'j'j/mm/aaaa'"
|
||||
update_data['date_du'] = date_du
|
||||
|
||||
|
||||
date_au = ""
|
||||
if ("date_fin" in diction.keys()):
|
||||
date_au = str(diction['date_fin'])[0:10]
|
||||
local_status = mycommon.CheckisDate(date_au)
|
||||
if (local_status is False):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " La date de fin d'affectation n'est pas au format 'j'j/mm/aaaa' ")
|
||||
return False, "La date de fin d'affectation n'est pas au format 'j'j/mm/aaaa'"
|
||||
|
||||
update_data['date_du'] = date_du
|
||||
|
||||
comment = ""
|
||||
if ("comment" in diction.keys()):
|
||||
comment = diction['comment']
|
||||
if(len(str(comment)) > 500):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " Le champ 'comment' a plus de 500 caractères ")
|
||||
return False, "Le champ 'comment' a plus de 500 caractères "
|
||||
update_data['date_du'] = date_du
|
||||
|
||||
|
||||
poste = ""
|
||||
if ("poste" in diction.keys()):
|
||||
poste = diction['poste']
|
||||
if (len(str(poste)) > 255):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " Le champ 'poste' a plus de 255 caractères ")
|
||||
return False, "Le champ 'poste' a plus de 255 caractères "
|
||||
update_data['poste'] = poste
|
||||
|
||||
|
||||
related_target_collection_id = ""
|
||||
related_target_collection = ""
|
||||
if ("related_target_collection_id" in diction.keys() and "related_target_collection" in diction.keys()):
|
||||
if (diction['related_target_collection_id'] and diction['related_target_collection']):
|
||||
related_target_collection_id = diction['related_target_collection_id']
|
||||
related_target_collection = diction['related_target_collection']
|
||||
else:
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " Les données related_target_collection_id et related_target_collection sont incohérentes")
|
||||
return False, "Les données related_target_collection_id et related_target_collection sont incohérentes "
|
||||
|
||||
update_data['related_target_collection_id'] = str(related_target_collection_id)
|
||||
update_data['related_target_collection'] = str(related_target_collection)
|
||||
|
||||
update_data['date_update'] = str(datetime.now().strftime("%d/%m/%Y %H:%M:%S"))
|
||||
|
||||
|
||||
# Verifier l'existance de l'affectation
|
||||
affectation_existe_count = MYSY_GV.dbname['ressource_humaine_affectation'].count_documents( {'_id': str(diction['_id']), 'valide': "1",
|
||||
"locked":"0", 'partner_owner_recid':str(partner_recid)})
|
||||
|
||||
if( affectation_existe_count != 1 ):
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - Impossible de mettre à jour cette affectation. Données incohérentes ")
|
||||
return False, " Impossible de mettre à jour cette affectation. Données incohérentes "
|
||||
|
||||
|
||||
inserted_data = MYSY_GV.dbname['ressource_humaine_affectation'].find_one_and_update(
|
||||
{'_id': str(diction['_id']), 'valide': "1", "locked":"0", 'partner_owner_recid':str(partner_recid)},
|
||||
{"$set": update_data},
|
||||
return_document=ReturnDocument.AFTER,
|
||||
upsert=False,
|
||||
)
|
||||
|
||||
if( inserted_data is None ):
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - Impossible de mettre à jour cette affectation (3)")
|
||||
return False, " Impossible de mettre à jour cette affectation (3) "
|
||||
|
||||
|
||||
|
||||
return True, "L'affectation de l'employé 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 cette affectation "
|
||||
|
||||
|
||||
"""
|
||||
Supprimer une affectation
|
||||
"""
|
||||
def Delete_Affectation_Ressource_Humaine_Poste(diction):
|
||||
try:
|
||||
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', "rh_id", "_id"]
|
||||
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
if val not in field_list:
|
||||
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', "rh_id", "_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, " Toutes le information obligatoires n'ont pas été fournies"
|
||||
|
||||
token = ""
|
||||
if ("token" in diction.keys()):
|
||||
if diction['token']:
|
||||
token = diction['token']
|
||||
|
||||
|
||||
|
||||
# Recuperation du recid du partenaire
|
||||
partner_recid = mycommon.get_parnter_recid_from_token(str(token))
|
||||
if partner_recid is False:
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - Impossible de recuperer le partner_recid")
|
||||
return False, " Les informations d'identification sont invalides"
|
||||
|
||||
local_status, my_partner_data = mycommon.Check_Connexion_And_Return_Partner_Data(diction)
|
||||
if (local_status is not True):
|
||||
return local_status, my_partner_data
|
||||
|
||||
update_data = {}
|
||||
|
||||
rh_id = ""
|
||||
if ("rh_id" in diction.keys()):
|
||||
if diction['rh_id']:
|
||||
rh_id = diction['rh_id']
|
||||
# Verifier que l'employé existe bien
|
||||
employee_existe_count = MYSY_GV.dbname['ressource_humaine'].count_documents({'_id':ObjectId(str(rh_id)), 'partner_recid':str(partner_recid),
|
||||
'valide':'1', 'locked':'0'})
|
||||
|
||||
if( employee_existe_count <= 0 ) :
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - Employé invalide ")
|
||||
return False, " Employé invalide "
|
||||
|
||||
if (employee_existe_count > 1):
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - Employé incohérent. il a plusieurs employés avec le meme id ")
|
||||
return False, " Employé incohérent. il a plusieurs employés avec le meme id "
|
||||
|
||||
|
||||
# Verifier l'existance de l'affectation
|
||||
affectation_existe_count = MYSY_GV.dbname['ressource_humaine_affectation'].count_documents( {'_id': str(diction['_id']), 'valide': "1",
|
||||
"locked":"0", 'partner_owner_recid':str(partner_recid)})
|
||||
|
||||
if( affectation_existe_count != 1 ):
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - Impossible de mettre à jour cette affectation. Données incohérentes ")
|
||||
return False, " Impossible de mettre à jour cette affectation. Données incohérentes "
|
||||
|
||||
|
||||
inserted_data = MYSY_GV.dbname['ressource_humaine_affectation'].delete_one( {'_id': str(diction['_id']), 'valide': "1", "locked":"0",
|
||||
'partner_owner_recid':str(partner_recid)}, )
|
||||
|
||||
if( inserted_data is None ):
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - Impossible de supprimer à jour cette affectation (3)")
|
||||
return False, " Impossible de supprimer cette affectation (3) "
|
||||
|
||||
|
||||
|
||||
return True, "L'affectation de l'employé 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 cette affectation "
|
||||
|
|
Loading…
Reference in New Issue