17/02/2024 - 11h
parent
990ce2c6ce
commit
79f298a523
|
@ -1,8 +1,17 @@
|
|||
<?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="sdsdqs">
|
||||
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="13/02/2024 - 11h">
|
||||
<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$/Session_Formation.py" beforeDir="false" afterPath="$PROJECT_DIR$/Session_Formation.py" 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$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/partner_client.py" beforeDir="false" afterPath="$PROJECT_DIR$/partner_client.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" />
|
||||
<change beforePath="$PROJECT_DIR$/ressources_materiels.py" beforeDir="false" afterPath="$PROJECT_DIR$/ressources_materiels.py" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
|
@ -72,13 +81,6 @@
|
|||
<option name="presentableId" value="Default" />
|
||||
<updated>1680804787304</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00172" summary="14/12/2023 - 21h">
|
||||
<created>1702583972424</created>
|
||||
<option name="number" value="00172" />
|
||||
<option name="presentableId" value="LOCAL-00172" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1702583972425</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00173" summary="14/12/2023 - 22h">
|
||||
<created>1702588091723</created>
|
||||
<option name="number" value="00173" />
|
||||
|
@ -415,7 +417,14 @@
|
|||
<option name="project" value="LOCAL" />
|
||||
<updated>1707775980254</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="221" />
|
||||
<task id="LOCAL-00221" summary="13/02/2024 - 11h">
|
||||
<created>1707817778812</created>
|
||||
<option name="number" value="00221" />
|
||||
<option name="presentableId" value="LOCAL-00221" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1707817778813</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="222" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="Vcs.Log.Tabs.Properties">
|
||||
|
@ -430,7 +439,6 @@
|
|||
</option>
|
||||
</component>
|
||||
<component name="VcsManagerConfiguration">
|
||||
<MESSAGE value="15/01/2024 - 17h00" />
|
||||
<MESSAGE value="15/01/2024 - 22h" />
|
||||
<MESSAGE value="16/01/2024 - 19h" />
|
||||
<MESSAGE value="19/01/2024 - 16h" />
|
||||
|
@ -455,6 +463,7 @@
|
|||
<MESSAGE value="09/02/24 - 22hqsdsq" />
|
||||
<MESSAGE value="11/02/2024 - 22h" />
|
||||
<MESSAGE value="sdsdqs" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="sdsdqs" />
|
||||
<MESSAGE value="13/02/2024 - 11h" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="13/02/2024 - 11h" />
|
||||
</component>
|
||||
</project>
|
|
@ -2402,18 +2402,19 @@ def AddStagiairetoClass_mass(file=None, Folder=None, diction=None):
|
|||
client_rattachement_email = ""
|
||||
if ("client_rattachement_email" in df.keys()):
|
||||
if (str(df['client_rattachement_email'].values[n]) and str(df['client_rattachement_email'].values[n]) != "nan" ):
|
||||
client_rattachement_email = str(df['client_rattachement_email'].values[n])
|
||||
client_rattachement_email = str(df['client_rattachement_email'].values[n]).strip()
|
||||
|
||||
|
||||
client_rattachement_nom = ""
|
||||
if ("client_rattachement_nom" in df.keys() and str(df['client_rattachement_nom'].values[n]) != "nan"):
|
||||
if (str(df['client_rattachement_nom'].values[n])):
|
||||
client_rattachement_nom = str(df['client_rattachement_nom'].values[n])
|
||||
client_rattachement_nom = str(df['client_rattachement_nom'].values[n]).strip()
|
||||
|
||||
if( client_rattachement_email and client_rattachement_nom ):
|
||||
local_client_retval_qry = {'email':str(client_rattachement_email), 'nom':str(client_rattachement_nom), 'valide':'1',
|
||||
'locked':'0', 'partner_recid' :str(partner_recid)}
|
||||
|
||||
print(" ### local_client_retval_qry = ", local_client_retval_qry)
|
||||
local_client_retval_count = MYSY_GV.dbname['partner_client'].count_documents(local_client_retval_qry)
|
||||
|
||||
if( local_client_retval_count > 1 ):
|
||||
|
@ -2430,7 +2431,7 @@ def AddStagiairetoClass_mass(file=None, Folder=None, diction=None):
|
|||
|
||||
local_client_retval_data = MYSY_GV.dbname['partner_client'].find_one(local_client_retval_qry)
|
||||
if( local_client_retval_data is not None ):
|
||||
mydata['client_rattachement_id'] = local_client_retval_data['_id']
|
||||
mydata['client_rattachement_id'] = str(local_client_retval_data['_id'])
|
||||
|
||||
status = str(df['status'].values[n]).strip()
|
||||
status = str(mycommon.tryInt(status))
|
||||
|
@ -2763,6 +2764,7 @@ def Controle_AddStagiairetoClass_mass(saved_file=None, Folder=None, diction=None
|
|||
'nom': str(client_rattachement_nom), 'valide': '1',
|
||||
'locked': '0', 'partner_recid': str(partner_recid)}
|
||||
|
||||
print(" ### local_client_retval_qry = ", local_client_retval_qry)
|
||||
local_client_retval_count = MYSY_GV.dbname['partner_client'].count_documents(
|
||||
local_client_retval_qry)
|
||||
|
||||
|
@ -2785,7 +2787,7 @@ def Controle_AddStagiairetoClass_mass(saved_file=None, Folder=None, diction=None
|
|||
|
||||
local_client_retval_data = MYSY_GV.dbname['partner_client'].find_one(local_client_retval_qry)
|
||||
if (local_client_retval_data is not None):
|
||||
mydata['client_rattachement_id'] = local_client_retval_data['_id']
|
||||
mydata['client_rattachement_id'] = str(local_client_retval_data['_id'])
|
||||
|
||||
|
||||
status = str(df['status'].values[n]).strip()
|
||||
|
@ -3119,17 +3121,17 @@ def AddStagiairetoClass_mass_for_many_session(file=None, Folder=None, diction=No
|
|||
client_rattachement_email = ""
|
||||
if ("client_rattachement_email" in df.keys()):
|
||||
if (str(df['client_rattachement_email'].values[n]) and str(df['client_rattachement_email'].values[n]) != "nan"):
|
||||
client_rattachement_email = str(df['client_rattachement_email'].values[n])
|
||||
client_rattachement_email = str(df['client_rattachement_email'].values[n]).strip()
|
||||
|
||||
|
||||
client_rattachement_nom = ""
|
||||
if ("client_rattachement_nom" in df.keys()):
|
||||
if (str(df['client_rattachement_nom'].values[n]) and str(df['client_rattachement_nom'].values[n]) != "nan" ):
|
||||
client_rattachement_nom = str(df['client_rattachement_nom'].values[n])
|
||||
client_rattachement_nom = str(df['client_rattachement_nom'].values[n]).strip()
|
||||
if (client_rattachement_email and client_rattachement_nom):
|
||||
local_client_retval_qry = {'email':str(client_rattachement_email), 'nom':str(client_rattachement_nom),
|
||||
'valide':'1', 'locked':'0', 'partner_recid' :str(partner_recid)}
|
||||
|
||||
print(" ### local_client_retval_qry = ", local_client_retval_qry)
|
||||
local_client_retval_count = MYSY_GV.dbname['partner_client'].count_documents(local_client_retval_qry)
|
||||
|
||||
if( local_client_retval_count > 1 ):
|
||||
|
@ -3146,7 +3148,7 @@ def AddStagiairetoClass_mass_for_many_session(file=None, Folder=None, diction=No
|
|||
|
||||
local_client_retval_data = MYSY_GV.dbname['partner_client'].find_one(local_client_retval_qry)
|
||||
if( local_client_retval_data is not None ):
|
||||
mydata['client_rattachement_id'] = local_client_retval_data['_id']
|
||||
mydata['client_rattachement_id'] = str(local_client_retval_data['_id'])
|
||||
|
||||
|
||||
mydata['status'] = str(df['status'].values[n]).strip()
|
||||
|
@ -3418,17 +3420,18 @@ def Controle_AddStagiairetoClass_mass_for_many_session(saved_file=None, Folder=N
|
|||
client_rattachement_email = ""
|
||||
if ("client_rattachement_email" in df.keys()):
|
||||
if (str(df['client_rattachement_email'].values[n]) and str(df['client_rattachement_email'].values[n]) != "nan"):
|
||||
client_rattachement_email = str(df['client_rattachement_email'].values[n])
|
||||
client_rattachement_email = str(df['client_rattachement_email'].values[n]).strip()
|
||||
|
||||
|
||||
client_rattachement_nom = ""
|
||||
if ("client_rattachement_nom" in df.keys()):
|
||||
if (str(df['client_rattachement_nom'].values[n]) and str(df['client_rattachement_nom'].values[n]) != "nan" ):
|
||||
client_rattachement_nom = str(df['client_rattachement_nom'].values[n])
|
||||
client_rattachement_nom = str(df['client_rattachement_nom'].values[n]).strip()
|
||||
if (client_rattachement_email and client_rattachement_nom):
|
||||
local_client_retval_qry = {'email':str(client_rattachement_email), 'nom':str(client_rattachement_nom),
|
||||
'valide':'1', 'locked':'0', 'partner_recid' :str(partner_recid)}
|
||||
|
||||
print(" ### local_client_retval_qry = ", local_client_retval_qry)
|
||||
local_client_retval_count = MYSY_GV.dbname['partner_client'].count_documents(local_client_retval_qry)
|
||||
|
||||
if( local_client_retval_count > 1 ):
|
||||
|
@ -3445,7 +3448,7 @@ def Controle_AddStagiairetoClass_mass_for_many_session(saved_file=None, Folder=N
|
|||
|
||||
local_client_retval_data = MYSY_GV.dbname['partner_client'].find_one(local_client_retval_qry)
|
||||
if( local_client_retval_data is not None ):
|
||||
mydata['client_rattachement_id'] = local_client_retval_data['_id']
|
||||
mydata['client_rattachement_id'] = str(local_client_retval_data['_id'])
|
||||
|
||||
|
||||
mydata['status'] = str(df['status'].values[n]).strip()
|
||||
|
|
5314
Log/log_file.log
5314
Log/log_file.log
File diff suppressed because one or more lines are too long
|
@ -4712,8 +4712,6 @@ def Prepare_and_Send_Convention_From_Session_By_PDF(diction):
|
|||
return False, " Le champ obligatoire '" + val + "' est vide "
|
||||
|
||||
|
||||
|
||||
|
||||
my_token = ""
|
||||
if ("token" in diction.keys()):
|
||||
if diction['token']:
|
||||
|
@ -5317,9 +5315,20 @@ def Create_Convention_By_Client_PDF(diction):
|
|||
'client_rattachement_id': str(
|
||||
diction['client_id'])})
|
||||
|
||||
qry = {'session_id': str(diction['session_id']),
|
||||
'status': '1',
|
||||
'partner_owner_recid': str(my_partner['recid']),
|
||||
'client_rattachement_id': str(
|
||||
diction['client_id'])}
|
||||
|
||||
for inscription in inscription_data:
|
||||
|
||||
local_status, local_retval = module_editique.Editic_Log_History_Action_From_courrier_template_type_document_ref_interne(my_partner, "CONVENTION_STAGIAIRE_ENTREPRISE", str(diction['session_id']), 'inscription', str(inscription['_id']),
|
||||
str(template_courrier_data['_id']))
|
||||
if( local_status is False ):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " WARNING : impossible d'exécuter la fonction Editic_Log_History_Action_From_courrier_template_type_document_ref_interne local_retval = ", local_retval)
|
||||
|
||||
return True, outputFilename
|
||||
|
||||
|
|
|
@ -529,7 +529,7 @@ def Update_Passwd_MySy_LMS_User(diction):
|
|||
"id='" + str(lms_user_id) + "' " \
|
||||
"AND user_id='" + str( lms_user_id) + "' AND enabled='1' AND status = '1' AND active = '1' ;"
|
||||
try:
|
||||
#print(" ### my_query update = ", my_query)
|
||||
print(" ### my_query update PWD LMS = ", my_query)
|
||||
# cur.execute("INSERT INTO employees (first_name,last_name) VALUES (?, ?)", ("Maria", "DB"))
|
||||
cur.execute(my_query)
|
||||
except mariadb.Error as e:
|
||||
|
|
28
main.py
28
main.py
|
@ -5291,6 +5291,19 @@ def Get_List_Ressource_Materielle_with_filter():
|
|||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
"""
|
||||
API de recherche d'une recherche materielle avec des filtres No Salle, donc hors salle
|
||||
"""
|
||||
@app.route('/myclass/api/Get_List_Ressource_Materielle_with_filter_No_Salle/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Get_List_Ressource_Materielle_with_filter_No_Salle():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Get_List_Ressource_Materielle_with_filter_No_Salle payload = ",payload)
|
||||
status, retval = ressources_materiels.Get_List_Ressource_Materielle_with_filter_No_Salle(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
"""
|
||||
API Pour récuperer la liste des ressources (humaines ou materielles) rattachée
|
||||
à une ressource materiel (ex : la liste des ordinateurs d'une salle)
|
||||
|
@ -5319,6 +5332,21 @@ def Get_Type_Ressource_Materielle():
|
|||
|
||||
|
||||
|
||||
"""
|
||||
API pour recuperer les differentes catégories de ressources materielles
|
||||
"""
|
||||
@app.route('/myclass/api/Get_Categorie_Ressource_Materielle/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Get_Categorie_Ressource_Materielle():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Get_Categorie_Ressource_Materielle payload = ",payload)
|
||||
status, retval = ressources_materiels.Get_Categorie_Ressource_Materielle(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
|
||||
|
||||
"""
|
||||
API de creation d'une commande client d'un partner
|
||||
"""
|
||||
|
|
|
@ -982,7 +982,7 @@ def Get_Partner_List_Partner_Client_with_filter_Like(diction):
|
|||
val_tmp = 1
|
||||
|
||||
for New_retVal in MYSY_GV.dbname['partner_client'].find(qry):
|
||||
print(" ### New_retVal = ", New_retVal)
|
||||
#print(" ### New_retVal = ", New_retVal)
|
||||
|
||||
user = New_retVal
|
||||
user['id'] = str(val_tmp)
|
||||
|
|
10
partners.py
10
partners.py
|
@ -269,6 +269,8 @@ def update_partner_main_mail(diction):
|
|||
partner_account_id) + " correspond à plusieurs utilisateurs "
|
||||
|
||||
|
||||
|
||||
|
||||
mymail=""
|
||||
if ("mail" in diction.keys()):
|
||||
if diction['mail']:
|
||||
|
@ -371,6 +373,8 @@ def update_partner_pwd(diction):
|
|||
if (local_status is not True):
|
||||
return local_status, my_partner
|
||||
|
||||
print(" ### update_partner_pwd my_partner = ", my_partner)
|
||||
|
||||
partner_recid = my_partner['recid']
|
||||
|
||||
mypwd=""
|
||||
|
@ -403,7 +407,7 @@ def update_partner_pwd(diction):
|
|||
|
||||
mydata['date_update'] = str(datetime.now())
|
||||
|
||||
#print(mydata)
|
||||
print(" ### update_partner_pwd ", mydata)
|
||||
|
||||
|
||||
coll_name = MYSY_GV.dbname['partnair_account']
|
||||
|
@ -428,11 +432,13 @@ def update_partner_pwd(diction):
|
|||
a un compte LMS. Si c'est le cas, alors il faut mettre à jour le mot de passe dans le compte LMS aussi.
|
||||
"""
|
||||
|
||||
#print("### my_partner = ", my_partner)
|
||||
print("### my_partner = ", my_partner)
|
||||
|
||||
|
||||
if ("mysy_lms_user_id" in my_partner.keys()):
|
||||
print(" ### update my_partner = ", my_partner)
|
||||
if my_partner['mysy_lms_user_id']:
|
||||
|
||||
new_diction = {}
|
||||
new_diction['token'] = my_partner['token']
|
||||
new_diction['new_password'] = confnewpwd
|
||||
|
|
|
@ -3582,34 +3582,64 @@ def Add_Update_Employee_Login_Pass(diction):
|
|||
contact_mail = diction['contact_mail']
|
||||
mydata['contact_mail'] = contact_mail
|
||||
|
||||
|
||||
mydata['num_nda'] = ''
|
||||
|
||||
mydata['nom'] = str(my_partner['nom'])
|
||||
mydata['pack_service'] = str(my_partner['pack_service'])
|
||||
mydata['nb_formation'] = str(my_partner['nb_formation'])
|
||||
mydata['stripe_account_id'] = str(my_partner['stripe_account_id'])
|
||||
mydata['stripe_paymentmethod_id'] = str(my_partner['stripe_paymentmethod_id'])
|
||||
|
||||
mydata['lms_virtualhost_id'] = str(my_partner['lms_virtualhost_id'])
|
||||
|
||||
mydata['recid'] = str(my_partner['recid'])
|
||||
mydata['is_partner_admin_account'] = '0'
|
||||
mydata['ispending'] = '0'
|
||||
mydata['update_by'] = str(my_partner['_id'])
|
||||
|
||||
"""
|
||||
14/01/2024 : Update : Chaque enseignant a son propre compte
|
||||
utilisateur dans le LMS
|
||||
15/02/2024 -
|
||||
Si c'est un update, c'est seulement le password qu'on modifie.
|
||||
"""
|
||||
mydata['lms_username'] = ""
|
||||
mydata['mysy_lms_user_id'] = ""
|
||||
is_count_exit = MYSY_GV.dbname['partnair_account'].count_documents({'ressource_humaine_id':str(diction['ressource_humaine_id']),
|
||||
'partner_owner_recid':str(my_partner['recid'])})
|
||||
|
||||
|
||||
if( is_count_exit > 1 ):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " L'identifiant du compte à modifier est invalide ")
|
||||
|
||||
return False, " L'identifiant du compte à modifier est invalide "
|
||||
|
||||
count_to_update_data = MYSY_GV.dbname['partnair_account'].find_one(
|
||||
{'ressource_humaine_id': str(diction['ressource_humaine_id']),
|
||||
'partner_owner_recid': str(my_partner['recid'])})
|
||||
|
||||
|
||||
|
||||
if (is_count_exit == 0 ):
|
||||
# Cas d'une creation d'un compte utilisateur
|
||||
mydata['num_nda'] = ''
|
||||
mydata['nom'] = str(my_partner['nom'])
|
||||
mydata['pack_service'] = str(my_partner['pack_service'])
|
||||
mydata['nb_formation'] = str(my_partner['nb_formation'])
|
||||
mydata['stripe_account_id'] = str(my_partner['stripe_account_id'])
|
||||
mydata['stripe_paymentmethod_id'] = str(my_partner['stripe_paymentmethod_id'])
|
||||
mydata['lms_virtualhost_id'] = str(my_partner['lms_virtualhost_id'])
|
||||
mydata['recid'] = str(my_partner['recid'])
|
||||
mydata['partner_owner_recid'] = str(my_partner['recid'])
|
||||
|
||||
mydata['is_partner_admin_account'] = '0'
|
||||
mydata['ispending'] = '0'
|
||||
mydata['update_by'] = str(my_partner['_id'])
|
||||
|
||||
"""
|
||||
14/01/2024 : Update : Chaque enseignant a son propre compte
|
||||
utilisateur dans le LMS
|
||||
"""
|
||||
if( "lms_username" in my_partner.keys() ):
|
||||
mydata['lms_username'] = my_partner['lms_username']
|
||||
else:
|
||||
mydata['lms_username'] = ""
|
||||
|
||||
if ("mysy_lms_user_id" in my_partner.keys()):
|
||||
mydata['mysy_lms_user_id'] = my_partner['mysy_lms_user_id']
|
||||
else:
|
||||
mydata['mysy_lms_user_id'] = ""
|
||||
|
||||
mydata['date_update'] = str(datetime.now().strftime("%d/%m/%Y %H:%M:%S"))
|
||||
|
||||
|
||||
mydata['active'] = '1'
|
||||
mydata['locked'] = '0'
|
||||
|
||||
|
||||
ressource_humaine_id = ""
|
||||
if ("ressource_humaine_id" in diction.keys()):
|
||||
if diction['ressource_humaine_id']:
|
||||
|
@ -3626,7 +3656,7 @@ def Add_Update_Employee_Login_Pass(diction):
|
|||
count_existe_with_wrong_ressource_humaine_id = False
|
||||
count_existe_with_correct_ressource_humaine_id = False
|
||||
count_account = 0
|
||||
for retval in MYSY_GV.dbname['partnair_account'].find({'email': str(email)}):
|
||||
for retval in MYSY_GV.dbname['partnair_account'].find({'email': str(email), 'partner_owner_recid':str(my_partner['recid'])}):
|
||||
count_account = count_account + 1
|
||||
if ("ressource_humaine_id" in retval.keys() and str(retval['ressource_humaine_id']) == str(ressource_humaine_id)):
|
||||
count_existe_with_correct_ressource_humaine_id = True
|
||||
|
@ -3647,9 +3677,14 @@ def Add_Update_Employee_Login_Pass(diction):
|
|||
|
||||
return False, " - L'adresse email " + str(email) + " existe déjà et rattaché à un autre partenaire "
|
||||
|
||||
|
||||
|
||||
qry_key = {'email':str(email), 'partner_owner_recid':str(my_partner['recid'])}
|
||||
print(" #### qry key 012 = ", qry_key)
|
||||
|
||||
inserted_id = ""
|
||||
result = MYSY_GV.dbname['partnair_account'].find_one_and_update(
|
||||
{'email':str(email)},
|
||||
{'email':str(email), 'partner_owner_recid':str(my_partner['recid'])},
|
||||
{"$set": mydata},
|
||||
upsert=True,
|
||||
return_document=ReturnDocument.AFTER
|
||||
|
@ -3659,6 +3694,30 @@ def Add_Update_Employee_Login_Pass(diction):
|
|||
" Impossible de créer ou mettre à jour le compte utilisateur pour " + str(diction['email']))
|
||||
return False, " Impossible de créer ou mettre à jour le compte utilisateur "
|
||||
|
||||
"""
|
||||
15/02/2024 :
|
||||
Si l'utilisateur a un deja un accès LMS, il faut aussi mettre à jour le mot de passe dans le LMS
|
||||
|
||||
"""
|
||||
print(" ### result = ", result)
|
||||
print(" ### my_partner = ", my_partner)
|
||||
if( "mysy_lms_user_id" in result.keys() and len(str(result['mysy_lms_user_id'])) > 1 and 'token' in result.keys()
|
||||
and "partner_owner_recid" in result.keys() and str(result['partner_owner_recid']) == str(my_partner['recid']) ):
|
||||
# ce compte a deja un acces LMS, il faut mettre à jour le mot de passe.
|
||||
local_data = {}
|
||||
local_data['token'] = result['token']
|
||||
local_data['new_password'] = result['pwd']
|
||||
local_data['lms_user_id'] = result['mysy_lms_user_id']
|
||||
|
||||
local_pwd_status, local_pwd_retval, local_pwd_rowid = mysy_lms.Update_Passwd_MySy_LMS_User(local_data)
|
||||
|
||||
if( local_pwd_status is False ):
|
||||
mycommon.myprint(
|
||||
" WARNING : Impossible de mettre à jour le mot de passe dans le LMS pour le user email " + str(result['email']))
|
||||
|
||||
else:
|
||||
mycommon.myprint(" INFO : le user au compte emai " + str(result['email'])+" n'as pas d'acces LMS, donc aucune mise à jour du PWD LMS à faire" )
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -4630,15 +4689,22 @@ def HR_Create_LMS_Trainer_Account(diction):
|
|||
lms_virtualhost_url
|
||||
lms_virtualhost_id
|
||||
"""
|
||||
qry = { 'new_lms_user_id':str(new_lms_user_id),
|
||||
qry = {
|
||||
'mysy_lms_user_id':str(new_lms_user_id),
|
||||
'lms_username':str(username),
|
||||
'lms_theme_name':str(my_partner['lms_theme_name']),
|
||||
'lms_virtualhost_url': str(my_partner['lms_virtualhost_url']),
|
||||
'lms_virtualhost_id': str(my_partner['lms_virtualhost_id']),
|
||||
}
|
||||
|
||||
#print(" #### qry meee = ", qry)
|
||||
MYSY_GV.dbname['partnair_account'].update_one({'_id':ObjectId(str(is_rh_data['account_partner_id'])),
|
||||
qry_key = {'_id':ObjectId(str(is_rh_data['account_partner_id'])),
|
||||
'active':'1',
|
||||
'recid':str(my_partner['recid'])}
|
||||
|
||||
print(" #### qry_key update partnair_account = ", qry_key)
|
||||
|
||||
print(" #### qry update partnair_account = ", qry)
|
||||
result_update = MYSY_GV.dbname['partnair_account'].update_one({'_id':ObjectId(str(is_rh_data['account_partner_id'])),
|
||||
'active':'1',
|
||||
'recid':str(my_partner['recid'])},
|
||||
{'$set':
|
||||
|
@ -4652,6 +4718,10 @@ def HR_Create_LMS_Trainer_Account(diction):
|
|||
})
|
||||
|
||||
|
||||
if( result_update is None or result_update.modified_count <= 0 ) :
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " Impossible de mettre à jour le 'partnair_account' avec les données du LMS ")
|
||||
return False, " Impossible de mettre à jour le 'partnair_account' avec les données du LMS "
|
||||
"""
|
||||
A présent les acces au LMS sont crées,
|
||||
on va envoyer un email de notification à la personne
|
||||
|
|
|
@ -48,7 +48,8 @@ def Add_Ressource_Materielle(diction):
|
|||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', "ref_interne", "nom", "description", "detail", "famille",'marque',
|
||||
'prix_achat', 'fournisseur', 'qty_stock', 'type', 'site_formation_id']
|
||||
'prix_achat', 'fournisseur', 'qty_stock', 'type', 'site_formation_id', "code_categorie",
|
||||
'complement_adresse', 'capacite_ideale', 'capacite_max', 'acces_handicape', 'prix_achat_by']
|
||||
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
|
@ -116,6 +117,83 @@ def Add_Ressource_Materielle(diction):
|
|||
return False, " - Le champ 'ref_interne' fait plus de 255 caractères"
|
||||
data['ref_interne'] = ref_interne
|
||||
|
||||
complement_adresse = ""
|
||||
if ("complement_adresse" in diction.keys()):
|
||||
if diction['complement_adresse']:
|
||||
complement_adresse = diction['complement_adresse']
|
||||
if (len(str(ref_interne)) > 500):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " - Le champ 'complement_adresse' fait plus de 500 caractères")
|
||||
|
||||
return False, " - Le champ 'complement_adresse' fait plus de 500 caractères"
|
||||
data['complement_adresse'] = complement_adresse
|
||||
|
||||
capacite_ideale = "0"
|
||||
if ("capacite_ideale" in diction.keys()):
|
||||
if diction['capacite_ideale']:
|
||||
capacite_ideale = diction['capacite_ideale']
|
||||
local_status, new_participants = mycommon.IsInt(capacite_ideale)
|
||||
if (local_status is False):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " Le champ 'capacite_ideale' n'est pas un nombre entier")
|
||||
return False, " Le champ 'capacite_ideale' n'est pas un nombre entier "
|
||||
|
||||
data['capacite_ideale'] = capacite_ideale
|
||||
|
||||
capacite_max = "0"
|
||||
if ("capacite_max" in diction.keys()):
|
||||
if diction['capacite_max']:
|
||||
capacite_max = diction['capacite_max']
|
||||
local_status, new_participants = mycommon.IsInt(capacite_max)
|
||||
if (local_status is False):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " Le champ 'capacite_max' n'est pas un nombre entier")
|
||||
return False, " Le champ 'capacite_max' n'est pas un nombre entier "
|
||||
|
||||
data['capacite_max'] = capacite_max
|
||||
|
||||
acces_handicape = "0"
|
||||
if ("acces_handicape" in diction.keys()):
|
||||
if diction['acces_handicape']:
|
||||
acces_handicape = diction['acces_handicape']
|
||||
local_status, new_participants = mycommon.IsInt(acces_handicape)
|
||||
if (local_status is False):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " Le champ 'acces_handicape' doit etre '0' ou '1' ")
|
||||
return False, "Le champ 'acces_handicape' doit etre '0' ou '1' "
|
||||
|
||||
data['acces_handicape'] = acces_handicape
|
||||
|
||||
prix_achat_by = ""
|
||||
if( "prix_achat_by" in diction.keys() and diction['prix_achat_by']):
|
||||
prix_achat_by = diction['prix_achat_by']
|
||||
if( diction['prix_achat_by'] not in ['fixe', 'heure', 'jour', 'mois']):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " Le champ 'prix_achat_by' doit etre 'fixe', 'heure', 'jour', 'mois' ")
|
||||
return False, "Le champ 'prix_achat_by' doit etre 'fixe', 'heure', 'jour', 'mois' "
|
||||
|
||||
data['prix_achat_by'] = prix_achat_by
|
||||
|
||||
# Si la catégorie est fournie, alors verifier qu'elle existe, si non, mettre par defaut à 'autre"
|
||||
code_categorie = "autre"
|
||||
if( "code_categorie" in diction.keys() and diction['code_categorie']):
|
||||
is_code_categorie_exist = MYSY_GV.dbname['ressource_materielle_categorie'].count_documents({'code':str(diction['code_categorie']).lower(),
|
||||
'valide':'1',
|
||||
'locked':'0',
|
||||
'partner_owner_recid':'default'})
|
||||
|
||||
if( is_code_categorie_exist != 1 ):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " L'identifiant du code categorie est invalide ")
|
||||
|
||||
return False, " L'identifiant du code categorie est invalide "
|
||||
|
||||
code_categorie = str(diction['code_categorie']).lower()
|
||||
|
||||
data['code_categorie'] = code_categorie
|
||||
|
||||
|
||||
nom = ""
|
||||
if ("nom" in diction.keys()):
|
||||
|
@ -279,7 +357,8 @@ def Update_Ressource_Materielle(diction):
|
|||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', "ref_interne", "nom", "description", "detail", "famille",'marque', 'type',
|
||||
'prix_achat', 'fournisseur', 'qty_stock', '_id', 'site_formation_id']
|
||||
'prix_achat', 'fournisseur', 'qty_stock', '_id', 'site_formation_id', 'code_categorie',
|
||||
'complement_adresse', 'capacite_ideale', 'capacite_max', 'acces_handicape', 'prix_achat_by']
|
||||
|
||||
|
||||
|
||||
|
@ -336,7 +415,7 @@ def Update_Ressource_Materielle(diction):
|
|||
|
||||
|
||||
|
||||
print(" ### qry_update aa = ", qry_update)
|
||||
#print(" ### qry_update aa = ", qry_update)
|
||||
|
||||
tmp_count = MYSY_GV.dbname['ressource_materielle'].count_documents(qry_update)
|
||||
if (tmp_count <= 0):
|
||||
|
@ -368,6 +447,86 @@ def Update_Ressource_Materielle(diction):
|
|||
return False, " - Le champ 'ref_interne' fait plus de 255 caractères"
|
||||
data_update['ref_interne'] = diction['ref_interne']
|
||||
|
||||
# Si la catégorie est fournie, alors verifier qu'elle existe, si non, mettre par defaut à 'autre"
|
||||
|
||||
if ("code_categorie" in diction.keys() and diction['code_categorie']):
|
||||
is_code_categorie_exist = MYSY_GV.dbname['ressource_materielle_categorie'].count_documents(
|
||||
{'code': str(diction['code_categorie']).lower(),
|
||||
'valide': '1',
|
||||
'locked': '0',
|
||||
'partner_owner_recid': 'default'})
|
||||
|
||||
if (is_code_categorie_exist != 1):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " L'identifiant du code categorie est invalide ")
|
||||
|
||||
return False, " L'identifiant du code categorie est invalide "
|
||||
|
||||
code_categorie = str(diction['code_categorie']).lower()
|
||||
data_update['code_categorie'] = code_categorie
|
||||
|
||||
|
||||
complement_adresse = ""
|
||||
if ("complement_adresse" in diction.keys()):
|
||||
if diction['complement_adresse']:
|
||||
complement_adresse = diction['complement_adresse']
|
||||
if (len(str(ref_interne)) > 500):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " - Le champ 'complement_adresse' fait plus de 500 caractères")
|
||||
|
||||
return False, " - Le champ 'complement_adresse' fait plus de 500 caractères"
|
||||
data_update['complement_adresse'] = complement_adresse
|
||||
|
||||
capacite_ideale = "0"
|
||||
if ("capacite_ideale" in diction.keys()):
|
||||
if diction['capacite_ideale']:
|
||||
capacite_ideale = diction['capacite_ideale']
|
||||
local_status, new_participants = mycommon.IsInt(capacite_ideale)
|
||||
if (local_status is False):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " Le champ 'capacite_ideale' n'est pas un nombre entier")
|
||||
return False, " Le champ 'capacite_ideale' n'est pas un nombre entier "
|
||||
|
||||
data_update['capacite_ideale'] = capacite_ideale
|
||||
|
||||
capacite_max = "0"
|
||||
if ("capacite_max" in diction.keys()):
|
||||
if diction['capacite_max']:
|
||||
capacite_max = diction['capacite_max']
|
||||
local_status, new_participants = mycommon.IsInt(capacite_max)
|
||||
if (local_status is False):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " Le champ 'capacite_max' n'est pas un nombre entier")
|
||||
return False, " Le champ 'capacite_max' n'est pas un nombre entier "
|
||||
|
||||
data_update['capacite_max'] = capacite_max
|
||||
|
||||
|
||||
if ("acces_handicape" in diction.keys()):
|
||||
acces_handicape = "0"
|
||||
if diction['acces_handicape']:
|
||||
acces_handicape = diction['acces_handicape']
|
||||
local_status, new_participants = mycommon.IsInt(acces_handicape)
|
||||
if (local_status is False):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " Le champ 'acces_handicape' doit etre '0' ou '1' ")
|
||||
return False, "Le champ 'acces_handicape' doit etre '0' ou '1' "
|
||||
|
||||
data_update['acces_handicape'] = acces_handicape
|
||||
|
||||
prix_achat_by = ""
|
||||
if ("prix_achat_by" in diction.keys() and diction['prix_achat_by']):
|
||||
prix_achat_by = diction['prix_achat_by']
|
||||
if (diction['prix_achat_by'] not in ['fixe', 'heure', 'jour', 'mois']):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " Le champ 'prix_achat_by' doit etre 'fixe', 'heure', 'jour', 'mois' ")
|
||||
return False, "Le champ 'prix_achat_by' doit etre 'fixe', 'heure', 'jour', 'mois' "
|
||||
|
||||
data_update['prix_achat_by'] = prix_achat_by
|
||||
|
||||
|
||||
nom = ""
|
||||
if ("nom" in diction.keys()):
|
||||
nom = diction['nom']
|
||||
|
@ -442,7 +601,7 @@ def Update_Ressource_Materielle(diction):
|
|||
mycommon.myprint(" L'identifiant du site de formation est invalide ")
|
||||
return False, " L'identifiant du site de formation est invalide "
|
||||
|
||||
print(" ##### GGRR site_formation_id = ", site_formation_id)
|
||||
#print(" ##### GGRR site_formation_id = ", site_formation_id)
|
||||
data_update['site_formation_id'] = site_formation_id
|
||||
|
||||
prix_achat = ""
|
||||
|
@ -671,6 +830,12 @@ def Get_List_Ressource_Materielle(diction):
|
|||
user = retval
|
||||
user['id'] = str(val_tmp)
|
||||
val_tmp = val_tmp + 1
|
||||
|
||||
if ("prix_achat_by" in retval.keys()):
|
||||
user['prix_achat_by'] = retval['prix_achat_by']
|
||||
else:
|
||||
user['prix_achat_by'] = ""
|
||||
|
||||
RetObject.append(mycommon.JSONEncoder().encode(user))
|
||||
|
||||
return True, RetObject
|
||||
|
@ -743,6 +908,11 @@ def Get_List_Ressource_Materielle_no_filter(diction):
|
|||
user = retval
|
||||
user['id'] = str(val_tmp)
|
||||
val_tmp = val_tmp + 1
|
||||
if ("prix_achat_by" in retval.keys()):
|
||||
user['prix_achat_by'] = retval['prix_achat_by']
|
||||
else:
|
||||
user['prix_achat_by'] = ""
|
||||
|
||||
RetObject.append(mycommon.JSONEncoder().encode(user))
|
||||
|
||||
return True, RetObject
|
||||
|
@ -815,6 +985,11 @@ def Get_Given_Ressource_Materielle(diction):
|
|||
user['id'] = str(val_tmp)
|
||||
val_tmp = val_tmp + 1
|
||||
|
||||
if ("prix_achat_by" in retval.keys()):
|
||||
user['prix_achat_by'] = retval['prix_achat_by']
|
||||
else:
|
||||
user['prix_achat_by'] = ""
|
||||
|
||||
RetObject.append(mycommon.JSONEncoder().encode(user))
|
||||
|
||||
#print(" ### RetObject = ", RetObject)
|
||||
|
@ -1813,7 +1988,8 @@ def Get_List_Ressource_Materielle_with_filter(diction):
|
|||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', 'nom', 'ref_interne', 'formation', 'session', 'employe_email']
|
||||
field_list = ['token', 'nom', 'ref_interne', 'formation', 'session', 'employe_email',
|
||||
'code_categorie']
|
||||
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
|
@ -1862,6 +2038,11 @@ def Get_List_Ressource_Materielle_with_filter(diction):
|
|||
filt_ref_interne = {
|
||||
'ref_interne': {'$regex': str(diction['ref_interne']), "$options": "i"}}
|
||||
|
||||
filt_code_categorie = {}
|
||||
if ("code_categorie" in diction.keys()):
|
||||
filt_code_categorie = {
|
||||
'code_categorie': {'$regex': str(diction['code_categorie']), "$options": "i"}}
|
||||
|
||||
# Sous Filter pour une formation
|
||||
sub_filt_formation = {}
|
||||
if ("formation" in diction.keys()):
|
||||
|
@ -1943,7 +2124,7 @@ def Get_List_Ressource_Materielle_with_filter(diction):
|
|||
data_cle['locked'] = "0"
|
||||
data_cle['valide'] = "1"
|
||||
|
||||
find_qry = {'$and':[{'partner_recid': str(my_partner['recid']), 'valide':'1', 'locked':'0' }, filt_nom, filt_ref_interne] }
|
||||
find_qry = {'$and':[{'partner_recid': str(my_partner['recid']), 'valide':'1', 'locked':'0' }, filt_nom, filt_ref_interne, filt_code_categorie] }
|
||||
|
||||
|
||||
new_myquery = [{'$match': find_qry},
|
||||
|
@ -1963,8 +2144,7 @@ def Get_List_Ressource_Materielle_with_filter(diction):
|
|||
}
|
||||
]
|
||||
|
||||
print(" ##### new_myquery aa = ", new_myquery)
|
||||
print(" ##### find_qry aa = ", find_qry)
|
||||
|
||||
|
||||
New_RetObject = []
|
||||
New_val_tmp = 1
|
||||
|
@ -1988,6 +2168,13 @@ def Get_List_Ressource_Materielle_with_filter(diction):
|
|||
user['ref_interne'] = New_retVal['ref_interne']
|
||||
user['nom'] = New_retVal['nom']
|
||||
|
||||
|
||||
if ("prix_achat_by" in New_retVal.keys()):
|
||||
user['prix_achat_by'] = New_retVal['prix_achat_by']
|
||||
else:
|
||||
user['prix_achat_by'] = ""
|
||||
|
||||
|
||||
if ("description" in New_retVal.keys()):
|
||||
user['description'] = New_retVal['description']
|
||||
else:
|
||||
|
@ -2028,6 +2215,18 @@ def Get_List_Ressource_Materielle_with_filter(diction):
|
|||
else:
|
||||
user['qty_stock'] = ""
|
||||
|
||||
site_formation_code_site = ""
|
||||
if( "site_formation_id" in New_retVal.keys() and New_retVal['site_formation_id'] ):
|
||||
local_site = MYSY_GV.dbname['site_formation'].find_one({'_id':ObjectId(str(New_retVal['site_formation_id'])),
|
||||
'valide':'1',
|
||||
'locked':'0',
|
||||
'partner_owner_recid':str(my_partner['recid'])})
|
||||
|
||||
if( local_site and 'code_site' in local_site.keys() ):
|
||||
site_formation_code_site = local_site['code_site']
|
||||
|
||||
user['site_formation_code_site'] = site_formation_code_site
|
||||
|
||||
|
||||
|
||||
user['affectation'] = []
|
||||
|
@ -2043,7 +2242,300 @@ def Get_List_Ressource_Materielle_with_filter(diction):
|
|||
affectation['date_au'] = local_affectation['date_au']
|
||||
|
||||
|
||||
print(" ### AFFACTATION local_affectation = ", local_affectation)
|
||||
#print(" ### AFFACTATION local_affectation = ", local_affectation)
|
||||
|
||||
New_RetObject.append(mycommon.JSONEncoder().encode(user))
|
||||
|
||||
return True, New_RetObject
|
||||
else:
|
||||
# Il s'agit d'une recherche sans lien avec des fonctions occupés dans une formation ou une session
|
||||
RetObject = []
|
||||
val_tmp = 1
|
||||
|
||||
for retval in MYSY_GV.dbname['ressource_materielle'].find(find_qry):
|
||||
user = retval
|
||||
user['id'] = str(val_tmp)
|
||||
val_tmp = val_tmp + 1
|
||||
RetObject.append(mycommon.JSONEncoder().encode(user))
|
||||
|
||||
return True, RetObject
|
||||
|
||||
|
||||
except Exception as e:
|
||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - Line : " + str(exc_tb.tb_lineno))
|
||||
return False, " Impossible de récupérer la liste des contact "
|
||||
|
||||
|
||||
"""
|
||||
Récuperation d'une ressource materiel hors salle (No_Salle)
|
||||
"""
|
||||
def Get_List_Ressource_Materielle_with_filter_No_Salle(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', 'nom', 'ref_interne', 'formation', 'session', 'employe_email',
|
||||
'code_categorie']
|
||||
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
if val not in field_list and val.startswith('my_') is False:
|
||||
mycommon.myprint(str(
|
||||
inspect.stack()[0][3]) + " Le champ '" + val + "' n'existe pas")
|
||||
return False, " Les informations fournies sont incorrectes",
|
||||
|
||||
"""
|
||||
Verification des champs obligatoires
|
||||
"""
|
||||
field_list_obligatoire = ['token', ]
|
||||
for val in field_list_obligatoire:
|
||||
if val not in diction:
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " - La valeur '" + val + "' n'est pas presente dans liste ")
|
||||
return False, " Les informations fournies sont incorrectes",
|
||||
|
||||
"""
|
||||
Verification de l'identité et autorisation de l'entité qui
|
||||
appelle cette API
|
||||
"""
|
||||
token = ""
|
||||
if ("token" in diction.keys()):
|
||||
if diction['token']:
|
||||
token = diction['token']
|
||||
|
||||
# Verifier la validité du token
|
||||
retval = mycommon.check_partner_token_validity("", token)
|
||||
|
||||
if retval is False:
|
||||
return "Err_Connexion", " La session de connexion n'est pas valide"
|
||||
|
||||
# Recuperation des données du partenaire
|
||||
local_status, my_partner = mycommon.get_partner_data_from_token(token)
|
||||
if (local_status is False):
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - impossible de récupérer les données de l'utilisateur ")
|
||||
return False, str(inspect.stack()[0][3]) + " - impossible de récupérer les données de l'utilisateur. "
|
||||
|
||||
filt_nom = {}
|
||||
if ("nom" in diction.keys()):
|
||||
filt_nom = {'nom': {'$regex': str(diction['nom']), "$options": "i"}}
|
||||
|
||||
filt_ref_interne = {}
|
||||
if ("ref_interne" in diction.keys()):
|
||||
filt_ref_interne = {
|
||||
'ref_interne': {'$regex': str(diction['ref_interne']), "$options": "i"}}
|
||||
|
||||
filt_code_categorie = {}
|
||||
if ("code_categorie" in diction.keys()):
|
||||
filt_code_categorie = {
|
||||
'code_categorie': {'$regex': str(diction['code_categorie']), "$options": "i"}}
|
||||
|
||||
# Sous Filter pour une formation
|
||||
sub_filt_formation = {}
|
||||
if ("formation" in diction.keys()):
|
||||
sub_filt_formation = {
|
||||
'external_code': {'$regex': str(diction['formation']), "$options": "i"}, 'partner_owner_recid':str(my_partner['recid'])}
|
||||
|
||||
# Sous Filter pour une session
|
||||
sub_filt_session = {}
|
||||
if ("session" in diction.keys()):
|
||||
sub_filt_session = { 'code_session': {'$regex': str(diction['session']), "$options": "i"}, 'partner_owner_recid':str(my_partner['recid'])}
|
||||
|
||||
|
||||
# Sous Filter pour un employe
|
||||
sub_filt_employee = {}
|
||||
if ("employe_email" in diction.keys()):
|
||||
sub_filt_employee = {'email': {'$regex': str(diction['employe_email']), "$options": "i"},
|
||||
'partner_recid': str(my_partner['recid'])}
|
||||
|
||||
"""
|
||||
Recuperation des id des codes session pouvant correspondre a la valeur fournie par le user
|
||||
(regexp bien sur)
|
||||
"""
|
||||
filt_session = {}
|
||||
Lists_session_id = []
|
||||
if ("session" in diction.keys()):
|
||||
for Lists_session in MYSY_GV.dbname['session_formation'].find(sub_filt_session, {'_id':1}):
|
||||
Lists_session_id.append(str(Lists_session['_id']))
|
||||
|
||||
if( len(Lists_session_id) > 0):
|
||||
filt_session = {'related_target_collection_id': {'$in': Lists_session_id, },
|
||||
'related_collection': 'ressource_materielle',
|
||||
'related_target_collection': 'session_formation',
|
||||
}
|
||||
|
||||
|
||||
"""
|
||||
Recuperation des id des formation pouvant correspondre a la valeur fournie par le user
|
||||
(regexp bien sur)
|
||||
"""
|
||||
filt_formation = {}
|
||||
Lists_formation_id = []
|
||||
if ("formation" in diction.keys()):
|
||||
for Lists_formation in MYSY_GV.dbname['myclass'].find(sub_filt_formation, {'_id': 1}):
|
||||
Lists_formation_id.append(str(Lists_formation['_id']))
|
||||
|
||||
|
||||
if(len(Lists_formation_id) > 0 ):
|
||||
filt_formation = {'related_target_collection_id': {'$in': Lists_formation_id, },
|
||||
'related_collection':'ressource_materielle',
|
||||
'related_target_collection':'myclass',
|
||||
}
|
||||
|
||||
"""
|
||||
Recuperation des id des employées dont l'email corresponds en mode regexp
|
||||
"""
|
||||
filt_employee = {}
|
||||
Lists_employee_id = []
|
||||
if ("employe_email" in diction.keys()):
|
||||
for Lists_employee in MYSY_GV.dbname['ressource_humaine'].find(sub_filt_employee, {'_id': 1}):
|
||||
Lists_employee_id.append(str(Lists_employee['_id']))
|
||||
|
||||
if (len(Lists_employee_id) > 0):
|
||||
filt_employee = {'related_target_collection_id': {'$in': Lists_employee_id, },
|
||||
'related_collection': 'ressource_materielle',
|
||||
'related_target_collection': 'ressource_humaine',
|
||||
}
|
||||
|
||||
#print(" ### sub_filt_employee = ", sub_filt_employee)
|
||||
#print(" ### Lists_employee_id = ", Lists_employee_id)
|
||||
#print(" ### filt_employee = ", filt_employee)
|
||||
|
||||
"""
|
||||
Clés de mise à jour
|
||||
"""
|
||||
|
||||
data_cle = {}
|
||||
data_cle['partner_recid'] = str(my_partner['recid'])
|
||||
|
||||
data_cle['locked'] = "0"
|
||||
data_cle['valide'] = "1"
|
||||
|
||||
no_salle_qry = {'code_categorie':{"$ne": "salle"}}
|
||||
|
||||
|
||||
find_qry = {'$and':[{'partner_recid': str(my_partner['recid']), 'valide':'1', 'locked':'0' }, filt_nom,
|
||||
filt_ref_interne, filt_code_categorie, no_salle_qry] }
|
||||
|
||||
|
||||
new_myquery = [{'$match': find_qry},
|
||||
{"$addFields": {"ressource_materielle_Id": {"$toString": "$_id"}}},
|
||||
{'$lookup':
|
||||
{
|
||||
'from': 'ressource_materielle_affectation',
|
||||
'localField': "ressource_materielle_Id",
|
||||
'foreignField': 'related_collection_recid',
|
||||
'pipeline': [{'$match':{ '$and' : [ filt_formation, filt_session, filt_employee, {'partner_owner_recid': str(my_partner['recid'])}, {'valide':'1'}] } }, {'$project': {'poste': 1,
|
||||
'date_du': 1,
|
||||
'date_au':1,
|
||||
'related_target_collection':1
|
||||
}}],
|
||||
'as': 'ressource_materielle_affectation_collection'
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
|
||||
New_RetObject = []
|
||||
New_val_tmp = 1
|
||||
|
||||
|
||||
""""
|
||||
Si dans la requette on a les champ : 'formation' ou 'session' on utiliser la requete ci-dessous.
|
||||
Cela veut dire qu'on cherche des ressources qui sont des affectation avec une formation ou une session.
|
||||
"""
|
||||
if( "formation" in diction.keys() or "session" in diction.keys() or "employe_email" in diction.keys() ):
|
||||
for New_retVal in MYSY_GV.dbname['ressource_materielle'].aggregate(new_myquery):
|
||||
if ('ressource_materielle_affectation_collection' in New_retVal.keys() and len(New_retVal['ressource_materielle_affectation_collection']) > 0):
|
||||
print(" #### RESULT New_retVal for = ", New_retVal['nom'])
|
||||
user = {}
|
||||
user['id'] = str(New_val_tmp)
|
||||
New_val_tmp = New_val_tmp + 1
|
||||
|
||||
|
||||
user['_id'] = New_retVal['_id']
|
||||
user['partner_recid'] = New_retVal['partner_recid']
|
||||
user['ref_interne'] = New_retVal['ref_interne']
|
||||
user['nom'] = New_retVal['nom']
|
||||
|
||||
|
||||
if ("prix_achat_by" in New_retVal.keys()):
|
||||
user['prix_achat_by'] = New_retVal['prix_achat_by']
|
||||
else:
|
||||
user['prix_achat_by'] = ""
|
||||
|
||||
|
||||
if ("description" in New_retVal.keys()):
|
||||
user['description'] = New_retVal['description']
|
||||
else:
|
||||
user['description'] = ""
|
||||
|
||||
if ("detail" in New_retVal.keys()):
|
||||
user['detail'] = New_retVal['detail']
|
||||
else:
|
||||
user['detail'] = ""
|
||||
|
||||
if( "famille" in New_retVal.keys()):
|
||||
user['famille'] = New_retVal['famille']
|
||||
else:
|
||||
user['famille'] = ""
|
||||
|
||||
if ("marque" in New_retVal.keys()):
|
||||
user['marque'] = New_retVal['marque']
|
||||
else:
|
||||
user['marque'] = ""
|
||||
|
||||
if ("type" in New_retVal.keys()):
|
||||
user['type'] = New_retVal['type']
|
||||
else:
|
||||
user['type'] = ""
|
||||
|
||||
if ("prix_achat" in New_retVal.keys()):
|
||||
user['prix_achat'] = New_retVal['prix_achat']
|
||||
else:
|
||||
user['prix_achat'] = ""
|
||||
|
||||
if ("fournisseur" in New_retVal.keys()):
|
||||
user['fournisseur'] = New_retVal['fournisseur']
|
||||
else:
|
||||
user['fournisseur'] = ""
|
||||
|
||||
if ("qty_stock" in New_retVal.keys()):
|
||||
user['qty_stock'] = New_retVal['qty_stock']
|
||||
else:
|
||||
user['qty_stock'] = ""
|
||||
|
||||
site_formation_code_site = ""
|
||||
if( "site_formation_id" in New_retVal.keys() and New_retVal['site_formation_id'] ):
|
||||
local_site = MYSY_GV.dbname['site_formation'].find_one({'_id':ObjectId(str(New_retVal['site_formation_id'])),
|
||||
'valide':'1',
|
||||
'locked':'0',
|
||||
'partner_owner_recid':str(my_partner['recid'])})
|
||||
|
||||
if( local_site and 'code_site' in local_site.keys() ):
|
||||
site_formation_code_site = local_site['code_site']
|
||||
|
||||
user['site_formation_code_site'] = site_formation_code_site
|
||||
|
||||
|
||||
|
||||
user['affectation'] = []
|
||||
for local_affectation in New_retVal['ressource_materielle_affectation_collection']:
|
||||
affectation = {}
|
||||
if ("poste" in local_affectation.keys()):
|
||||
affectation['poste'] = local_affectation['poste']
|
||||
else:
|
||||
affectation['poste'] = ""
|
||||
|
||||
affectation['related_target_collection'] = local_affectation['related_target_collection']
|
||||
affectation['date_du'] = local_affectation['date_du']
|
||||
affectation['date_au'] = local_affectation['date_au']
|
||||
|
||||
|
||||
#print(" ### AFFACTATION local_affectation = ", local_affectation)
|
||||
|
||||
New_RetObject.append(mycommon.JSONEncoder().encode(user))
|
||||
|
||||
|
@ -2243,4 +2735,81 @@ def Get_Type_Ressource_Materielle(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 type de ressource materielle "
|
||||
return False, " Impossible de récupérer les types de ressource materielle "
|
||||
|
||||
|
||||
"""
|
||||
Recuperation des catégories materiel
|
||||
(salles, infomatique, autre, etc)
|
||||
"""
|
||||
def Get_Categorie_Ressource_Materielle(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', ]
|
||||
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
if val not in field_list and val.startswith('my_') is False:
|
||||
mycommon.myprint(str(
|
||||
inspect.stack()[0][3]) + " Le champ '" + val + "' n'existe pas")
|
||||
return False, " Les informations fournies sont incorrectes",
|
||||
|
||||
"""
|
||||
Verification des champs obligatoires
|
||||
"""
|
||||
field_list_obligatoire = ['token', ]
|
||||
for val in field_list_obligatoire:
|
||||
if val not in diction:
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " - La valeur '" + val + "' n'est pas presente dans liste ")
|
||||
return False, " Les informations fournies sont incorrectes",
|
||||
|
||||
"""
|
||||
Verification de l'identité et autorisation de l'entité qui
|
||||
appelle cette API
|
||||
"""
|
||||
token = ""
|
||||
if ("token" in diction.keys()):
|
||||
if diction['token']:
|
||||
token = diction['token']
|
||||
|
||||
# Verifier la validité du token
|
||||
retval = mycommon.check_partner_token_validity("", token)
|
||||
|
||||
if retval is False:
|
||||
return "Err_Connexion", " La session de connexion n'est pas valide"
|
||||
|
||||
# Recuperation des données du partenaire
|
||||
local_status, my_partner = mycommon.get_partner_data_from_token(token)
|
||||
if (local_status is False):
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - impossible de récupérer les données de l'utilisateur ")
|
||||
return False, str(inspect.stack()[0][3]) + " - impossible de récupérer les données de l'utilisateur. "
|
||||
|
||||
"""
|
||||
Clés de mise à jour
|
||||
"""
|
||||
data_cle = {}
|
||||
data_cle['partner_owner_recid'] = "default"
|
||||
data_cle['locked'] = "0"
|
||||
data_cle['valide'] = "1"
|
||||
|
||||
RetObject = []
|
||||
val_tmp = 1
|
||||
|
||||
for retval in MYSY_GV.dbname['ressource_materielle_categorie'].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 catégories de ressource materielle "
|
||||
|
|
Loading…
Reference in New Issue