06/07/22 - 9h30
parent
94be08a869
commit
68702f74d2
|
@ -81,7 +81,7 @@ def Dev_del_user_token(diction):
|
|||
mydata['indexed'] = '0'
|
||||
|
||||
dbname = client['cherifdb']
|
||||
coll_token = dbname['user_token']
|
||||
coll_token = MYSY_GV.dbname['user_token']
|
||||
|
||||
myquery = {"email": email}
|
||||
delete_row = coll_token.delete_many(myquery)
|
||||
|
|
|
@ -21,7 +21,7 @@ import sys, os
|
|||
import GlobalVariable as MYSY_GV
|
||||
import user_message_mgt as umm
|
||||
import Ela_Spacy as ES
|
||||
|
||||
import GlobalVariable as MYSY_GV
|
||||
|
||||
|
||||
class JSONEncoder(json.JSONEncoder):
|
||||
|
@ -61,7 +61,7 @@ def get_all_articles_avis(diction):
|
|||
mycommon.myprint(str(inspect.stack()[0][3]) + " Le champ '" + val + "' n'est pas autorisé")
|
||||
return False, " Impossible de recuperer les articles et avis"
|
||||
|
||||
coll_name = dbname['articles_avis']
|
||||
coll_name = MYSY_GV.dbname['articles_avis']
|
||||
|
||||
val_tmp = 1
|
||||
insertObject = []
|
||||
|
@ -184,7 +184,7 @@ def get_articles_avis(diction):
|
|||
|
||||
#print(" My Data =" + str(mydata))
|
||||
|
||||
coll_name = dbname['articles_avis']
|
||||
coll_name = MYSY_GV.dbname['articles_avis']
|
||||
insertObject = []
|
||||
|
||||
for x in coll_name.find({'valide': '1', 'locked': '0', 'internal_url':my_internal_id},
|
||||
|
@ -391,7 +391,7 @@ def add_articles_avis(diction):
|
|||
|
||||
#print(mydata)
|
||||
|
||||
coll_name = dbname['articles_avis']
|
||||
coll_name = MYSY_GV.dbname['articles_avis']
|
||||
ret_val = coll_name.insert_one(mydata)
|
||||
|
||||
if (ret_val and ret_val.inserted_id):
|
||||
|
@ -518,7 +518,7 @@ def recherche_articles_avis(diction):
|
|||
#mycommon.myprint(" pour phrase : #" + search_text + "#, voici la liste des formations")
|
||||
#mycommon.myprint(tab_training)
|
||||
|
||||
coll_name = dbname['articles_avis']
|
||||
coll_name = MYSY_GV.dbname['articles_avis']
|
||||
|
||||
'''
|
||||
la valeur nb_result permettra de savoir si la requete a donnée un resultat.
|
||||
|
@ -654,7 +654,7 @@ def store_recherche_article_avis(diction, user_recid=""):
|
|||
mydata['valide'] = diction['valide']
|
||||
|
||||
|
||||
coll_name = dbname['user_recherche']
|
||||
coll_name = MYSY_GV.dbname['user_recherche']
|
||||
|
||||
# Si le champ "id" est renseigné, il s'agit d'une mis jour
|
||||
#mycommon.myprint(str(inspect.stack()[0][3]) + " on va stocker "+str(mydata)+" id = "+str(mydata_id))
|
||||
|
@ -728,7 +728,7 @@ def get_article_avis_alaune(diction):
|
|||
return False, " : La valeur '" + val + "' n'est pas presente dans liste ",
|
||||
|
||||
|
||||
coll_name = dbname['articles_avis']
|
||||
coll_name = MYSY_GV.dbname['articles_avis']
|
||||
insertObject = []
|
||||
|
||||
for x in coll_name.find({'valide': '1', 'locked': '0', 'isalaune': '1'},
|
||||
|
|
49
class_mgt.py
49
class_mgt.py
|
@ -17,6 +17,7 @@ import pandas as pd
|
|||
from pymongo import ReturnDocument
|
||||
import GlobalVariable as MYSY_GV
|
||||
from math import isnan
|
||||
import GlobalVariable as MYSY_GV
|
||||
|
||||
|
||||
class JSONEncoder(json.JSONEncoder):
|
||||
|
@ -249,7 +250,7 @@ def add_class(diction):
|
|||
# Create internal ref. of class
|
||||
mydata['internal_code'] = mycommon.Create_internal_call_ref()
|
||||
|
||||
coll_name = dbname['myclass']
|
||||
coll_name = MYSY_GV.dbname['myclass']
|
||||
|
||||
'''
|
||||
Verification si cette formation exite deja .
|
||||
|
@ -259,14 +260,25 @@ def add_class(diction):
|
|||
tmp = coll_name.count_documents({'external_code': str(mydata['external_code'])})
|
||||
|
||||
#mycommon.myprint(" TMP = " + str(tmp))
|
||||
if (tmp > 0):
|
||||
mycommon.myprint(str(inspect.stack()[0][3])+" -la formation avec l'external code " + str(mydata['external_code']) + "' existe deja, impossible de créer le compte partenaire ")
|
||||
'''if (tmp > 0):
|
||||
mycommon.myprint(str(inspect.stack()[0][3])+" -la formation avec l'external code " + str(mydata['external_code']) + "' existe deja, impossible de créer la formation ")
|
||||
return False, "la formation avec l'external code " + str(mydata['external_code']) + "' existe deja. Impossible de créer la formation "
|
||||
'''
|
||||
|
||||
#coll_name.insert_one(mydata)
|
||||
|
||||
coll_name.insert_one(mydata)
|
||||
ret_val = coll_name.find_one_and_update(
|
||||
{'external_code': str(mydata['external_code']), },
|
||||
{"$set": mydata},
|
||||
upsert=True,
|
||||
return_document=ReturnDocument.AFTER
|
||||
)
|
||||
|
||||
return True, "La formation a bien été ajoutée"
|
||||
if ret_val and ret_val['_id']:
|
||||
return True, "La formation a bien été ajoutée"
|
||||
else:
|
||||
mycommon.myprint(" Impossible d'ajouter la formation "+str(str(mydata['external_code'])))
|
||||
return False, " Impossible d'ajouter la formation "+str(str(mydata['external_code']))
|
||||
|
||||
except Exception as e:
|
||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||
|
@ -459,7 +471,8 @@ def update_class(diction):
|
|||
mydata['indexed_obj'] = '0'
|
||||
|
||||
|
||||
coll_name = dbname['myclass']
|
||||
coll_name = MYSY_GV.dbname['myclass']
|
||||
coll_name = MYSY_GV.dbname['myclass']
|
||||
|
||||
|
||||
# seules les formation avec locked = 0 et valide=1 sont modifiables
|
||||
|
@ -557,7 +570,7 @@ def disable_class(diction):
|
|||
mydata['date_update'] = str(datetime.now())
|
||||
|
||||
mydata['valide'] = '0'
|
||||
coll_name = dbname['myclass']
|
||||
coll_name = MYSY_GV.dbname['myclass']
|
||||
|
||||
|
||||
|
||||
|
@ -659,7 +672,7 @@ def enable_class(diction):
|
|||
mydata['valide'] = '1'
|
||||
|
||||
|
||||
coll_name = dbname['myclass']
|
||||
coll_name = MYSY_GV.dbname['myclass']
|
||||
|
||||
# seules les formation avec locked = 0 et valide=1 sont modifiables
|
||||
ret_val = coll_name.find_one_and_update(
|
||||
|
@ -758,7 +771,7 @@ def unlock_class(diction):
|
|||
|
||||
mydata['locked'] = '0'
|
||||
|
||||
coll_name = dbname['myclass']
|
||||
coll_name = MYSY_GV.dbname['myclass']
|
||||
|
||||
# seules les formation avec locked = 1 et valide=1 sont 'unlockable'
|
||||
ret_val = coll_name.find_one_and_update(
|
||||
|
@ -860,7 +873,7 @@ def lock_class(diction):
|
|||
|
||||
mydata['locked'] = '1'
|
||||
|
||||
coll_name = dbname['myclass']
|
||||
coll_name = MYSY_GV.dbname['myclass']
|
||||
|
||||
# seules les formation avec locked = 1 et valide=1 sont 'unlockable'
|
||||
ret_val = coll_name.find_one_and_update(
|
||||
|
@ -950,10 +963,10 @@ def get_class(diction):
|
|||
title_crit['title'] = diction['title']
|
||||
|
||||
|
||||
coll_name = dbname['myclass']
|
||||
coll_name = MYSY_GV.dbname['myclass']
|
||||
|
||||
# verifier que le token et l'email sont ok
|
||||
coll_token = dbname['user_token']
|
||||
coll_token = MYSY_GV.dbname['user_token']
|
||||
|
||||
# Verification de la validité du token dans le cas des user en mode connecté
|
||||
'''
|
||||
|
@ -964,7 +977,7 @@ def get_class(diction):
|
|||
'''
|
||||
|
||||
user_recid = "None"
|
||||
coll_search_result = dbname['user_recherche_result']
|
||||
coll_search_result = MYSY_GV.dbname['user_recherche_result']
|
||||
|
||||
# Verification de la validité du token/mail dans le cas des user en mode connecté
|
||||
if (len(str(my_token)) > 0):
|
||||
|
@ -1109,7 +1122,7 @@ def get_class_coup_de_coeur(diction):
|
|||
|
||||
|
||||
|
||||
coll_name = dbname['myclass']
|
||||
coll_name = MYSY_GV.dbname['myclass']
|
||||
|
||||
|
||||
RetObject = []
|
||||
|
@ -1228,10 +1241,10 @@ def get_partner_class(diction):
|
|||
title_crit['title'] = diction['title']
|
||||
|
||||
|
||||
coll_name = dbname['myclass']
|
||||
coll_name = MYSY_GV.dbname['myclass']
|
||||
|
||||
# verifier que le token et l'email sont ok
|
||||
coll_token = dbname['user_token']
|
||||
coll_token = MYSY_GV.dbname['user_token']
|
||||
|
||||
# Verification de la validité du token dans le cas des user en mode connecté
|
||||
'''
|
||||
|
@ -1318,7 +1331,7 @@ def get_class_global_search(search_string):
|
|||
client = MongoClient(CONNECTION_STRING)
|
||||
|
||||
dbname = client['cherifdb']
|
||||
coll_name = dbname['myclass']
|
||||
coll_name = MYSY_GV.dbname['myclass']
|
||||
|
||||
val = re.compile(r".*"+search_string+".*")
|
||||
my_regex = "/.*"+search_string+".*/"
|
||||
|
@ -1342,7 +1355,7 @@ def get_all_class_by_attribut(attribut, value):
|
|||
try:
|
||||
mycommon.myprint(" attribut", attribut, " value = ",value)
|
||||
|
||||
coll_name = dbname['myclass']
|
||||
coll_name = MYSY_GV.dbname['myclass']
|
||||
|
||||
insertObject = []
|
||||
for x in coll_name.find({attribut: value}, {"_id": 0}):
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import GlobalVariable as MYSY_GV
|
||||
|
||||
def update_token_fr_pontuation(token_fr_pontuation):
|
||||
tab_ponctuation = ['...', '.', ';', ',', ':', '!', '?', ')', '(', '[', ']', '{', '}','-',
|
||||
|
|
|
@ -24,6 +24,7 @@ import prj_common as mycommon
|
|||
from pymongo import ReturnDocument
|
||||
import inspect
|
||||
import sys, os
|
||||
import GlobalVariable as MYSY_GV
|
||||
|
||||
|
||||
class JSONEncoder(json.JSONEncoder):
|
||||
|
@ -101,7 +102,7 @@ def get_user_objectif(diction):
|
|||
return False, " Impossible de recuperer les objectifs de l'utilisateur"
|
||||
|
||||
query['user_recid'] = user_recid
|
||||
coll_name = dbname['user_objectif']
|
||||
coll_name = MYSY_GV.dbname['user_objectif']
|
||||
|
||||
# Verification si ce user a deja une formation du meme nom
|
||||
#tmp = coll_name.find(query).count()
|
||||
|
@ -183,7 +184,7 @@ def desable_user_objectif(diction):
|
|||
myobjectif['date_update'] = str(datetime.now())
|
||||
|
||||
dbname = client['cherifdb']
|
||||
coll_name = dbname['user_objectif']
|
||||
coll_name = MYSY_GV.dbname['user_objectif']
|
||||
|
||||
mycommon.myprint(" on recherche " + user_recid)
|
||||
|
||||
|
@ -289,7 +290,7 @@ def add_update_user_objectif(diction):
|
|||
myobjectif['date_update'] = str(now)
|
||||
|
||||
dbname = client['cherifdb']
|
||||
coll_name = dbname['user_objectif']
|
||||
coll_name = MYSY_GV.dbname['user_objectif']
|
||||
|
||||
mycommon.myprint(" on recherche recid "+user_recid)
|
||||
|
||||
|
@ -379,7 +380,7 @@ def add_user_account(diction):
|
|||
mycommon.myprint(" webservice : diction = "+str(myuser))
|
||||
|
||||
dbname = client['cherifdb']
|
||||
coll_name = dbname['user_account']
|
||||
coll_name = MYSY_GV.dbname['user_account']
|
||||
|
||||
|
||||
|
||||
|
@ -413,7 +414,7 @@ def valide_user_account(value):
|
|||
try:
|
||||
client = MongoClient(CONNECTION_STRING)
|
||||
dbname = client['cherifdb']
|
||||
coll_name = dbname['user_account']
|
||||
coll_name = MYSY_GV.dbname['user_account']
|
||||
|
||||
tmp = coll_name.find({'_id':ObjectId(str(value))})
|
||||
|
||||
|
@ -427,6 +428,16 @@ def valide_user_account(value):
|
|||
|
||||
if( ret_val and ret_val['_id']):
|
||||
mycommon.myprint("La modif a bien ete faite ="+str(ret_val['_id']))
|
||||
"""
|
||||
Declenchement de l'envoie du mail de remerciement
|
||||
"""
|
||||
status = mail.send_user_thks_mail("", ret_val['email'])
|
||||
|
||||
if( status is False ):
|
||||
mycommon.myprint(" Impossible d'envoyer le mail de remerciement de validation le compte")
|
||||
|
||||
|
||||
|
||||
return True," Le compte a bien été validé "
|
||||
else:
|
||||
mycommon.myprint(" Impossible de valider le compte")
|
||||
|
@ -479,7 +490,7 @@ def update_user_account(diction):
|
|||
|
||||
mycommon.myprint(" MAJ de diction "+str(diction))
|
||||
|
||||
coll_name = dbname['user_account']
|
||||
coll_name = MYSY_GV.dbname['user_account']
|
||||
|
||||
now = datetime.now()
|
||||
dictionnary = {}
|
||||
|
@ -654,7 +665,7 @@ def get_user_account(diction):
|
|||
|
||||
client = MongoClient(CONNECTION_STRING)
|
||||
dbname = client['cherifdb']
|
||||
coll_name = dbname['user_account']
|
||||
coll_name = MYSY_GV.dbname['user_account']
|
||||
|
||||
RetObject = []
|
||||
for retVal in coll_name.find({'recid': user_recid, 'active':'1', 'locked':'0'}):
|
||||
|
@ -760,7 +771,7 @@ def change_user_pwd(diction):
|
|||
|
||||
client = MongoClient(CONNECTION_STRING)
|
||||
dbname = client['cherifdb']
|
||||
coll_name = dbname['user_account']
|
||||
coll_name = MYSY_GV.dbname['user_account']
|
||||
|
||||
print(" le recid = "+user_recid+" mydata = "+str(mydata))
|
||||
ret_val = coll_name.find_one_and_update({'recid': user_recid, 'locked': '0', 'active':'1', 'pwd':pwd},
|
||||
|
@ -860,7 +871,7 @@ def Reset_user_pwd_by_token(diction):
|
|||
mydata['date_update'] = str(datetime.now())
|
||||
client = MongoClient(CONNECTION_STRING)
|
||||
dbname = client['cherifdb']
|
||||
coll_name = dbname['user_account']
|
||||
coll_name = MYSY_GV.dbname['user_account']
|
||||
|
||||
print(" le recid = "+user_recid+" mydata = "+str(mydata))
|
||||
ret_val = coll_name.find_one_and_update({'recid': user_recid, 'locked': '0', 'active':'1'},
|
||||
|
@ -871,7 +882,7 @@ def Reset_user_pwd_by_token(diction):
|
|||
if (ret_val and ret_val['_id']):
|
||||
# Apres avoir changer le mot passe, desactivation tu token
|
||||
|
||||
coll_name = dbname['user_token']
|
||||
coll_name = MYSY_GV.dbname['user_token']
|
||||
ret_val = coll_name.update_many({'recid': user_recid, 'valide': '1'},
|
||||
{"$set": {'valide': '0', 'date_update': str(datetime.now())}},
|
||||
)
|
||||
|
@ -958,7 +969,7 @@ def change_uer_email(diction):
|
|||
mydata['date_update'] = str(datetime.now())
|
||||
|
||||
|
||||
coll_name = dbname['user_account']
|
||||
coll_name = MYSY_GV.dbname['user_account']
|
||||
|
||||
print(" le recid = "+user_recid+" mydata = "+str(mydata))
|
||||
ret_val = coll_name.find_one_and_update({'recid': user_recid, 'locked': '0'},
|
||||
|
@ -1065,7 +1076,7 @@ def send_mail_delete_user(diction):
|
|||
|
||||
mydata['date_update'] = str(datetime.now())
|
||||
|
||||
coll_name = dbname['user_account']
|
||||
coll_name = MYSY_GV.dbname['user_account']
|
||||
ret_val = coll_name.find_one_and_update({'recid': str(user_recid), 'locked': '0'},
|
||||
{"$set": mydata},
|
||||
return_document=ReturnDocument.AFTER
|
||||
|
@ -1171,7 +1182,7 @@ def delete_user_account(diction):
|
|||
mydata['delete_ip_1'] = diction['user_ip']
|
||||
|
||||
|
||||
coll_name = dbname['user_account']
|
||||
coll_name = MYSY_GV.dbname['user_account']
|
||||
ret_val = coll_name.find_one_and_update({'recid': str(user_recid), 'locked': '0'},
|
||||
{"$set": mydata},
|
||||
return_document=ReturnDocument.AFTER
|
||||
|
@ -1187,7 +1198,7 @@ def delete_user_account(diction):
|
|||
|
||||
# Anonymisation de la table user_token ou se trouve aussi l'adresse email.
|
||||
# table : user_token
|
||||
user_token_coll_name = dbname['user_token']
|
||||
user_token_coll_name = MYSY_GV.dbname['user_token']
|
||||
ret_val = user_token_coll_name.update_many({'recid': str(user_recid), },
|
||||
{"$set": {'email':'Anonyme',
|
||||
'valide':'0',
|
||||
|
@ -1197,7 +1208,7 @@ def delete_user_account(diction):
|
|||
" "+str(ret_val.acknowledged)+" ont été modifiées")
|
||||
|
||||
# table : articles_avis
|
||||
articles_avis_coll_name = dbname['articles_avis']
|
||||
articles_avis_coll_name = MYSY_GV.dbname['articles_avis']
|
||||
ret_val = articles_avis_coll_name.update_many({'postedby': str(user_email_from_recid), },
|
||||
{"$set": {'email': 'Anonyme',
|
||||
'date_update':str(datetime.now()) }},
|
||||
|
@ -1248,7 +1259,7 @@ def lock_user_account(diction):
|
|||
return False, "Impossible de mettre à jour le compte utilisateur"
|
||||
|
||||
|
||||
coll_name = dbname['user_account']
|
||||
coll_name = MYSY_GV.dbname['user_account']
|
||||
|
||||
now = datetime.now()
|
||||
dictionnary = {}
|
||||
|
@ -1320,7 +1331,7 @@ def desable_user_account(diction):
|
|||
return False, "Impossible de mettre à jour le compte utilisateur"
|
||||
|
||||
|
||||
coll_name = dbname['user_account']
|
||||
coll_name = MYSY_GV.dbname['user_account']
|
||||
|
||||
now = datetime.now()
|
||||
dictionnary = {}
|
||||
|
@ -1421,7 +1432,7 @@ def get_user_recherche_history(diction):
|
|||
query['user_recid'] = user_recid
|
||||
query['valide'] = '1'
|
||||
|
||||
coll_name = dbname['user_recherche']
|
||||
coll_name = MYSY_GV.dbname['user_recherche']
|
||||
|
||||
# Verification si ce user a deja une formation du meme nom
|
||||
#tmp = coll_name.find(query, {"_id": 0}).count()
|
||||
|
@ -1503,7 +1514,7 @@ def InitUserPasswd(diction):
|
|||
myquery['locked'] = '0'
|
||||
|
||||
|
||||
coll_name = dbname['user_account']
|
||||
coll_name = MYSY_GV.dbname['user_account']
|
||||
|
||||
#print(" myquery ="+str(myquery))
|
||||
|
||||
|
@ -1523,7 +1534,7 @@ def InitUserPasswd(diction):
|
|||
update_field = {'valide': '0', 'date_update':str(datetime.now())}
|
||||
|
||||
|
||||
coll_name_token = dbname['user_token']
|
||||
coll_name_token = MYSY_GV.dbname['user_token']
|
||||
ret_val_user_rech = coll_name_token.update_many(
|
||||
{'recid': retVal[0]['recid']},
|
||||
{"$set": update_field}
|
||||
|
@ -1599,7 +1610,7 @@ def IsUserTokenValide(diction):
|
|||
myquery['token'] = diction['token']
|
||||
|
||||
myquery['valide'] = '1'
|
||||
coll_name_token = dbname['user_token']
|
||||
coll_name_token = MYSY_GV.dbname['user_token']
|
||||
|
||||
|
||||
tmp = coll_name_token.count_documents(myquery)
|
||||
|
|
162
email_mgt.py
162
email_mgt.py
|
@ -115,6 +115,168 @@ def send_user_account_mail(message, account_mail):
|
|||
return False, " Impossible d'envoyer l'email de notification "
|
||||
|
||||
|
||||
'''
|
||||
Cette fonction envoie un mail de remerciement apres l'activation
|
||||
du compte d'un utilisateur
|
||||
'''
|
||||
|
||||
def send_user_thks_mail(message, account_mail):
|
||||
try:
|
||||
tomorrow = datetime.date.today() + datetime.timedelta(days=1)
|
||||
tomorrow_day = tomorrow.strftime("%A")
|
||||
|
||||
print("debut envoi mail de test ")
|
||||
# on rentre les renseignements pris sur le site du fournisseur
|
||||
|
||||
msg = MIMEMultipart("alternative")
|
||||
|
||||
msg['Subject'] = 'MySy Training : Votre compte est actif '
|
||||
msg['From'] = 'contact@mysy-training.com'
|
||||
msg['To'] = str(account_mail)
|
||||
|
||||
html = '''
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<link rel="stylesheet" href="http://88.170.110.220/mysy_css/mysy_css.css">
|
||||
</head>
|
||||
<body>
|
||||
<div style="background-color:#eee;padding:0px;text-align:center;width:100%">
|
||||
<h2 style="font-family:Georgia, 'Times New Roman', Times, serif;color#454349;">
|
||||
<img src="http://88.170.110.220/img/MYSY-LOGO-BLUE.png" alt="Mysy Training Logo" width="110px" height="70px"/> </h2>
|
||||
</div>
|
||||
<div style="padding:20px 0px;text-align:center;font-family:Georgia, 'Times New Roman', Times, serif;color#454349;font-size:2rem;">
|
||||
<div style="width:100%">
|
||||
<div style="text-align:center;" class="p">
|
||||
Bonjour
|
||||
<div style="padding:20px 0px;text-align:center;font-family:Georgia, 'Times New Roman', Times, serif;color#454349;font-size:1.2rem;">
|
||||
|
||||
Vous venez d'activer votre compte sur le moteur de recherche <font color="green">MySy-Training</font>. <br>
|
||||
Merci à vous.
|
||||
<br/>
|
||||
<br/>
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
|
||||
|
||||
<b> Suivez l'actualité des formations depuis nos medias : <br/>
|
||||
|
||||
<a href="https://apimysy.iexercice.com/myclass/api/valide_user_account/{objId}" target="_blank" >
|
||||
Facebook
|
||||
</a>
|
||||
|
||||
<a href="https://apimysy.iexercice.com/myclass/api/valide_user_account/{objId}" target="_blank" >
|
||||
LinkedIn
|
||||
</a>
|
||||
|
||||
<a href="https://apimysy.iexercice.com/myclass/api/valide_user_account/{objId}" target="_blank" >
|
||||
Twitter
|
||||
</a>
|
||||
|
||||
</b>
|
||||
</div>
|
||||
</font>
|
||||
<br/>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class='Box_div'>
|
||||
<div class='Container_div'>
|
||||
<div class='Row_Div'>
|
||||
<div class='Column_div'>
|
||||
<div class='Heading_p'>MySy Training Technology</div>
|
||||
<a href="/QuiSommesNous/#desc" class='FooterLink_a'>À propos de nous</a>
|
||||
<a href="/QuiSommesNous/#vision" class='FooterLink_a'>Notre vision</a>
|
||||
<a href="/ContactezNous" class='FooterLink_a'>Nous contacter</a>
|
||||
</div>
|
||||
|
||||
<div class='Column_div'>
|
||||
<div class='Heading_p'>Contact Us</div>
|
||||
<a href="#" class='FooterLink_a'>Paris</a>
|
||||
<a href="#" class='FooterLink_a'>Geneve</a>
|
||||
<a href="#" class='FooterLink_a'>Bruxelles</a>
|
||||
</div>
|
||||
|
||||
<div class='Column_div'>
|
||||
<div class='Heading_p'>Social Media</div>
|
||||
<a href="https://www.facebook.com/profile.php?id=100080411044908" class='FooterLink_a'>
|
||||
<i class="fab fa-facebook-f">
|
||||
<span style={{ marginLeft: "10px" }}>
|
||||
Facebook
|
||||
</span>
|
||||
</i>
|
||||
</a>
|
||||
<a href="https://www.linkedin.com/in/mysy-training-96b53a237/" class='FooterLink_a'>
|
||||
<i class="fab fa-instagram">
|
||||
<span style={{ marginLeft: "10px" }}>
|
||||
LinkedIn
|
||||
</span>
|
||||
</i>
|
||||
</a>
|
||||
<a href="https://twitter.com/mysy_training" class='FooterLink_a'>
|
||||
<i class="fab fa-twitter">
|
||||
<span style={{ marginLeft: "10px" }}>
|
||||
Twitter
|
||||
</span>
|
||||
</i>
|
||||
</a>
|
||||
<a href="https://www.youtube.com/" class='FooterLink_a'>
|
||||
<i class="fab fa-youtube">
|
||||
<span style={{ marginLeft: "10px" }}>
|
||||
Youtube
|
||||
</span>
|
||||
</i>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<br />
|
||||
<hr />
|
||||
<div style="font-size:0.5rem;">
|
||||
© 2022 Mysy Training Technology. Tous droits réservés. MySy Training Technology est une marque déposée.
|
||||
Mentions légales.
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
'''.format(code=tomorrow_day, objId=message)
|
||||
|
||||
html_mime = MIMEText(html, 'html')
|
||||
|
||||
# msg.attach(texte_mime)
|
||||
msg.attach(html_mime)
|
||||
|
||||
print("html_mime =" + str(html))
|
||||
|
||||
toaddr = str(account_mail)
|
||||
cc = ['contact@mysy-training.com']
|
||||
toaddrs = [toaddr] + cc
|
||||
|
||||
# msg.attach(MIMEText(open(filename).read()))
|
||||
|
||||
with smtplib.SMTP(smtp_address, port) as server:
|
||||
server.starttls() # Secure the connection
|
||||
|
||||
server.login(user, password)
|
||||
server.sendmail(sender, toaddrs, msg.as_string())
|
||||
mycommon.myprint("mail successfully sent to " + str(toaddrs))
|
||||
|
||||
return True
|
||||
|
||||
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 d'envoyer l'email de notification "
|
||||
|
||||
|
||||
|
||||
def send_partner_account_mail(message, account_mail):
|
||||
|
||||
try:
|
||||
|
|
5
main.py
5
main.py
|
@ -217,9 +217,10 @@ def valide_user_account(value):
|
|||
|
||||
url = ""
|
||||
if( status ):
|
||||
url = 'https://dev.mysy-training.com/login'
|
||||
url = 'https://www.mysy-training.com/mysy-account-activated/'
|
||||
#url = 'http://localhost:3009/mysy-account-activated/'
|
||||
else:
|
||||
url = 'https://dev.mysy-training.com/erreur'
|
||||
url = 'https://www.mysy-training.com/erreur'
|
||||
|
||||
return redirect(url)
|
||||
|
||||
|
|
21
partners.py
21
partners.py
|
@ -28,6 +28,7 @@ import inspect
|
|||
import sys, os
|
||||
from pymongo import ReturnDocument
|
||||
from datetime import datetime
|
||||
import GlobalVariable as MYSY_GV
|
||||
|
||||
|
||||
|
||||
|
@ -145,7 +146,7 @@ def add_partner_account(diction):
|
|||
print(str(datetime.now()) + " webservice : diction = "+str(mydata))
|
||||
|
||||
|
||||
coll_name = dbname['partnair_account']
|
||||
coll_name = MYSY_GV.dbname['partnair_account']
|
||||
|
||||
|
||||
# Verification que cette adresse email n'existe pas
|
||||
|
@ -243,7 +244,7 @@ def update_partner_main_mail(diction):
|
|||
mydata['date_update'] = str(datetime.now())
|
||||
|
||||
|
||||
coll_name = dbname['partnair_account']
|
||||
coll_name = MYSY_GV.dbname['partnair_account']
|
||||
|
||||
ret_val = coll_name.find_one_and_update(
|
||||
{'recid': str(partner_recid), 'locked': '0', 'active': '1', 'email':mymail},
|
||||
|
@ -346,7 +347,7 @@ def update_partner_pwd(diction):
|
|||
#print(mydata)
|
||||
|
||||
|
||||
coll_name = dbname['partnair_account']
|
||||
coll_name = MYSY_GV.dbname['partnair_account']
|
||||
|
||||
ret_val = coll_name.find_one_and_update(
|
||||
{'recid': str(partner_recid), 'locked': '0', 'active': '1', 'pwd':mypwd},
|
||||
|
@ -492,7 +493,7 @@ def update_partner_account(diction):
|
|||
|
||||
#print(str(datetime.now()) + " webservice : diction = " + str(mydata))
|
||||
|
||||
coll_name = dbname['partnair_account']
|
||||
coll_name = MYSY_GV.dbname['partnair_account']
|
||||
|
||||
|
||||
|
||||
|
@ -525,7 +526,7 @@ def valide_partnair_account(value):
|
|||
try:
|
||||
client = MongoClient(CONNECTION_STRING)
|
||||
dbname = client['cherifdb']
|
||||
coll_name = dbname['partnair_account']
|
||||
coll_name = MYSY_GV.dbname['partnair_account']
|
||||
|
||||
tmp = coll_name.find({'_id':ObjectId(str(value))})
|
||||
|
||||
|
@ -592,10 +593,10 @@ def get_partner_account(diction):
|
|||
token_value = diction['token']
|
||||
|
||||
|
||||
coll_name = dbname['partnair_account']
|
||||
coll_name = MYSY_GV.dbname['partnair_account']
|
||||
|
||||
# Verification de la valididé du token
|
||||
coll_token = dbname['user_token']
|
||||
coll_token = MYSY_GV.dbname['user_token']
|
||||
|
||||
# Verification de la validité du token/mail dans le cas des user en mode connecté
|
||||
retval = mycommon.check_partner_token_validity(email_value, token_value )
|
||||
|
@ -612,7 +613,7 @@ def get_partner_account(diction):
|
|||
return False
|
||||
'''
|
||||
|
||||
coll_token = dbname['partner_token']
|
||||
coll_token = MYSY_GV.dbname['partner_token']
|
||||
tmp = coll_token.find({ 'token': str(token_value), 'valide': '1'})
|
||||
partnere_recid = tmp[0]['recid']
|
||||
|
||||
|
@ -693,7 +694,7 @@ def partner_login(diction):
|
|||
|
||||
|
||||
# Verification que les informations sont juste
|
||||
coll_name = dbname['partnair_account']
|
||||
coll_name = MYSY_GV.dbname['partnair_account']
|
||||
ret_val = coll_name.find_one_and_update({'email': str(email), 'pwd': str(pwd), 'token': str(token), 'active': '1', 'locked':'0'},
|
||||
{"$set": {'last_connexion':str(now)}},
|
||||
upsert=True,
|
||||
|
@ -706,7 +707,7 @@ def partner_login(diction):
|
|||
|
||||
#print(" GRRRRRRRRRRRRRRRRRRR "+str(ret_val))
|
||||
mydata['recid'] = str(ret_val['recid'])
|
||||
token_collection = dbname['partner_token']
|
||||
token_collection = MYSY_GV.dbname['partner_token']
|
||||
|
||||
ret_val2 = token_collection.find_one_and_update({'recid': str(mydata['recid']), 'valide': '1', 'locked':'0'},
|
||||
{"$set": mydata},
|
||||
|
|
|
@ -1204,7 +1204,7 @@ def recordImage(file=None, Folder=None, diction=None):
|
|||
try:
|
||||
|
||||
# Dictionnaire des champs utilisables
|
||||
field_list = ['token']
|
||||
field_list = ['token', 'type']
|
||||
incom_keys = diction.keys()
|
||||
|
||||
'''
|
||||
|
@ -1223,7 +1223,7 @@ def recordImage(file=None, Folder=None, diction=None):
|
|||
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']
|
||||
field_list_obligatoire = ['token', 'type']
|
||||
for val in field_list_obligatoire:
|
||||
if str(val).lower() not in diction:
|
||||
mycommon.myprint(
|
||||
|
@ -1239,6 +1239,13 @@ def recordImage(file=None, Folder=None, diction=None):
|
|||
mytoken = diction['token']
|
||||
|
||||
|
||||
mytype = ""
|
||||
# recuperation des paramettre
|
||||
if ("type" in diction.keys()):
|
||||
if diction['type']:
|
||||
mytype = diction['type']
|
||||
|
||||
|
||||
'''
|
||||
Verification de la validité du token et recuperation du recid du user
|
||||
'''
|
||||
|
@ -1249,10 +1256,19 @@ def recordImage(file=None, Folder=None, diction=None):
|
|||
return False, "L'email ou le token ne sont pas valident"
|
||||
|
||||
# Recuperation du recid de la personne
|
||||
user_recid = get_user_recid_from_token(str(mytoken))
|
||||
if user_recid is False:
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - Impossible de recuperer le recid du user")
|
||||
return False, " Les informations d'identification sont incorrectes"
|
||||
if( mytype == "user"):
|
||||
user_recid = get_user_recid_from_token(str(mytoken))
|
||||
if user_recid is False:
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - Impossible de recuperer le recid du user")
|
||||
return False, " Les informations d'identification sont incorrectes"
|
||||
|
||||
elif( mytype == "partner"):
|
||||
user_recid = get_parnter_recid_from_token(str(mytoken))
|
||||
if user_recid is False:
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - Impossible de recuperer le recid du partner")
|
||||
return False, " Les informations d'identification sont incorrectes"
|
||||
|
||||
|
||||
|
||||
myuserrecid = user_recid
|
||||
|
||||
|
@ -1312,7 +1328,7 @@ Test de recuperation d'une image
|
|||
def getRecodedImage(diction=None):
|
||||
try:
|
||||
# Dictionnaire des champs utilisables
|
||||
field_list = ['token']
|
||||
field_list = ['token', 'type']
|
||||
incom_keys = diction.keys()
|
||||
|
||||
'''
|
||||
|
@ -1331,7 +1347,7 @@ def getRecodedImage(diction=None):
|
|||
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']
|
||||
field_list_obligatoire = ['token','type']
|
||||
for val in field_list_obligatoire:
|
||||
if str(val).lower() not in diction:
|
||||
mycommon.myprint(
|
||||
|
@ -1346,6 +1362,11 @@ def getRecodedImage(diction=None):
|
|||
if diction['token']:
|
||||
mytoken = diction['token']
|
||||
|
||||
mytype = ""
|
||||
if ("type" in diction.keys()):
|
||||
if diction['type']:
|
||||
mytype = diction['type']
|
||||
|
||||
'''
|
||||
Verification de la validité du token et recuperation du recid du user
|
||||
'''
|
||||
|
@ -1356,10 +1377,17 @@ def getRecodedImage(diction=None):
|
|||
return False, "L'email ou le token ne sont pas valident"
|
||||
|
||||
# Recuperation du recid de la personne
|
||||
user_recid = get_user_recid_from_token(str(mytoken))
|
||||
if user_recid is False:
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - Impossible de recuperer le recid du user")
|
||||
return False, " Les informations d'identification sont incorrectes"
|
||||
if( mytype == "user"):
|
||||
user_recid = get_user_recid_from_token(str(mytoken))
|
||||
if user_recid is False:
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - Impossible de recuperer le recid du user")
|
||||
return False, " Les informations d'identification sont incorrectes"
|
||||
|
||||
elif (mytype == "partner"):
|
||||
user_recid = get_parnter_recid_from_token(str(mytoken))
|
||||
if user_recid is False:
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - Impossible de recuperer le recid du user")
|
||||
return False, " Les informations d'identification sont incorrectes"
|
||||
|
||||
myuserrecid = user_recid
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ import prj_common as mycommon
|
|||
from pymongo import ReturnDocument
|
||||
import inspect
|
||||
import sys, os
|
||||
import GlobalVariable as MYSY_GV
|
||||
|
||||
TOKEN_SIZE = 25
|
||||
CONNECTION_STRING = "mongodb://localhost/cherifdb"
|
||||
|
@ -81,7 +82,7 @@ def login(diction):
|
|||
|
||||
|
||||
# Recuperation du RecId du user connecté
|
||||
coll_name = dbname['user_account']
|
||||
coll_name = MYSY_GV.dbname['user_account']
|
||||
|
||||
|
||||
print(" on recherche ici " + email)
|
||||
|
|
Loading…
Reference in New Issue