04/07/23 - 17h

master
cherif 2023-07-04 16:52:16 +02:00
parent f832eef3e6
commit 384e51d5a3
11 changed files with 2085 additions and 35 deletions

View File

@ -1,27 +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="13/06/23 - 21h21">
<change afterPath="$PROJECT_DIR$/appel_offre.py" afterDir="false" />
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="04/07/23 - 10h">
<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$/Session_Formation.py" beforeDir="false" afterPath="$PROJECT_DIR$/Session_Formation.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/appel_offre.py" beforeDir="false" afterPath="$PROJECT_DIR$/appel_offre.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/articles_avis.py" beforeDir="false" afterPath="$PROJECT_DIR$/articles_avis.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/business_prices.py" beforeDir="false" afterPath="$PROJECT_DIR$/business_prices.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/class_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/class_mgt.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/data_indexees.csv" beforeDir="false" afterPath="$PROJECT_DIR$/data_indexees.csv" afterDir="false" />
<change beforePath="$PROJECT_DIR$/ela_factures_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/ela_factures_mgt.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/ela_output_test_file_pandas_2.txt" beforeDir="false" afterPath="$PROJECT_DIR$/ela_output_test_file_pandas_2.txt" afterDir="false" />
<change beforePath="$PROJECT_DIR$/ela_user_account.py" beforeDir="false" afterPath="$PROJECT_DIR$/ela_user_account.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/email_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/email_mgt.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$/partners.py" beforeDir="false" afterPath="$PROJECT_DIR$/partners.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/prj_common.py" beforeDir="false" afterPath="$PROJECT_DIR$/prj_common.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/product_service.py" beforeDir="false" afterPath="$PROJECT_DIR$/product_service.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/statistics.py" beforeDir="false" afterPath="$PROJECT_DIR$/statistics.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/strype_payement.py" beforeDir="false" afterPath="$PROJECT_DIR$/strype_payement.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/user_message_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/user_message_mgt.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/wrapper.py" beforeDir="false" afterPath="$PROJECT_DIR$/wrapper.py" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
@ -338,7 +328,14 @@
<option name="project" value="LOCAL" />
<updated>1686684145572</updated>
</task>
<option name="localTasksCounter" value="37" />
<task id="LOCAL-00037" summary="04/07/23 - 10h">
<created>1688460514460</created>
<option name="number" value="00037" />
<option name="presentableId" value="LOCAL-00037" />
<option name="project" value="LOCAL" />
<updated>1688460514460</updated>
</task>
<option name="localTasksCounter" value="38" />
<servers />
</component>
<component name="Vcs.Log.Tabs.Properties">
@ -353,7 +350,6 @@
</option>
</component>
<component name="VcsManagerConfiguration">
<MESSAGE value="22/04/23 - 19h" />
<MESSAGE value="23/04/23 - 19h" />
<MESSAGE value="24/04/23 - 21h" />
<MESSAGE value="25/04/23 - 21h" />
@ -378,6 +374,7 @@
<MESSAGE value="08/06/23 - 21h" />
<MESSAGE value="13/06/23 - 16h" />
<MESSAGE value="13/06/23 - 21h21" />
<option name="LAST_COMMIT_MESSAGE" value="13/06/23 - 21h21" />
<MESSAGE value="04/07/23 - 10h" />
<option name="LAST_COMMIT_MESSAGE" value="04/07/23 - 10h" />
</component>
</project>

File diff suppressed because one or more lines are too long

View File

@ -82,6 +82,7 @@ def Add_Update_SessionFormation(diction):
if ("class_internal_url" in diction.keys()):
mydata['class_internal_url'] = diction['class_internal_url']
class_internal_url = diction['class_internal_url']
query_key['class_internal_url'] = diction['code_session']
class_source = ""
if ("source" in diction.keys()):
@ -518,7 +519,7 @@ def Add_Update_SessionFormation_mass(file=None, Folder=None, diction=None):
retval = mycommon.check_partner_token_validity("", my_token)
if retval is False:
return False, " La session de connexion n'est pas valide"
return "Err_Connexion", " La session de connexion n'est pas valide"
partner_recid = mycommon.get_parnter_recid_from_token(my_token)

View File

