15/01/2024 - 22h

master
cherif 2024-01-15 22:02:59 +01:00
parent 99603f883e
commit 580595e607
6 changed files with 1534 additions and 15 deletions

View File

@ -1,10 +1,10 @@
<?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="12/01/24 - 16h30">
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="15/01/2024 - 17h00">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" 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$/lms_chamilo/mysy_lms.py" beforeDir="false" afterPath="$PROJECT_DIR$/lms_chamilo/mysy_lms.py" 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$/partners.py" beforeDir="false" afterPath="$PROJECT_DIR$/partners.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/ressources_humaines.py" beforeDir="false" afterPath="$PROJECT_DIR$/ressources_humaines.py" afterDir="false" />
@ -77,13 +77,6 @@
<option name="presentableId" value="Default" />
<updated>1680804787304</updated>
</task>
<task id="LOCAL-00146" summary="13/11/2023 - 22h30">
<created>1699909122400</created>
<option name="number" value="00146" />
<option name="presentableId" value="LOCAL-00146" />
<option name="project" value="LOCAL" />
<updated>1699909122401</updated>
</task>
<task id="LOCAL-00147" summary="14/11/2023 - 12h">
<created>1699961714532</created>
<option name="number" value="00147" />
@ -420,7 +413,14 @@
<option name="project" value="LOCAL" />
<updated>1705071129313</updated>
</task>
<option name="localTasksCounter" value="195" />
<task id="LOCAL-00195" summary="15/01/2024 - 17h00">
<created>1705335099150</created>
<option name="number" value="00195" />
<option name="presentableId" value="LOCAL-00195" />
<option name="project" value="LOCAL" />
<updated>1705335099151</updated>
</task>
<option name="localTasksCounter" value="196" />
<servers />
</component>
<component name="Vcs.Log.Tabs.Properties">
@ -435,7 +435,6 @@
</option>
</component>
<component name="VcsManagerConfiguration">
<MESSAGE value="13/12/2023 - 23h30" />
<MESSAGE value="14/12/2023 - 08h30" />
<MESSAGE value="14/12/2023 - 16h16" />
<MESSAGE value="14/12/2023 - 21h" />
@ -460,6 +459,7 @@
<MESSAGE value="09/01/24 - 19h30" />
<MESSAGE value="11/01/24 - 21h30" />
<MESSAGE value="12/01/24 - 16h30" />
<option name="LAST_COMMIT_MESSAGE" value="12/01/24 - 16h30" />
<MESSAGE value="15/01/2024 - 17h00" />
<option name="LAST_COMMIT_MESSAGE" value="15/01/2024 - 17h00" />
</component>
</project>

File diff suppressed because it is too large Load Diff

View File

@ -3640,8 +3640,6 @@ def Delete_SessionFormation(diction):
return True, "La session 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) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))

41
main.py
View File

@ -4888,6 +4888,33 @@ def HR_Create_LMS_Trainer_Account():
return jsonify(status=status, message=retval)
"""
Cette API desactive le compte utilisateur d'un employé
"""
@app.route('/myclass/api/Lock_partner_account_From_Rh_Id/', methods=['POST','GET'])
@crossdomain(origin='*')
def Lock_partner_account_From_Rh_Id():
# On recupere le corps (payload) de la requete
payload = mycommon.strip_dictionary (request.form.to_dict())
print(" ### Lock_partner_account_From_Rh_Id payload = ",payload)
status, retval = ressources_humaines.Lock_partner_account_From_Rh_Id(payload)
return jsonify(status=status, message=retval)
"""
Cette API reactive le compte utilisateur d'un employé
"""
@app.route('/myclass/api/Unlock_partner_account_From_Rh_Id/', methods=['POST','GET'])
@crossdomain(origin='*')
def Unlock_partner_account_From_Rh_Id():
# On recupere le corps (payload) de la requete
payload = mycommon.strip_dictionary (request.form.to_dict())
print(" ### Unlock_partner_account_From_Rh_Id payload = ",payload)
status, retval = ressources_humaines.Unlock_partner_account_From_Rh_Id(payload)
return jsonify(status=status, message=retval)
"""
API qui desactive le compte LMS d'un employé, en parant du rh_id
"""
@ -7122,6 +7149,20 @@ def Export_Inscription_To_Excel_From_from_List_Id(token, tab_id):
return False
"""
Cette API verrouille le compte utilisateur d'un personne (partner ou employé)
"""
@app.route('/myclass/api/Lock_partner_account/', methods=['POST','GET'])
@crossdomain(origin='*')
def Lock_partner_account():
# On recupere le corps (payload) de la requete
payload = mycommon.strip_dictionary (request.form.to_dict())
print(" ### Lock_partner_account payload = ",payload)
print(request.files)
status, retval = pa.Lock_partner_account(payload)
return jsonify(status=status, message=retval)
if __name__ == '__main__':
print(" debut api")

