Validation 26/02/22 - 22h21
parent
b772c25960
commit
ada9b53961
|
@ -420,9 +420,6 @@ def disable_class(diction):
|
|||
mydata['date_update'] = str(datetime.now())
|
||||
|
||||
mydata['valide'] = '0'
|
||||
|
||||
|
||||
|
||||
coll_name = dbname['myclass']
|
||||
|
||||
|
||||
|
|
64
partners.py
64
partners.py
|
@ -55,7 +55,7 @@ def add_partner_account(diction):
|
|||
# Ici on doit mettre tous les champs possible (obligatoire ou non) de la BDD dans la liste
|
||||
# field_list.
|
||||
'''
|
||||
field_list = ['nom', 'adr_street', 'adr_city', 'adr_zip', 'adr_country',
|
||||
field_list = ['nom', 'adr_street', 'adr_city', 'adr_zip', 'adr_country','link_linkedin','link_facebook','link_twitter'
|
||||
'email','pwd', 'telephone','contact_nom','contact_prenom','contact_tel','contact_mail']
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
|
@ -124,6 +124,18 @@ def add_partner_account(diction):
|
|||
if diction['contact_mail']:
|
||||
mydata['contact_mail'] = diction['contact_mail']
|
||||
|
||||
if ("link_linkedin" in diction.keys()):
|
||||
if diction['link_linkedin']:
|
||||
mydata['link_linkedin'] = diction['link_linkedin']
|
||||
|
||||
if ("link_facebook" in diction.keys()):
|
||||
if diction['link_facebook']:
|
||||
mydata['link_facebook'] = diction['link_facebook']
|
||||
|
||||
if ("link_twitter" in diction.keys()):
|
||||
if diction['link_twitter']:
|
||||
mydata['link_twitter'] = diction['link_twitter']
|
||||
|
||||
# Creation du RecId du user
|
||||
mydata['recid'] = mycommon.create_user_recid()
|
||||
|
||||
|
@ -169,14 +181,16 @@ def update_partner_account(diction):
|
|||
# Ici on doit mettre tous les champs possible (obligatoire ou non) de la BDD dans la liste
|
||||
# field_list.
|
||||
'''
|
||||
field_list = ['nom', 'adr_street', 'adr_city', 'adr_zip', 'adr_country',
|
||||
field_list = ['nom', 'adr_street', 'adr_city', 'adr_zip', 'adr_country', 'link_linkedin',
|
||||
'email', 'pwd', 'telephone', 'contact_nom', 'contact_prenom', 'contact_tel',
|
||||
'contact_mail', 'token']
|
||||
'contact_mail', 'token', 'link_facebook', 'link_twitter']
|
||||
incom_keys = diction.keys()
|
||||
|
||||
|
||||
for val in incom_keys:
|
||||
if val not in field_list:
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - Creation partner account : Le champ '" + val + "' n'existe pas, Creation partenaire annulée")
|
||||
return False, " Creation partner account : Le champ '" + val + "' n'existe pas, Creation partenaire annulée"
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " : Le champ '"+val + "' n'est pas autorisé ")
|
||||
return False, " Creation partner account : Le champ '" + val + "' n'est pas accepté "
|
||||
|
||||
'''
|
||||
Une fois qu'on a controlé que toutes les clés mise dans l'API sont correcte. etape precedente,
|
||||
|
@ -198,11 +212,16 @@ def update_partner_account(diction):
|
|||
|
||||
|
||||
# Verifier la validité du token
|
||||
retval = mycommon.check_token_validity("", my_token)
|
||||
retval = mycommon.check_partner_token_validity("", my_token)
|
||||
|
||||
if retval is False :
|
||||
return False, " Le token n'est pas valide"
|
||||
# Recuperation du recid de l'utilisateur
|
||||
|
||||
partner_recid = mycommon.get_parnter_recid_from_token(str(my_token))
|
||||
if partner_recid is False:
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - Impossible de recuperer le recid du partenaire")
|
||||
return False, " Impossible de mettre à jour le partenaire "
|
||||
|
||||
mydata = {}
|
||||
if ("nom" in diction.keys()):
|
||||
|
@ -253,6 +272,18 @@ def update_partner_account(diction):
|
|||
if diction['contact_mail']:
|
||||
mydata['contact_mail'] = diction['contact_mail']
|
||||
|
||||
if ("link_linkedin" in diction.keys()):
|
||||
if diction['link_linkedin']:
|
||||
mydata['link_linkedin'] = diction['link_linkedin']
|
||||
|
||||
if ("link_facebook" in diction.keys()):
|
||||
if diction['link_facebook']:
|
||||
mydata['link_facebook'] = diction['link_facebook']
|
||||
|
||||
if ("link_twitter" in diction.keys()):
|
||||
if diction['link_twitter']:
|
||||
mydata['link_twitter'] = diction['link_twitter']
|
||||
|
||||
|
||||
mydata['date_update'] = str(datetime.now())
|
||||
|
||||
|
@ -261,13 +292,28 @@ def update_partner_account(diction):
|
|||
dbname = client['cherifdb']
|
||||
coll_name = dbname['partnair_account']
|
||||
|
||||
'''
|
||||
ret_val = coll_name.find_and_modify(query={'email': str(my_token), 'locked': '0'},
|
||||
update={"$set": mydata}
|
||||
)
|
||||
'''
|
||||
|
||||
print("debut update recid partenaire ="+partner_recid)
|
||||
print(" mydata = "+str(mydata))
|
||||
|
||||
ret_val = coll_name.find_one_and_update(
|
||||
{'recid': str(partner_recid), 'locked': '0', 'active': '1'},
|
||||
{"$set": mydata},
|
||||
return_document=ReturnDocument.AFTER
|
||||
)
|
||||
|
||||
|
||||
if (ret_val and ret_val['_id']):
|
||||
mycommon.myprint("Le partenaire a bien ete mise à jour =" + str(ret_val['_id']))
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + "Le partenaire a bien ete mise à jour =" + str(ret_val['_id']))
|
||||
return True, "Le partenaire a bien ete mise à jour"
|
||||
else:
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - Impossible de mettre à jour le partenaire recid= : " +str(partner_recid) )
|
||||
return False, " Impossible de mettre à jour le partenaire"
|
||||
|
||||
except Exception as e:
|
||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||
|
@ -358,7 +404,7 @@ def get_partner_account(diction):
|
|||
coll_token = dbname['user_token']
|
||||
|
||||
# Verification de la validité du token/mail dans le cas des user en mode connecté
|
||||
retval = mycommon.check_token_validity(email_value, token_value )
|
||||
retval = mycommon.check_partner_token_validity(email_value, token_value )
|
||||
|
||||
if retval is False:
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - Le token n'est pas valide")
|
||||
|
@ -372,7 +418,7 @@ def get_partner_account(diction):
|
|||
return False
|
||||
'''
|
||||
|
||||
coll_token = dbname['user_token']
|
||||
coll_token = dbname['partner_token']
|
||||
tmp = coll_token.find({ 'token': str(token_value), 'valide': '1'})
|
||||
partnere_recid = tmp[0]['recid']
|
||||
|
||||
|
|
|
@ -105,7 +105,6 @@ donc la table partner_token
|
|||
'''
|
||||
def check_partner_token_validity(email="", token=""):
|
||||
try :
|
||||
|
||||
coll_token = dbname['partner_token']
|
||||
tmp_count = coll_token.find(
|
||||
{ 'token': str(token), 'locked':'0', 'valide': '1'}).count()
|
||||
|
|
Loading…
Reference in New Issue