22/02/23 20h

master
cherif 2023-02-22 20:41:06 +01:00
parent 4bc04a0fd5
commit 7c49d6f3d3
7 changed files with 4255 additions and 32 deletions

View File

@ -1,21 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="1122d9e2-679f-46d6-8c4f-97e9ae4041b5" name="Changes" comment="17/02/23 - 14h">
<change afterPath="$PROJECT_DIR$/business_prices.py" afterDir="false" />
<list default="true" id="1122d9e2-679f-46d6-8c4f-97e9ae4041b5" name="Changes" comment="20/02/23 - 11h">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Ela_Spacy.py" beforeDir="false" afterPath="$PROJECT_DIR$/Ela_Spacy.py" 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$/Template/Mysy_attestion_modele2_tpl.html" beforeDir="false" afterPath="$PROJECT_DIR$/Template/Mysy_attestion_modele2_tpl.html" afterDir="false" />
<change beforePath="$PROJECT_DIR$/business_prices.py" beforeDir="false" afterPath="$PROJECT_DIR$/business_prices.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_index_bdd_classes.py" beforeDir="false" afterPath="$PROJECT_DIR$/ela_index_bdd_classes.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$/email_inscription_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/email_inscription_mgt.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$/tools_cherif/tools_cherif.py" beforeDir="false" afterPath="$PROJECT_DIR$/tools_cherif/tools_cherif.py" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -319,7 +312,14 @@
<option name="project" value="LOCAL" />
<updated>1676639333755</updated>
</task>
<option name="localTasksCounter" value="35" />
<task id="LOCAL-00035" summary="20/02/23 - 11h">
<created>1676888825283</created>
<option name="number" value="00035" />
<option name="presentableId" value="LOCAL-00035" />
<option name="project" value="LOCAL" />
<updated>1676888825283</updated>
</task>
<option name="localTasksCounter" value="36" />
<servers />
</component>
<component name="Vcs.Log.Tabs.Properties">
@ -334,7 +334,6 @@
</option>
</component>
<component name="VcsManagerConfiguration">
<MESSAGE value="16/12/2022 - 22h00" />
<MESSAGE value="20/12/22 - 11h30" />
<MESSAGE value="20/12/22 - 15h30" />
<MESSAGE value="24/12/2022 - 15h00" />
@ -359,7 +358,8 @@
<MESSAGE value="14/02/23 - 21h" />
<MESSAGE value="16/02/23 - 22h" />
<MESSAGE value="17/02/23 - 14h" />
<option name="LAST_COMMIT_MESSAGE" value="17/02/23 - 14h" />
<MESSAGE value="20/02/23 - 11h" />
<option name="LAST_COMMIT_MESSAGE" value="20/02/23 - 11h" />
</component>
<component name="XDebuggerManager">
<breakpoint-manager>

File diff suppressed because it is too large Load Diff

View File