@ -31,8 +31,8 @@ def Add_Appel_Offre(diction):
"""
Verification des input acceptés
"""
field_list = ['token', 'nom', 'prenom', 'email', 'tel_mobile', 'date_naissance', 'adr_rue', 'adr_ville',
'adr_code_postal', 'adr_pays']
field_list = ['token', "external_code", "description", "date_debut", "date_fin", "contact",
"date_deliberation", "description_critere_selection", "comment", "list_produits_appel_offre"]
incom_keys = diction.keys()
for val in incom_keys:
if val not in field_list:
@ -59,6 +59,13 @@ def Add_Appel_Offre(diction):
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"
partner_recid = mycommon.get_parnter_recid_from_token(token)
if (partner_recid is False):
mycommon.myprint(
@ -76,11 +83,134 @@ def Add_Appel_Offre(diction):
"""
data = {}
data['partner_recid'] = diction['partner_recid']
nom = ""
if ("nom" in diction.keys()):
if diction['nom']:
nom = diction['nom']
data['nom'] = diction['nom']
external_code = ""
if ("external_code" in diction.keys()):
if diction['external_code']:
external_code = diction['external_code']
data['external_code'] = diction['external_code']
description = ""
if ("description" in diction.keys()):
if diction['description']:
description = diction['description']
data['description'] = diction['description']
date_debut = ""
if ("date_debut" in diction.keys()):
if diction['date_debut']:
date_debut = diction['date_debut']
data['date_debut'] = diction['date_debut']
local_status = mycommon.CheckisDate(date_debut)
if (local_status is False):
mycommon.myprint(
str(inspect.stack()[0][
3]) + " - La date debut n'est pas au format jj/mm/aaaa ")
return False, " La date debut n'est pas au format jj/mm/aaaa "
date_fin = ""
if ("date_fin" in diction.keys()):
if diction['date_fin']:
date_fin = diction['date_fin']
data['date_fin'] = diction['date_fin']
local_status = mycommon.CheckisDate(date_fin)
if (local_status is False):
mycommon.myprint(
str(inspect.stack()[0][
3]) + " - La date de fin n'est pas au format jj/mm/aaaa ")
return False, " La date de fin n'est pas au format jj/mm/aaaa "
"""
Controle cohérence des dates debut et fin
"""
if (datetime.strptime(str(date_debut).strip(), '%d/%m/%Y') > datetime.strptime(
str(date_fin).strip(), '%d/%m/%Y')):
mycommon.myprint(
str(inspect.stack()[0][
3]) + " La date debut " + str(date_debut) +" est postérieure à la date de fin " + str(date_fin) + " ")
return False, " La date debut " + str(date_debut) + " est postérieure à la date de fin " + str(date_fin) + " "
contact = ""
if ("contact" in diction.keys()):
if diction['contact']:
contact = diction['contact']
data['contact'] = diction['contact']
date_deliberation = ""
if ("date_deliberation" in diction.keys()):
if diction['date_deliberation']:
date_deliberation = diction['date_deliberation']
data['date_deliberation'] = diction['date_deliberation']
local_status = mycommon.CheckisDate(date_deliberation)
if (local_status is False):
mycommon.myprint(
str(inspect.stack()[0][
3]) + " - La date de deliberation n'est pas au format jj/mm/aaaa ")
return False, " La date de deliberation n'est pas au format jj/mm/aaaa "
"""
Controle cohérence des dates debut et la date de deliberation
"""
if (datetime.strptime(str(date_debut).strip(), '%d/%m/%Y') > datetime.strptime(
str(date_deliberation).strip(), '%d/%m/%Y')):
mycommon.myprint(
str(inspect.stack()[0][
3]) + " La date debut " + str(date_debut) + " est postérieure à la date de deliberation " + str(
date_deliberation) + " ")
return False, " La date debut " + str(date_debut) + " est postérieure à la date de deliberation " + str(
date_deliberation) + " "
description_critere_selection = ""
if ("description_critere_selection" in diction.keys()):
if diction['description_critere_selection']:
description_critere_selection = diction['description_critere_selection']
data['description_critere_selection'] = diction['description_critere_selection']
comment = ""
if ("comment" in diction.keys()):
if diction['comment']:
comment = diction['comment']
data['comment'] = diction['comment']
list_produits_appel_offre = ""
if ("list_produits_appel_offre" in diction.keys()):
if diction['list_produits_appel_offre']:
list_produits_appel_offre = diction['list_produits_appel_offre']
data['list_produits_appel_offre'] = diction['list_produits_appel_offre']
"""
Verifier s'il n'y pas deja un appel d'offre avec le meme code externe et partner_recid
"""
tmp_count = MYSY_GV['appel_offre'].count_documents({'external_code': str(external_code),
'valide': '1', 'partner_recid':my_partner['recid']})
if (tmp_count > 0):
mycommon.myprint(
str(inspect.stack()[0][
3]) + " - Cet appel d'offre est deja enregistré : external_code = ", str(external_code))
return False, " - Cet appel d'offre est deja enregistré "
data['partner_recid'] = my_partner['recid']
data['valide'] = '1'
data['locked'] = '0'
inserted_id = ""
inserted_id = MYSY_GV.dbname['appel_offre'].insert_one(data).inserted_id
if (not inserted_id):
mycommon.myprint(
" Impossible de créer l'appel d'offre (1) ")
return False, " Impossible de créer l'appel d'offre (1) "
return True, " L'appel d'ofre a été correctement créé"
@ -129,6 +259,12 @@ def Update_Appel_Offre(diction):
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"
partner_recid = mycommon.get_parnter_recid_from_token(token)
if (partner_recid is False):
mycommon.myprint(
@ -178,4 +314,66 @@ def Update_Appel_Offre(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 d'ajouter le candidat "
return False, " Impossible de mettre à jour l'appel d'offre' "
"""
fonction de recuperation d'un appel d'offre
"""
def Get_Appel_Offre(diction):
try:
diction = mycommon.strip_dictionary(diction)
"""
Verification des input acceptés
"""
field_list = ['token', 'nom', 'prenom', 'email', 'tel_mobile', 'date_naissance', 'adr_rue', 'adr_ville',
'adr_code_postal', 'adr_pays', 'candidats_id', 'cpny']
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'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_user = mycommon.get_user_data_from_token(token)
if (local_status is False):
mycommon.myprint(str(inspect.stack()[0][3]) + " - impossible de recuperer les données de l'utilisateur ")
return False, str(inspect.stack()[0][3]) + " - impossible de recuperer les données de l'utilisateur. "
RetObject = []
nb_val = 0
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 candidats "

View File

@ -497,7 +497,7 @@ def recherche_articles_avis(diction):
if retval is False:
mycommon.myprint(str(inspect.stack()[0][3]) + " - La session de connexion n'est pas valide")
return False, "La session de connexion n'est pas valide"
return "Err_Connexion", "La session de connexion n'est pas valide"
# Recuperation du recid de l'utilisateur
user_recid = mycommon.get_user_recid_from_token(token)

View File

@ -1735,7 +1735,7 @@ def get_class(diction):
if retval is False:
mycommon.myprint(str(inspect.stack()[0][3]) + " - La session de connexion n'est pas valide")
return False, "La session de connexion n'est pas valide"
return "Err_Connexion", "La session de connexion n'est pas valide"
# Recuperation du recid de l'utilisateur
user_recid = mycommon.get_parnter_recid_from_token(my_token)

View File

@ -1184,7 +1184,7 @@ def change_uer_email(diction):
if retval is False:
mycommon.myprint("La session de connexion n'est pas valide")
return False, "La session de connexion n'est pas valide"
return "Err_Connexion", "La session de connexion n'est pas valide"
# Recuperation du recid du user
@ -1278,7 +1278,7 @@ def send_mail_delete_user(diction):
if retval is False:
mycommon.myprint(
str(inspect.stack()[0][3]) + " - La session de connexion n'est pas valide ")
return False, "La session de connexion n'est pas valide"
return "Err_Connexion", "La session de connexion n'est pas valide"
# Recuperation du recid du user
user_recid = mycommon.get_user_recid_from_token(token_value)
@ -1654,7 +1654,7 @@ def get_user_recherche_history(diction):
if retval is False:
mycommon.myprint(str(inspect.stack()[0][3]) + " La session de connexion n'est pas valide")
return False, "La session de connexion n'est pas valide"
return "Err_Connexion", "La session de connexion n'est pas valide"
# Recuperation du recid du user
user_recid = mycommon.get_user_recid_from_token(token_value)
@ -1925,7 +1925,7 @@ def IsUserTokenValide(diction):
tmp = coll_name_token.count_documents(myquery)
if (tmp <= 0):
mycommon.myprint(str(inspect.stack()[0][3]) + " Aucun resultat trouvé pour " + str(myquery))
return False, "La session de connexion n'est pas valide"
return "Err_Connexion", "La session de connexion n'est pas valide"
elif( myaccounttype == "2"):
# Il s'agit d'un compte pro (partenaire)
@ -1937,7 +1937,7 @@ def IsUserTokenValide(diction):
tmp = coll_name_token.count_documents(myquery)
if (tmp <= 0):
mycommon.myprint(str(inspect.stack()[0][3]) + " Aucun resultat trouvé pour " + str(myquery))
return False, "La session de connexion n'est pas valide"
return "Err_Connexion", "La session de connexion n'est pas valide"
return True, "Le token est valdie"

13
main.py
View File

@ -3014,6 +3014,19 @@ def Get_Valide_Code_Promo():
localStatus, message = code_promo_mgt.Get_Valide_Code_Promo(payload)
return jsonify(status=localStatus, message=message)
"""
Cette API verifie la validité d'un token partenaire
"""
@app.route('/myclass/api/check_partner_token_validity_v2/', methods=['POST','GET'])
@crossdomain(origin='*')
def check_partner_token_validity_v2():
# On recupere le corps (payload) de la requete
payload = mycommon.strip_dictionary (request.form.to_dict())
print(" ### check_partner_token_validity_v2 : payload = ",payload)
localStatus = mycommon.check_partner_token_validity_v2(payload)
return jsonify(status=localStatus)
"""
Cette API retourne tous les codes promo, peut importe la validité
"""

View File

@ -1182,7 +1182,7 @@ def UpgradetoPro(diction):
if retval is False :
mycommon.myprint(str(inspect.stack()[0][3])+" - La session de connexion n'est pas valide")
return False, "La session de connexion n'est pas valide"
return "Err_Connexion", "La session de connexion n'est pas valide"
# Recuperation du recid de l'utilisateur
user_recid = mycommon.get_user_recid_from_token(token)

View File

@ -274,6 +274,36 @@ def check_partner_token_validity(email="", token=""):
def check_partner_token_validity_v2(diction):
try :
token = ""
if ("token" in diction.keys()):
if diction['token']:
token = diction['token']
else:
myprint("La session de connexion n'est pas valide")
return False
coll_token = MYSY_GV.dbname['partner_token']
local_qry = {'locked':'0', 'valide': '1', 'token':str(token)}
tmp_count = MYSY_GV.dbname['partner_token'].count_documents(local_qry)
#tmp_count = coll_token.find({ 'token': str(token), 'locked':'0', 'valide': '1'}).count()
if (tmp_count <= 0):
myprint("La session de connexion n'est pas valide")
return False
return True
except Exception as e:
exc_type, exc_obj, exc_tb = sys.exc_info()
myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
return False
"""
Cette fonction retour le stripe_account_id
"""

View File

@ -211,7 +211,7 @@ def get_all_class(diction):
if retval is False:
mycommon.myprint(str(inspect.stack()[0][3]) + " - La session de connexion n'est pas valide")
return False, "La session de connexion n'est pas valide"
return "Err_Connexion", "La session de connexion n'est pas valide"
# Recuperation du recid de l'utilisateur
user_recid = mycommon.get_parnter_recid_from_token(token)
@ -559,7 +559,7 @@ def recherche_text_simple(diction):
if retval is False :
mycommon.myprint(str(inspect.stack()[0][3])+" - La session de connexion n'est pas valide")
return False, "La session de connexion n'est pas valide"
return "Err_Connexion", "La session de connexion n'est pas valide"
# Recuperation du recid de l'utilisateur
user_recid = mycommon.get_user_recid_from_token(token)
@ -573,7 +573,7 @@ def recherche_text_simple(diction):
if retval is False:
mycommon.myprint(str(inspect.stack()[0][3]) + " - La session de connexion n'est pas valide")
return False, "La session de connexion n'est pas valide"
return "Err_Connexion", "La session de connexion n'est pas valide"
# Recuperation du recid de l'utilisateur
user_recid = mycommon.get_parnter_recid_from_token(token)