22/07/2023 - 17h
parent
625e732fe8
commit
17196e6408
|
@ -1,10 +1,13 @@
|
|||
<?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="16/07/23 - 21h">
|
||||
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="16/07/23 - 22h">
|
||||
<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$/appel_offre.py" beforeDir="false" afterPath="$PROJECT_DIR$/appel_offre.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$/prj_common.py" beforeDir="false" afterPath="$PROJECT_DIR$/prj_common.py" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
|
@ -390,7 +393,14 @@
|
|||
<option name="project" value="LOCAL" />
|
||||
<updated>1689534101885</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="47" />
|
||||
<task id="LOCAL-00047" summary="16/07/23 - 22h">
|
||||
<created>1689542189593</created>
|
||||
<option name="number" value="00047" />
|
||||
<option name="presentableId" value="LOCAL-00047" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1689542189593</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="48" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="Vcs.Log.Tabs.Properties">
|
||||
|
@ -405,7 +415,6 @@
|
|||
</option>
|
||||
</component>
|
||||
<component name="VcsManagerConfiguration">
|
||||
<MESSAGE value="15/05/23 - 23h" />
|
||||
<MESSAGE value="21/05/23 - 10h" />
|
||||
<MESSAGE value="21/05/23 - 22h" />
|
||||
<MESSAGE value="22/05/23 - 23h" />
|
||||
|
@ -430,6 +439,7 @@
|
|||
<MESSAGE value="10/07/23 - 22h" />
|
||||
<MESSAGE value="12/07/23 - 21h" />
|
||||
<MESSAGE value="16/07/23 - 21h" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="16/07/23 - 21h" />
|
||||
<MESSAGE value="16/07/23 - 22h" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="16/07/23 - 22h" />
|
||||
</component>
|
||||
</project>
|
9038
Log/log_file.log
9038
Log/log_file.log
File diff suppressed because it is too large
Load Diff
|
@ -209,7 +209,7 @@ def Add_Appel_Offre(diction):
|
|||
if (tmp_count > 0):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " - Cet appel d'offre est deja enregistré : external_code = ", str(external_code))
|
||||
3]) + " - Cet appel d'offre est deja enregistré : external_code = "+ str(external_code))
|
||||
|
||||
return False, " - Cet appel d'offre est deja enregistré "
|
||||
|
||||
|
@ -615,7 +615,7 @@ def Update_Appel_Offre(diction):
|
|||
if ("_id" not in result.keys()):
|
||||
mycommon.myprint(
|
||||
" Impossible de mettre à jour l'appel d'offre: external_code = " + str(external_code))
|
||||
return False, " Impossible de mettre à jour l'appel d'offre "
|
||||
return False, " Impossible de mettre à jour l'appel d'offre "
|
||||
|
||||
return True, " L'appel d'offre a été correctement mise à jour"
|
||||
|
||||
|
@ -692,7 +692,7 @@ def Get_Given_Appel_Offre(diction):
|
|||
|
||||
print(" #### data_cle 01= " + str(data_cle))
|
||||
|
||||
for retval in MYSY_GV.dbname[''].find(data_cle):
|
||||
for retval in MYSY_GV.dbname['appel_offre'].find(data_cle):
|
||||
user = retval
|
||||
user['id'] = str(val_tmp)
|
||||
val_tmp = val_tmp + 1
|
||||
|
@ -785,7 +785,7 @@ def Get_List_Appel_Offre(diction):
|
|||
|
||||
print(" #### data_cle 01= " + str(data_cle))
|
||||
|
||||
for retval in MYSY_GV.dbname[''].find(data_cle):
|
||||
for retval in MYSY_GV.dbname['appel_offre'].find(data_cle):
|
||||
user = retval
|
||||
user['id'] = str(val_tmp)
|
||||
val_tmp = val_tmp + 1
|
||||
|
|
55
main.py
55
main.py
|
@ -3249,6 +3249,61 @@ def Add_Partner_Client():
|
|||
return jsonify(status=localStatus, message=message)
|
||||
|
||||
|
||||
"""
|
||||
API de mise à jour du client d'un partner
|
||||
"""
|
||||
@app.route('/myclass/api/Update_Partner_Client/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Update_Partner_Client():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Update_Partner_Client : payload = ",payload)
|
||||
localStatus, message = partner_client.Update_Partner_Client(payload)
|
||||
return jsonify(status=localStatus, message=message)
|
||||
|
||||
|
||||
|
||||
"""
|
||||
API de recuperation de la liste des clients d'un partner
|
||||
"""
|
||||
@app.route('/myclass/api/Get_Partner_List_Partner_Client/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Get_Partner_List_Partner_Client():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Get_Partner_List_Partner_Client : payload = ",payload)
|
||||
localStatus, message = partner_client.Get_Partner_List_Partner_Client(payload)
|
||||
return jsonify(status=localStatus, message=message)
|
||||
|
||||
"""
|
||||
API de recuperation d'un client donné d'un partner
|
||||
"""
|
||||
@app.route('/myclass/api/Get_Given_Partner_Client/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Get_Given_Partner_Client():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Get_Given_Partner_Client : payload = ",payload)
|
||||
localStatus, message = partner_client.Get_Given_Partner_Client(payload)
|
||||
return jsonify(status=localStatus, message=message)
|
||||
|
||||
|
||||
|
||||
|
||||
"""
|
||||
API qui permet de modifier un contact donnée (nested list) d'un client de partenai
|
||||
"""
|
||||
@app.route('/myclass/api/Update_Partner_Client_Contact/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Update_Partner_Client_Contact():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Update_Partner_Client_Contact : payload = ",payload)
|
||||
localStatus, message = partner_client.Update_Partner_Client_Contact(payload)
|
||||
return jsonify(status=localStatus, message=message)
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
print(" debut api")
|
||||
|
|
|
@ -35,7 +35,12 @@ def Add_Partner_Client(diction):
|
|||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', "raison_sociale", "nom", "siret", "tva", "email",
|
||||
"telephone", "website", "comment", "address", "invoice_address", "list_contact", ]
|
||||
"telephone", "website", "comment", "address", "invoice_address", "list_contact",
|
||||
'adr_adresse', 'adr_code_postal', 'adr_ville', 'adr_pays',
|
||||
'invoice_email', 'invoice_nom', 'invoice_siret',
|
||||
'invoice_tva', 'invoice_adresse', 'invoice_ville',
|
||||
'invoice_code_postal', 'invoice_pays'
|
||||
]
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
if val not in field_list:
|
||||
|
@ -91,19 +96,18 @@ def Add_Partner_Client(diction):
|
|||
tmp_count = MYSY_GV.dbname['partner_client'].count_documents(qry)
|
||||
if (tmp_count > 0):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " - Il existe déjà un client qui porte le même nom = ", str(diction['nom']))
|
||||
str(inspect.stack()[0][3]) + " - Il existe déjà un client qui porte le même nom = "+str(diction['nom']))
|
||||
|
||||
return False, " - Il existe déjà un client qui porte le même nom "
|
||||
return False, " - Vous déjà un client qui porte le même nom "
|
||||
|
||||
tmp_count = MYSY_GV.dbname['partner_client'].count_documents({'email': str(diction['email']),
|
||||
'valide': '1', 'partner_recid': my_partner['recid']})
|
||||
if (tmp_count > 0):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " - Il existe déjà un client qui porte le même email principal = ", str(diction['email']))
|
||||
3]) + " - Il existe déjà un client qui porte le même email principal = " +str(diction['email']))
|
||||
|
||||
return False, " - Il existe déjà un client qui porte le même email principal "
|
||||
return False, " - Vous avez déjà un client qui a le même email principal "
|
||||
|
||||
|
||||
|
||||
|
@ -131,6 +135,30 @@ def Add_Partner_Client(diction):
|
|||
siret = diction['siret']
|
||||
data['siret'] = diction['siret']
|
||||
|
||||
adr_adresse = ""
|
||||
if ("adr_adresse" in diction.keys()):
|
||||
if diction['adr_adresse']:
|
||||
adr_adresse = diction['adr_adresse']
|
||||
data['adr_adresse'] = diction['adr_adresse']
|
||||
|
||||
adr_code_postal = ""
|
||||
if ("adr_code_postal" in diction.keys()):
|
||||
if diction['adr_code_postal']:
|
||||
adr_code_postal = diction['adr_code_postal']
|
||||
data['adr_code_postal'] = diction['adr_code_postal']
|
||||
|
||||
adr_ville = ""
|
||||
if ("adr_ville" in diction.keys()):
|
||||
if diction['adr_ville']:
|
||||
adr_ville = diction['adr_ville']
|
||||
data['adr_ville'] = diction['adr_ville']
|
||||
|
||||
adr_pays = ""
|
||||
if ("adr_pays" in diction.keys()):
|
||||
if diction['adr_pays']:
|
||||
adr_pays = diction['siret']
|
||||
data['adr_pays'] = diction['adr_pays']
|
||||
|
||||
tva = ""
|
||||
if ("tva" in diction.keys()):
|
||||
if diction['tva']:
|
||||
|
@ -142,6 +170,20 @@ def Add_Partner_Client(diction):
|
|||
if diction['email']:
|
||||
email = diction['email']
|
||||
data['email'] = diction['email']
|
||||
if( mycommon.isEmailValide(email) is False):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " - L'adresse email "+str(email)+" n'est pas valide")
|
||||
|
||||
return False, " - - L'adresse email "+str(email)+" n'est pas valide "
|
||||
|
||||
|
||||
telephone = ""
|
||||
if ("telephone" in diction.keys()):
|
||||
if diction['telephone']:
|
||||
telephone = diction['telephone']
|
||||
data['telephone'] = diction['telephone']
|
||||
|
||||
|
||||
website = ""
|
||||
if ("website" in diction.keys()):
|
||||
|
@ -155,22 +197,84 @@ def Add_Partner_Client(diction):
|
|||
comment = diction['comment']
|
||||
data['comment'] = diction['comment']
|
||||
|
||||
address = {}
|
||||
invoice_email = ""
|
||||
if ("invoice_email" in diction.keys()):
|
||||
if diction['invoice_email']:
|
||||
email = diction['invoice_email']
|
||||
data['invoice_email'] = diction['invoice_email']
|
||||
if (mycommon.isEmailValide(invoice_email) is False):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " - L'adresse email de facturation " + str(invoice_email) + " n'est pas valide")
|
||||
|
||||
return False, " - L'adresse email de facturation " + str(invoice_email) + " n'est pas valide "
|
||||
|
||||
invoice_nom = ""
|
||||
if ("invoice_nom" in diction.keys()):
|
||||
if diction['invoice_nom']:
|
||||
invoice_nom = diction['invoice_nom']
|
||||
data['invoice_nom'] = diction['invoice_nom']
|
||||
|
||||
invoice_siret = ""
|
||||
if ("invoice_siret" in diction.keys()):
|
||||
if diction['invoice_siret']:
|
||||
invoice_siret = diction['invoice_siret']
|
||||
data['invoice_siret'] = diction['invoice_siret']
|
||||
|
||||
invoice_tva = ""
|
||||
if ("invoice_tva" in diction.keys()):
|
||||
if diction['invoice_tva']:
|
||||
invoice_tva = diction['invoice_tva']
|
||||
data['invoice_tva'] = diction['invoice_tva']
|
||||
|
||||
invoice_adresse = ""
|
||||
if ("invoice_adresse" in diction.keys()):
|
||||
if diction['invoice_adresse']:
|
||||
invoice_adresse = diction['invoice_adresse']
|
||||
data['invoice_adresse'] = diction['invoice_adresse']
|
||||
|
||||
invoice_ville = ""
|
||||
if ("invoice_ville" in diction.keys()):
|
||||
if diction['invoice_ville']:
|
||||
invoice_ville = diction['invoice_ville']
|
||||
data['invoice_ville'] = diction['invoice_ville']
|
||||
|
||||
invoice_code_postal = ""
|
||||
if ("invoice_code_postal" in diction.keys()):
|
||||
if diction['invoice_code_postal']:
|
||||
invoice_code_postal = diction['invoice_code_postal']
|
||||
data['invoice_code_postal'] = diction['invoice_code_postal']
|
||||
|
||||
invoice_pays = ""
|
||||
if ("invoice_pays" in diction.keys()):
|
||||
if diction['invoice_pays']:
|
||||
invoice_pays = diction['invoice_pays']
|
||||
data['invoice_pays'] = diction['invoice_pays']
|
||||
|
||||
list_adress = []
|
||||
line = 0
|
||||
if ("address" in diction.keys()):
|
||||
if diction['address']:
|
||||
address = ast.literal_eval(diction['address'])
|
||||
data['address'] = ast.literal_eval(diction['address'])
|
||||
""""
|
||||
/!\ : l'adresse etant directement enregistrée sur le client, alors verification que le ligne "adresse" contient bien les champs :
|
||||
- adresse, code postal, ville, pays
|
||||
"""
|
||||
list_adress = ast.literal_eval(diction['address'])
|
||||
data['address'] = list_adress
|
||||
for adress_val in list_adress :
|
||||
print(" ### adress_val = ", adress_val)
|
||||
address = adress_val
|
||||
data['address'][line]['recid'] = mycommon.create_user_recid()
|
||||
line = line + 1
|
||||
|
||||
"""
|
||||
/!\ : l'adresse etant directement enregistrée sur le client, alors verification que le ligne "adresse" contient bien les champs :
|
||||
- adresse, code postal, ville, pays
|
||||
"""
|
||||
|
||||
adresse_field_list_obligatoire = ['adresse', "code_postal", "ville", "pays", ]
|
||||
for val in adresse_field_list_obligatoire:
|
||||
if val not in address.keys():
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " - Le champ '" + val + "' est obligatoire dans l'adresse")
|
||||
return False, " Le champ '" + val + "' est obligatoire dans l'adresse",
|
||||
|
||||
adresse_field_list_obligatoire = ['adresse', "code_postal", "ville", "pays", ]
|
||||
for val in adresse_field_list_obligatoire:
|
||||
if val not in address.keys():
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " - Le champ '" + val + "' est obligatoire dans l'adresse")
|
||||
return False, " Le champ '" + val + "' est obligatoire dans l'adresse",
|
||||
|
||||
|
||||
invoice_address = {}
|
||||
|
@ -220,8 +324,121 @@ def Add_Partner_Client(diction):
|
|||
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - Line : " + str(exc_tb.tb_lineno))
|
||||
return False, " Impossible d'ajouter le client "
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Mise à jour d'un client
|
||||
Mise à jour contact d'un client de partner
|
||||
"""
|
||||
def Update_Partner_Client_Contact(diction):
|
||||
try:
|
||||
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', "partner_client_contact_recid", "adresse", "ville", "code_postal", "pays", "email", "telephone" ]
|
||||
|
||||
"""
|
||||
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"
|
||||
|
||||
partner_recid = mycommon.get_parnter_recid_from_token(token)
|
||||
if (partner_recid is False):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " - partner_recid est KO. Les données de connexion sont incorrectes ")
|
||||
return False, " Vous n'etes pas autorisé à utiliser cette API "
|
||||
|
||||
# Recuperation des données du partenaire
|
||||
local_status, my_partner = mycommon.get_partner_data_from_recid(partner_recid)
|
||||
if (local_status is False):
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - impossible de recuperer les données du partenaire")
|
||||
return False, str(inspect.stack()[0][3]) + " - impossible de recuperer les données du partenaire. "
|
||||
|
||||
data_update = {}
|
||||
|
||||
partner_client_contact_recid = ""
|
||||
if ("partner_client_contact_recid" in diction.keys()):
|
||||
partner_client_contact_recid = diction['partner_client_contact_recid']
|
||||
|
||||
adresse = ""
|
||||
if ("adresse" in diction.keys()):
|
||||
adresse = diction['adresse']
|
||||
data_update['partner_recid'] = my_partner['recid']
|
||||
data_update["address.$[elem].adresse"] = adresse
|
||||
|
||||
ville = ""
|
||||
if ("ville" in diction.keys()):
|
||||
ville = diction['ville']
|
||||
data_update["address.$[elem].ville"] = ville
|
||||
|
||||
code_postal = ""
|
||||
if ("code_postal" in diction.keys()):
|
||||
code_postal = diction['code_postal']
|
||||
data_update["address.$[elem].code_postal"] = code_postal
|
||||
|
||||
pays = ""
|
||||
if ("pays" in diction.keys()):
|
||||
pays = diction['pays']
|
||||
data_update["address.$[elem].pays"] = pays
|
||||
|
||||
email = ""
|
||||
if ("email" in diction.keys()):
|
||||
email = diction['email']
|
||||
data_update["address.$[elem].email"] = email
|
||||
if (mycommon.isEmailValide(email) is False):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " - L'adresse email " + str(email) + " n'est pas valide")
|
||||
|
||||
return False, " -L'adresse email " + str(email) + " n'est pas valide "
|
||||
|
||||
telephone = ""
|
||||
if ("telephone" in diction.keys()):
|
||||
telephone = diction['telephone']
|
||||
data_update["address.$[elem].telephone"] = telephone
|
||||
|
||||
|
||||
print(" #### data_update = ", data_update)
|
||||
print(" #### partner_recid = ", str(partner_recid))
|
||||
print(" #### elem.recid = ", str(partner_client_contact_recid))
|
||||
|
||||
result = MYSY_GV.dbname['partner_client'].update_one(
|
||||
{'partner_recid':str(partner_recid)},
|
||||
{ "$set": data_update},
|
||||
upsert=True,
|
||||
array_filters=[{"elem.recid": str(partner_client_contact_recid) }],
|
||||
)
|
||||
|
||||
|
||||
print("raw:", result.raw_result)
|
||||
print("acknowledged:", result.acknowledged)
|
||||
print("matched_count:", result.matched_count)
|
||||
|
||||
|
||||
return True, " Le contact du client a été correctement mis à jour"
|
||||
|
||||
except Exception as e:
|
||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - Line : " + str(exc_tb.tb_lineno))
|
||||
return False, " Impossible d'ajouter le client "
|
||||
|
||||
"""
|
||||
Mise à jour d'un client.
|
||||
La clé de mise à jour est : l'email et ou le nom
|
||||
|
||||
Donc pas de modification possible du mail et du nom
|
||||
"""
|
||||
def Update_Partner_Client(diction):
|
||||
try:
|
||||
|
@ -231,7 +448,11 @@ def Update_Partner_Client(diction):
|
|||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', "raison_sociale", "nom", "siret", "tva", "email",
|
||||
"telephone", "website", "comment", "address", "invoice_address", "list_contact", ]
|
||||
"telephone", "website", "comment", "address", "invoice_address", "list_contact",
|
||||
'adr_adresse', 'adr_code_postal', 'adr_ville', 'adr_pays',
|
||||
'invoice_email', 'invoice_nom', 'invoice_siret',
|
||||
'invoice_tva', 'invoice_adresse', 'invoice_ville',
|
||||
'invoice_code_postal', 'invoice_pays']
|
||||
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
|
@ -283,16 +504,22 @@ def Update_Partner_Client(diction):
|
|||
nom, ou la meme adresse email
|
||||
"""
|
||||
|
||||
qry = {'nom': str(diction['nom']), 'email': str(diction['email']),
|
||||
'valide': '1', 'partner_recid': str(my_partner['recid'])}
|
||||
qry_update = { "$or":[{'nom': str(diction['nom']), 'email': str(diction['email']),
|
||||
'valide': '1', 'partner_recid': str(my_partner['recid'])},
|
||||
|
||||
tmp_count = MYSY_GV.dbname['partner_client'].count_documents(qry)
|
||||
{'email': str(diction['email']), 'email': str(diction['email']),
|
||||
'valide': '1', 'partner_recid': str(my_partner['recid'])}
|
||||
]}
|
||||
|
||||
|
||||
print(" ### qry_update = ", qry_update)
|
||||
tmp_count = MYSY_GV.dbname['partner_client'].count_documents(qry_update)
|
||||
if (tmp_count <= 0):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " - Ce client n'existe pas: nom = ", str(diction['nom']))
|
||||
3]) + " - Ce client n'existe pas: nom = "+str(diction['nom']))
|
||||
|
||||
return False, " - Ce client n'existe pas "
|
||||
return False, " - Ce client n'existe pas, mise à jour impossible "
|
||||
|
||||
|
||||
|
||||
|
@ -313,22 +540,96 @@ def Update_Partner_Client(diction):
|
|||
nom = ""
|
||||
if ("nom" in diction.keys()):
|
||||
nom = diction['nom']
|
||||
data_update['nom'] = diction['nom']
|
||||
# data_update['nom'] = diction['nom'] - on ne modifie pas le nom
|
||||
|
||||
siret = ""
|
||||
if ("siret" in diction.keys()):
|
||||
siret = diction['siret']
|
||||
data_update['siret'] = diction['siret']
|
||||
|
||||
adr_adresse = ""
|
||||
if ("adr_adresse" in diction.keys()):
|
||||
adr_adresse = diction['adr_adresse']
|
||||
data_update['adr_adresse'] = diction['adr_adresse']
|
||||
|
||||
adr_code_postal = ""
|
||||
if ("adr_code_postal" in diction.keys()):
|
||||
adr_code_postal = diction['adr_code_postal']
|
||||
data_update['adr_code_postal'] = diction['adr_code_postal']
|
||||
|
||||
adr_ville = ""
|
||||
if ("adr_ville" in diction.keys()):
|
||||
adr_ville = diction['adr_ville']
|
||||
data_update['adr_ville'] = diction['adr_ville']
|
||||
|
||||
adr_pays = ""
|
||||
if ("adr_pays" in diction.keys()):
|
||||
adr_pays = diction['adr_pays']
|
||||
data_update['adr_pays'] = diction['adr_pays']
|
||||
|
||||
|
||||
|
||||
tva = ""
|
||||
if ("tva" in diction.keys()):
|
||||
tva = diction['tva']
|
||||
data_update['tva'] = diction['tva']
|
||||
|
||||
telephone = ""
|
||||
if ("telephone" in diction.keys()):
|
||||
telephone = diction['telephone']
|
||||
data_update['telephone'] = diction['telephone']
|
||||
|
||||
email = ""
|
||||
if ("email" in diction.keys()):
|
||||
email = diction['email']
|
||||
data_update['email'] = diction['email']
|
||||
# data_update['email'] = diction['email'] - on ne modifie pas le mail
|
||||
|
||||
invoice_email = ""
|
||||
if ("invoice_email" in diction.keys()):
|
||||
invoice_email = diction['invoice_email']
|
||||
data_update['invoice_email'] = diction['invoice_email']
|
||||
if (mycommon.isEmailValide(invoice_email) is False):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " - L'adresse email de facturation " + str(invoice_email) + " n'est pas valide")
|
||||
|
||||
return False, " - L'adresse email de facturation " + str(invoice_email) + " n'est pas valide "
|
||||
|
||||
invoice_nom = ""
|
||||
if ("invoice_nom" in diction.keys()):
|
||||
invoice_nom = diction['invoice_nom']
|
||||
data_update['invoice_nom'] = diction['invoice_nom']
|
||||
|
||||
invoice_siret = ""
|
||||
if ("invoice_siret" in diction.keys()):
|
||||
invoice_siret = diction['invoice_siret']
|
||||
data_update['invoice_siret'] = diction['invoice_siret']
|
||||
|
||||
invoice_tva = ""
|
||||
if ("invoice_tva" in diction.keys()):
|
||||
invoice_tva = diction['invoice_tva']
|
||||
data_update['invoice_tva'] = diction['invoice_tva']
|
||||
|
||||
invoice_adresse = ""
|
||||
if ("invoice_adresse" in diction.keys()):
|
||||
invoice_adresse = diction['invoice_adresse']
|
||||
data_update['invoice_adresse'] = diction['invoice_adresse']
|
||||
|
||||
invoice_ville = ""
|
||||
if ("invoice_ville" in diction.keys()):
|
||||
invoice_ville = diction['invoice_ville']
|
||||
data_update['invoice_ville'] = diction['invoice_ville']
|
||||
|
||||
invoice_code_postal = ""
|
||||
if ("invoice_code_postal" in diction.keys()):
|
||||
invoice_code_postal = diction['invoice_code_postal']
|
||||
data_update['invoice_code_postal'] = diction['invoice_code_postal']
|
||||
|
||||
invoice_pays = ""
|
||||
if ("invoice_pays" in diction.keys()):
|
||||
invoice_pays = diction['invoice_pays']
|
||||
data_update['invoice_pays'] = diction['invoice_pays']
|
||||
|
||||
|
||||
website = ""
|
||||
if ("website" in diction.keys()):
|
||||
|
@ -383,6 +684,27 @@ def Update_Partner_Client(diction):
|
|||
data_update['locked'] = '0'
|
||||
data_update['date_update'] = str(datetime.now())
|
||||
|
||||
"""
|
||||
Clés de mise à jour
|
||||
"""
|
||||
data_cle = {}
|
||||
data_cle['partner_recid'] = str(my_partner['recid'])
|
||||
data_cle['email'] = str(diction['email'])
|
||||
data_cle['nom'] = str(diction['nom'])
|
||||
data_cle['valide'] = "1"
|
||||
data_cle['locked'] = "0"
|
||||
|
||||
inserted_id = ""
|
||||
result = MYSY_GV.dbname['partner_client'].find_one_and_update(
|
||||
data_cle,
|
||||
{"$set": data_update},
|
||||
upsert=False,
|
||||
return_document=ReturnDocument.AFTER
|
||||
)
|
||||
if ("_id" not in result.keys()):
|
||||
mycommon.myprint(
|
||||
" Impossible de mettre à jour le client : email = " + str(diction['email']))
|
||||
return False, " Impossible de mettre à jour le client "
|
||||
|
||||
return True, " Le client a été correctement mise à jour"
|
||||
|
||||
|
@ -398,22 +720,149 @@ Recuperation d'une liste de client d'un partenaire
|
|||
|
||||
def Get_Partner_List_Partner_Client(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:
|
||||
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 recuperer les données de l'utilisateur ")
|
||||
return False, str(inspect.stack()[0][3]) + " - impossible de recuperer les données de l'utilisateur. "
|
||||
|
||||
"""
|
||||
Clés de mise à jour
|
||||
"""
|
||||
data_cle = {}
|
||||
data_cle['partner_recid'] = str(my_partner['recid'])
|
||||
data_cle['valide'] = "1"
|
||||
data_cle['locked'] = "0"
|
||||
|
||||
RetObject = []
|
||||
val_tmp = 1
|
||||
|
||||
for retval in MYSY_GV.dbname['partner_client'].find(data_cle):
|
||||
user = retval
|
||||
user['id'] = str(val_tmp)
|
||||
val_tmp = val_tmp + 1
|
||||
RetObject.append(mycommon.JSONEncoder().encode(user))
|
||||
|
||||
return True, RetObject
|
||||
|
||||
return True, " Le client a été correctement mise à jour"
|
||||
|
||||
except Exception as e:
|
||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - Line : " + str(exc_tb.tb_lineno))
|
||||
return False, " Impossible de mettre à jour le client "
|
||||
return False, " Impossible de recuperer la liste des clients "
|
||||
|
||||
|
||||
"""
|
||||
Recuperation d'un client donnée
|
||||
"""
|
||||
def Get_Given_Partner_List_Client(diction):
|
||||
def Get_Given_Partner_Client(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', 'email']
|
||||
|
||||
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','email' ]
|
||||
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 recuperer les données de l'utilisateur ")
|
||||
return False, str(inspect.stack()[0][3]) + " - impossible de recuperer les données de l'utilisateur. "
|
||||
|
||||
"""
|
||||
Clés de mise à jour
|
||||
"""
|
||||
data_cle = {}
|
||||
data_cle['partner_recid'] = str(my_partner['recid'])
|
||||
data_cle['email'] = str(diction['email'])
|
||||
data_cle['valide'] = "1"
|
||||
data_cle['locked'] = "0"
|
||||
|
||||
RetObject = []
|
||||
val_tmp = 1
|
||||
|
||||
print(" ### data_cle = ", data_cle)
|
||||
for retval in MYSY_GV.dbname['partner_client'].find(data_cle):
|
||||
user = retval
|
||||
user['id'] = str(val_tmp)
|
||||
val_tmp = val_tmp + 1
|
||||
RetObject.append(mycommon.JSONEncoder().encode(user))
|
||||
|
||||
print(" ### RetObject = ", RetObject)
|
||||
return True, RetObject
|
||||
|
||||
return True, " Le client a été correctement mise à jour"
|
||||
|
||||
except Exception as e:
|
||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||
|
|
|
@ -999,7 +999,7 @@ def CronUSerMessage_Mail():
|
|||
|
||||
if (re.match(patter_mail, str(mail_recever))):
|
||||
if( len(mail_object) == 0 or len(message) == 0 ):
|
||||
myprint(" WARNING : Impossible d'enboyer le mail au destinataire. l'objet ou le message sont vides : mail_object = "
|
||||
myprint(" WARNING : Impossible d'envoyer le mail au destinataire. l'objet ou le message sont vides : mail_object = "
|
||||
+ str(mail_object)+ " ou message = "+str(message))
|
||||
ismail_traited = 'error'
|
||||
error_message = "l'objet ou le message sont vides"
|
||||
|
@ -1526,9 +1526,6 @@ def recordImage(file=None, Folder=None, diction=None):
|
|||
if user_recid is False:
|
||||
myprint(str(inspect.stack()[0][3]) + " - Impossible de recuperer le recid du partner")
|
||||
return False, " Les informations d'identification sont incorrectes"
|
||||
|
||||
|
||||
|
||||
myuserrecid = user_recid
|
||||
|
||||
|
||||
|
@ -3086,4 +3083,21 @@ def strip_dictionary(d):
|
|||
"""
|
||||
Strip all leading and trailing whitespace in dictionary keys and values.
|
||||
"""
|
||||
return dict((k.strip(), v.strip()) for k, v in d.items())
|
||||
return dict((k.strip(), v.strip()) for k, v in d.items())
|
||||
|
||||
|
||||
"""
|
||||
Cette fonction verifie si une chaine de caractère est un email valide
|
||||
"""
|
||||
def isEmailValide(email):
|
||||
try:
|
||||
pat = "^[a-zA-Z0-9-_]+@[a-zA-Z0-9]+\.[a-z]{1,3}$"
|
||||
if re.match(pat, email):
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
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
|
Loading…
Reference in New Issue