@ -82,28 +82,40 @@ def add_business_price(diction):
date_du = str(diction['date_du']).strip()[0:10]
date_au = str(diction['date_au']).strip()[0:10]
is_date_du = mycommon.CheckisDate(date_du)
is_date_au = mycommon.CheckisDate(date_au)
if (is_date_du is False or is_date_au is False):
mycommon.myprint(
str(inspect.stack()[0][
3]) + " - Impossible de créer le prix, Les dates sont incorrectes ")
return False, " Impossible de créer le prix, Les dates sont incorrectes"
3]) + " - Impossible de créer le prix, Les dates sont incorrectes. Le format attendu est jj/mm/aaaa ")
return False, " Impossible de créer le prix, Les dates sont incorrectes. Le format attendu est jj/mm/aaaa"
if (datetime.strptime(str(date_du), '%d/%m/%Y') > datetime.strptime(
str(date_au), '%d/%m/%Y')):
mycommon.myprint(
str(inspect.stack()[0][
3]) + " - Impossible de créer le prix. La date debut est postérieur à la date de fin " )
return False, " Impossible de créer le prix. La date debut est postérieur à la date de fin "
mydata['date_du'] = date_du
mydata['date_au'] = date_au
client_recid = str(diction['client_recid']).strip()
local_status = mycommon.get_user_data_from_recid(client_recid)
local_status, local_val = mycommon.get_partner_data_from_recid(client_recid)
if(local_status is False ):
mycommon.myprint(
str(inspect.stack()[0][
3]) + " - Impossible de créer le prix, Le client n'est pas valide ")
return False, " Impossible de créer le prix, Le client n'est pas valide "
mydata['client_recid'] = client_recid
mydata['client_nom'] = local_val['nom']
mydata['valide'] = "1"
mydata['date_update'] = datetime.now().strftime("%d/%m/%Y")
@ -221,7 +233,7 @@ def delete_business_price(diction):
# Ici on doit mettre tous les champs possible (obligatoire ou non) de la BDD dans la liste
# field_list.
'''
field_list = ['token', 'price_id', 'discount', 'date_du', 'date_au']
field_list = ['token', 'price_id', ]
incom_keys = diction.keys()
for val in incom_keys:
@ -336,3 +348,255 @@ def recherche_business_price(diction):
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 un prix "
"""
Recuperation des prix client d'un partneaire
"""
def get_cust_prices_by_partner(diction):
try:
field_list = ['token',]
incom_keys = diction.keys()
for val in incom_keys:
if val not in field_list:
mycommon.myprint(str(inspect.stack()[0][
3]) + " Impossible de recuperer les prix client, Le champ '" + val + "' n'existe pas ")
return False, " Impossible de recuperer les prix client, Le champ '" + val + "' n'existe pas"
'''
Une fois qu'on a controlé que toutes les clés mise dans l'API sont correcte. etape precedente,
On controle que les champs obligatoires sont presents dans la liste
'''
field_list_obligatoire = ['token']
for val in field_list_obligatoire:
if val not in diction:
mycommon.myprint(
str(inspect.stack()[0][3]) + " - Impossible de recuperer les prix clients, La valeur '" + val + "' n'est pas presente dans liste")
return False, " Impossible de recuperer les prix clients, La valeur '" + val + "' n'est pas presente dans liste"
# recuperation des paramettre
my_token = ""
partner_recid = ""
if ("token" in diction.keys()):
if diction['token']:
my_token = diction['token']
partner_recid = ""
# Verification de la validité du token/mail dans le cas des user en mode connecté
if (len(str(my_token)) > 0):
retval = mycommon.check_partner_token_validity("", my_token)
if retval is False:
mycommon.myprint(str(inspect.stack()[0][3]) + " - Le token n'est pas valide")
return False, " Impossible de recuperer les factures"
# Recuperation du recid de l'utilisateur
partner_recid = mycommon.get_parnter_recid_from_token(my_token)
if partner_recid is False:
mycommon.myprint(str(inspect.stack()[0][3]) + " - Impossible de recuperer le token du partenaire")
return False, " Impossible de recuperer le token du partenaire"
if (len(str(my_token)) <= 0):
mycommon.myprint(str(inspect.stack()[0][3]) + " - Le token est vide")
return False, " Impossible de recuperer les factures"
RetObject = []
coll_facture = MYSY_GV.dbname['business_prices']
for retVal in coll_facture.find({'partner_recid':partner_recid, 'valide': '1'},
)\
.sort([("date_update", pymongo.DESCENDING), ]):
user = retVal
RetObject.append(mycommon.JSONEncoder().encode(user))
print(" liste prix du client = "+str(RetObject))
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) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
return False, "Impossible de recuperer les factures"
"""
Cette fonction retour la liste de clients rattaché à un fournisseur
collection 'fsseur_client_link'
"""
def get_linked_customer_to_partner(diction):
try:
field_list = ['token',]
incom_keys = diction.keys()
for val in incom_keys:
if val not in field_list:
mycommon.myprint(str(inspect.stack()[0][
3]) + " Impossible de recuperer les prix client, Le champ '" + val + "' n'existe pas ")
return False, " Impossible de recuperer les prix client, Le champ '" + val + "' n'existe pas"
'''
Une fois qu'on a controlé que toutes les clés mise dans l'API sont correcte. etape precedente,
On controle que les champs obligatoires sont presents dans la liste
'''
field_list_obligatoire = ['token']
for val in field_list_obligatoire:
if val not in diction:
mycommon.myprint(
str(inspect.stack()[0][3]) + " - Impossible de recuperer les clients, La valeur '" + val + "' n'est pas presente dans liste")
return False, " Impossible de recuperer les clients, La valeur '" + val + "' n'est pas presente dans liste"
# recuperation des paramettre
my_token = ""
partner_recid = ""
if ("token" in diction.keys()):
if diction['token']:
my_token = diction['token']
print(" ### my_token = ", my_token)
partner_recid = ""
# Verification de la validité du token/mail dans le cas des user en mode connecté
if (len(str(my_token)) > 0):
retval = mycommon.check_partner_token_validity("", my_token)
if retval is False:
mycommon.myprint(str(inspect.stack()[0][3]) + " - Le token n'est pas valide")
return False, " Impossible de recuperer les factures"
# Recuperation du recid de l'utilisateur
partner_recid = mycommon.get_parnter_recid_from_token(my_token)
if partner_recid is False:
mycommon.myprint(str(inspect.stack()[0][3]) + " - Impossible de recuperer le token du partenaire")
return False, " Impossible de recuperer le token du partenaire"
if (len(str(my_token)) <= 0):
mycommon.myprint(str(inspect.stack()[0][3]) + " - Le token est vide")
return False, " Impossible de recuperer les factures"
RetObject = []
coll_facture = MYSY_GV.dbname['fsseur_client_link']
pipe = [
{ '$lookup':
{
'from': 'partnair_account',
'localField': 'client_recid',
'foreignField': 'recid',
'as': 'partnair_account'
}
}
]
for retVal in coll_facture.aggregate(pipe):
client = retVal['partnair_account']
val = {}
val['nom'] = client[0]['nom']
val['recid'] = client[0]['recid']
RetObject.append(mycommon.JSONEncoder().encode(val))
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) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
return False, "Impossible de recuperer les factures"
"""
Cette fonction retourne un ligne de prix spécifique
"""
def get_cust_specific_prices_by_partner(diction):
try:
field_list = ['token', 'price_line_id']
incom_keys = diction.keys()
for val in incom_keys:
if val not in field_list:
mycommon.myprint(str(inspect.stack()[0][
3]) + " Impossible de recuperer les prix client, Le champ '" + val + "' n'existe pas ")
return False, " Impossible de recuperer les prix client, Le champ '" + val + "' n'existe pas"
'''
Une fois qu'on a controlé que toutes les clés mise dans l'API sont correcte. etape precedente,
On controle que les champs obligatoires sont presents dans la liste
'''
field_list_obligatoire = ['token', 'price_line_id']
for val in field_list_obligatoire:
if val not in diction:
mycommon.myprint(
str(inspect.stack()[0][3]) + " - Impossible de recuperer les prix clients, La valeur '" + val + "' n'est pas presente dans liste")
return False, " Impossible de recuperer les prix clients, La valeur '" + val + "' n'est pas presente dans liste"
# recuperation des paramettre
my_token = ""
partner_recid = ""
if ("token" in diction.keys()):
if diction['token']:
my_token = diction['token']
partner_recid = ""
# Verification de la validité du token/mail dans le cas des user en mode connecté
if (len(str(my_token)) > 0):
retval = mycommon.check_partner_token_validity("", my_token)
if retval is False:
mycommon.myprint(str(inspect.stack()[0][3]) + " - Le token n'est pas valide")
return False, " Impossible de recuperer les factures"
# Recuperation du recid de l'utilisateur
partner_recid = mycommon.get_parnter_recid_from_token(my_token)
if partner_recid is False:
mycommon.myprint(str(inspect.stack()[0][3]) + " - Impossible de recuperer le token du partenaire")
return False, " Impossible de recuperer le token du partenaire"
if (len(str(my_token)) <= 0):
mycommon.myprint(str(inspect.stack()[0][3]) + " - Le token est vide")
return False, " Impossible de recuperer les factures"
"""
pipe = [
{ '$match': {'_id':ObjectId(diction['price_line_id']), 'valide': '1' } },
{ '$lookup':
{
'from': 'partnair_account',
'localField': 'client_recid',
'foreignField': 'recid',
'as': 'partnair_account'
}
}
]
for retVal in coll_facture.aggregate(pipe):
new_retVal = {}
new_retVal['nom'] = retVal['partnair_account']['nom']
new_retVal['discount'] = retVal['discount']
new_retVal['date_du'] = retVal['date_du']
new_retVal['date_au'] = retVal['date_au']
new_retVal['discount'] = retVal['discount']
"""
RetObject = []
coll_facture = MYSY_GV.dbname['business_prices']
retVal = coll_facture.find_one({'partner_recid':partner_recid, 'valide': '1',
'_id':ObjectId(diction['price_line_id'])}, )
print(" ### retVal ", retVal)
RetObject.append(mycommon.JSONEncoder().encode(retVal))
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) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
return False, "Impossible de recuperer les factures"

View File

@ -1,4 +1,7 @@
,index,mots,occurence,moyenne,id_formation,source_field
0,0,aromatherapie,1,0.33,AR,title
1,1,integrative,1,0.33,AR,title
2,2,praticien,1,0.33,AR,title
0,0,orthographe,1,0.17,LPP_0004,title
1,1,niveau,1,0.17,LPP_0004,title
2,2,heure,1,0.17,LPP_0004,title
3,3,formule,1,0.17,LPP_0004,title
4,4,learning,1,0.17,LPP_0004,title
5,5,tutorat,1,0.17,LPP_0004,title

1 index mots occurence moyenne id_formation source_field
2 0 0 aromatherapie orthographe 1 0.33 0.17 AR LPP_0004 title
3 1 1 integrative niveau 1 0.33 0.17 AR LPP_0004 title
4 2 2 praticien heure 1 0.33 0.17 AR LPP_0004 title
5 3 3 formule 1 0.17 LPP_0004 title
6 4 4 learning 1 0.17 LPP_0004 title
7 5 5 tutorat 1 0.17 LPP_0004 title

View File

@ -1,4 +1,7 @@
mots occurence moyenne id_formation source_field
0 aromatherapie 1 0.33 AR title
1 integrative 1 0.33 AR title
2 praticien 1 0.33 AR title
mots occurence moyenne id_formation source_field
0 orthographe 1 0.17 LPP_0004 title
1 niveau 1 0.17 LPP_0004 title
2 heure 1 0.17 LPP_0004 title
3 formule 1 0.17 LPP_0004 title
4 learning 1 0.17 LPP_0004 title
5 tutorat 1 0.17 LPP_0004 title

39
main.py
View File

@ -2498,6 +2498,45 @@ def delete_business_price():
localStatus, message = business_prices.delete_business_price(payload)
return jsonify(status=localStatus, message=message )
"""
Cette API recupere liste de prix client d'un partenaire
"""
@app.route('/myclass/api/get_cust_prices_by_partner/', methods=['POST','GET'])
@crossdomain(origin='*')
def get_cust_prices_by_partner():
# On recupere le corps (payload) de la requete
payload = request.form.to_dict()
print(" ### get_cust_prices_by_partner : payload = ",payload)
localStatus, message = business_prices.get_cust_prices_by_partner(payload)
return jsonify(status=localStatus, message=message )
"""
Cette API retourne une ligne de prix donnée
"""
@app.route('/myclass/api/get_cust_specific_prices_by_partner/', methods=['POST','GET'])
@crossdomain(origin='*')
def get_cust_specific_prices_by_partner():
# On recupere le corps (payload) de la requete
payload = request.form.to_dict()
print(" ### get_cust_specific_prices_by_partner : payload = ",payload)
localStatus, message = business_prices.get_cust_specific_prices_by_partner(payload)
return jsonify(status=localStatus, message=message )
"""
Cette API retourne la liste des client rattaché à partenaire
"""
@app.route('/myclass/api/get_linked_customer_to_partner/', methods=['POST','GET'])
@crossdomain(origin='*')
def get_linked_customer_to_partner():
# On recupere le corps (payload) de la requete
payload = request.form.to_dict()
print(" ### get_linked_customer_to_partner : payload = ",payload)
localStatus, message = business_prices.get_linked_customer_to_partner(payload)
return jsonify(status=localStatus, message=message )
"""
Cette API recherche un business price

View File

@ -297,24 +297,25 @@ def get_user_recid_from_token(token = ""):
return False
"""
Cette fonction retourn les données d'un user en partant du recid.
Cette fonction retourne les données d'un user en partant du recid.
return false si le recid est faux ou que le compte utilisateur n'est pas actif
"""
def get_user_data_from_recid(user_recid = ""):
def get_partner_data_from_recid(user_recid = ""):
try :
if len(str(user_recid)) <= 0 :
myprint(" Le user_recid est vide")
return False
myprint(" Le partner_recid est vide")
return False, ""
coll_token = MYSY_GV.dbname['user_account']
coll_token = MYSY_GV.dbname['partner_token']
# print(" myquery pr demo_account = " + str(myquery))
tmp_count = coll_token.count_documents({'recid': str(user_recid), 'active': '1'})
tmp_count = coll_token.count_documents({'recid': str(user_recid), 'valide': '1', 'locked':'0'})
if (tmp_count <= 0):
return False
return False, ""
tmp_val = coll_token.find_one({'recid': str(user_recid), 'active': '1'})
coll_token = MYSY_GV.dbname['partnair_account']
tmp_val = coll_token.find_one({'recid': str(user_recid), 'active': '1', 'locked':'0'})
return tmp_val
return True, tmp_val
except Exception as e:
exc_type, exc_obj, exc_tb = sys.exc_info()