View File

@ -1578,3 +1578,134 @@ def UpgradetoPro(diction):
"""
Cette fonction verrouille le compte d'un utilisateur
"""
def Lock_partner_account(diction):
try:
field_list = ['token', 'partner_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é, Creation partenaire annulée")
return False, "de récupérer la liste des stagiaires . Toutes les informations fournies ne sont pas valables"
"""
Verification de la liste des champs obligatoires
"""
field_list_obligatoire = ['token', 'partner_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 les informations necessaires n'ont pas été fournies"
# Recuperation du recid du partner
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 compte existe
is_partner_account_valide = MYSY_GV.dbname['partnair_account'].count_documents({'_id':ObjectId(str(diction['partner_id'])),
'recid':my_partner['recid']})
if( is_partner_account_valide != 1 ):
mycommon.myprint(
str(inspect.stack()[0][3]) + " L'identifiant du compte est invalide ")
return False, " L'identifiant du compte est invalide "
new_data = {}
new_data['date_update'] = str(datetime.now())
new_data['update_by'] = str(my_partner['_id'])
new_data['locked'] = "1"
new_data['active'] = "0"
update_data = MYSY_GV.dbname['partnair_account'].find_one_and_update({'_id':ObjectId(str(diction['partner_id'])),
'recid':my_partner['recid']},
{'$set':new_data})
if( update_data and '_id' in update_data.keys() ):
return True, "Le compte a été correctement verrouillé"
else:
return False, "Impossible de verrouiller le compte utilisateur (2)"
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 verrouiller le compte utilisateur"
"""
Cette fonction reactive le compte d'un utilisateur
"""
def UnLock_partner_account(diction):
try:
field_list = ['token', 'partner_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é, Creation partenaire annulée")
return False, "de récupérer la liste des stagiaires . Toutes les informations fournies ne sont pas valables"
"""
Verification de la liste des champs obligatoires
"""
field_list_obligatoire = ['token', 'partner_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 les informations necessaires n'ont pas été fournies"
# Recuperation du recid du partner
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 compte existe
is_partner_account_valide = MYSY_GV.dbname['partnair_account'].count_documents({'_id':ObjectId(str(diction['partner_id'])),
'recid':my_partner['recid']})
if( is_partner_account_valide != 1 ):
mycommon.myprint(
str(inspect.stack()[0][3]) + " L'identifiant du compte est invalide ")
return False, " L'identifiant du compte est invalide "
new_data = {}
new_data['date_update'] = str(datetime.now())
new_data['update_by'] = str(my_partner['_id'])
new_data['locked'] = "0"
new_data['active'] = "1"
update_data = MYSY_GV.dbname['partnair_account'].find_one_and_update({'_id':ObjectId(str(diction['partner_id'])),
'recid':my_partner['recid']},
{'$set':new_data})
if( update_data and '_id' in update_data.keys() ):
return True, "Le compte a été correctement réactivé"
else:
return False, "Impossible de réactiver le compte utilisateur (2)"
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 réactiver le compte utilisateur "

View File

@ -15,6 +15,8 @@ import json
from bson import ObjectId
import re
from datetime import datetime
import partners
import prj_common as mycommon
import secrets
import inspect
@ -1851,7 +1853,7 @@ def Get_Given_Ressource_Humaine(diction):
account_data = MYSY_GV.dbname['partnair_account'].find_one({'_id':ObjectId(str(retval['account_partner_id'])),
'recid':str(my_partner['recid'])
}, {'lms_virtualhost_url':1, 'mysy_lms_user_id':1,
'lms_username':1, 'lms_account_disable':1})
'lms_username':1, 'lms_account_disable':1, 'locked':1})
lms_virtualhost_url = ""
if(account_data and "lms_virtualhost_url" in account_data.keys() ):
@ -1873,6 +1875,11 @@ def Get_Given_Ressource_Humaine(diction):
lms_account_disable = account_data['lms_account_disable']
user['lms_account_disable'] = lms_account_disable
locked = ""
if (account_data and "locked" in account_data.keys()):
locked = account_data['locked']
user['locked'] = locked
RetObject.append(mycommon.JSONEncoder().encode(user))
@ -4623,3 +4630,134 @@ def HR_Create_LMS_Trainer_Account(diction):
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 les acces LMS "
"""
Cette fonction verrouile / desactive le compte utilisateur
d'un employé
"""
def Lock_partner_account_From_Rh_Id(diction):
try:
field_list = ['token', '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é, Creation partenaire annulée")
return False, "de récupérer la liste des stagiaires . Toutes les informations fournies ne sont pas valables"
"""
Verification de la liste des champs obligatoires
"""
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, "Toutes les informations necessaires n'ont pas été fournies"
# Recuperation du recid du partner
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 compte existe
is_rh_valide = MYSY_GV.dbname['ressource_humaine'].count_documents(
{'_id': ObjectId(str(diction['rh_id'])),
'partner_recid': my_partner['recid']})
if (is_rh_valide != 1):
mycommon.myprint(
str(inspect.stack()[0][3]) + " L'identifiant du compte est invalide ")
return False, " L'identifiant du compte est invalide "
is_rh_valide_data = MYSY_GV.dbname['ressource_humaine'].find_one(
{'_id': ObjectId(str(diction['rh_id'])),
'partner_recid': my_partner['recid']})
if( "account_partner_id" not in is_rh_valide_data.keys() or is_rh_valide_data['account_partner_id'] == ""):
mycommon.myprint(
str(inspect.stack()[0][3]) + " Cet employé ne dispose pas d'un compte utilisateur ")
return False, " Cet employé ne dispose pas d'un compte utilisateur "
new_data = {}
new_data['token'] = str(diction['token'])
new_data['partner_id'] = str(is_rh_valide_data['account_partner_id'])
local_status, local_retval = partners.Lock_partner_account(new_data)
return local_status, local_retval
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 supprimer le compte utilisateur"
"""
Cette fonction Reactive le le compte utilisateur
d'un employé
"""
def Unlock_partner_account_From_Rh_Id(diction):
try:
field_list = ['token', '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é, Creation partenaire annulée")
return False, "de récupérer la liste des stagiaires . Toutes les informations fournies ne sont pas valables"
"""
Verification de la liste des champs obligatoires
"""
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, "Toutes les informations necessaires n'ont pas été fournies"
# Recuperation du recid du partner
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 compte existe
is_rh_valide = MYSY_GV.dbname['ressource_humaine'].count_documents(
{'_id': ObjectId(str(diction['rh_id'])),
'partner_recid': my_partner['recid']})
if (is_rh_valide != 1):
mycommon.myprint(
str(inspect.stack()[0][3]) + " L'identifiant du compte est invalide ")
return False, " L'identifiant du compte est invalide "
is_rh_valide_data = MYSY_GV.dbname['ressource_humaine'].find_one(
{'_id': ObjectId(str(diction['rh_id'])),
'partner_recid': my_partner['recid']})
if( "account_partner_id" not in is_rh_valide_data.keys() or is_rh_valide_data['account_partner_id'] == ""):
mycommon.myprint(
str(inspect.stack()[0][3]) + " Cet employé ne dispose pas d'un compte utilisateur ")
return False, " Cet employé ne dispose pas d'un compte utilisateur "
new_data = {}
new_data['token'] = str(diction['token'])
new_data['partner_id'] = str(is_rh_valide_data['account_partner_id'])
local_status, local_retval = partners.UnLock_partner_account(new_data)
return local_status, local_retval
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 réactiver le compte utilisateur"