22/11/2024 - 18h
parent
f39ee004d4
commit
64e1fb5b93
|
@ -4,6 +4,8 @@
|
|||
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="qsd">
|
||||
<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$/articles_avis.py" beforeDir="false" afterPath="$PROJECT_DIR$/articles_avis.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
|
|
5477
Log/log_file.log
5477
Log/log_file.log
File diff suppressed because it is too large
Load Diff
457
articles_avis.py
457
articles_avis.py
|
@ -65,12 +65,15 @@ def get_all_articles_avis(diction):
|
|||
"valide": 0, "locked": 0, }).sort(
|
||||
[ ("date_avis",pymongo.DESCENDING), ("title_formation",pymongo.ASCENDING),]):
|
||||
# mycommon.myprint("AVANT ==> "+str(x['description']))
|
||||
val = x['qualite']
|
||||
if (len(x['qualite']) > MYSY_GV.MAX_CARACT):
|
||||
x['qualite'] = val[:MYSY_GV.MAX_CARACT] + " ..."
|
||||
if( "qualite" in x.keys() ):
|
||||
val = x['qualite']
|
||||
if (len(x['qualite']) > MYSY_GV.MAX_CARACT):
|
||||
x['qualite'] = val[:MYSY_GV.MAX_CARACT] + " ..."
|
||||
|
||||
else:
|
||||
x['qualite'] = val[:MYSY_GV.MAX_CARACT]
|
||||
else:
|
||||
x['qualite'] = val[:MYSY_GV.MAX_CARACT]
|
||||
else :
|
||||
x['qualite'] = "--"
|
||||
|
||||
val = x['avis']
|
||||
CLEANR = re.compile('<.*?>')
|
||||
|
@ -150,12 +153,13 @@ def get_last_3_articles(diction):
|
|||
"valide": 0, "locked": 0, }).limit(3).sort(
|
||||
[ ("date_avis",pymongo.DESCENDING), ("title_formation",pymongo.ASCENDING),]):
|
||||
# mycommon.myprint("AVANT ==> "+str(x['description']))
|
||||
val = x['qualite']
|
||||
if (len(x['qualite']) > MYSY_GV.MAX_CARACT):
|
||||
x['qualite'] = val[:MYSY_GV.MAX_CARACT] + " ..."
|
||||
if( "qualite" in x.keys() ):
|
||||
val = x['qualite']
|
||||
if (len(x['qualite']) > MYSY_GV.MAX_CARACT):
|
||||
x['qualite'] = val[:MYSY_GV.MAX_CARACT] + " ..."
|
||||
|
||||
else:
|
||||
x['qualite'] = val[:MYSY_GV.MAX_CARACT]
|
||||
else:
|
||||
x['qualite'] = val[:MYSY_GV.MAX_CARACT]
|
||||
|
||||
val = x['avis']
|
||||
CLEANR = re.compile('<.*?>')
|
||||
|
@ -297,6 +301,79 @@ def get_articles_avis(diction):
|
|||
return False, " Impossible de récupérer l'article/avis"
|
||||
|
||||
|
||||
'''
|
||||
Cette API recupere et retourne un articles / avis en partant de l'_id
|
||||
'''
|
||||
def get_articles_avis_from_id(diction):
|
||||
try:
|
||||
|
||||
# Dictionnaire des champs utilisables
|
||||
field_list = ['internal_url', 'token', 'user_ip', 'user_country_code', 'user_country_name',
|
||||
'user_city','user_postal', 'user_latitude', 'user_longitude', 'user_state', '_id']
|
||||
|
||||
incom_keys = diction.keys()
|
||||
|
||||
'''
|
||||
# Verification que les champs reçus dans l'API sont bien dans la liste des champs autorisés
|
||||
# Cela evite le cas ou une entité tierce ajouter les valeurs inconnu dans l'API
|
||||
# Ici on doit mettre tous les champs possible (obligatoire ou non) de la BDD dans la liste
|
||||
# field_list.
|
||||
'''
|
||||
for val in incom_keys:
|
||||
if str(val).lower() not in str(field_list).lower():
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " Le champ '" + val + "' n'est pas autorisé")
|
||||
return False, " Impossible de récupérer l'articles/avis"
|
||||
|
||||
'''
|
||||
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 = ['_id',]
|
||||
|
||||
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, " Impossible de récupérer l'articles/avis"
|
||||
|
||||
|
||||
|
||||
# Recuperation des parametres
|
||||
mydata = {}
|
||||
|
||||
|
||||
|
||||
#print(" My Data =" + str(mydata))
|
||||
|
||||
coll_name = MYSY_GV.dbname['articles_avis']
|
||||
insertObject = []
|
||||
|
||||
cpt = 0
|
||||
|
||||
for x in coll_name.find({'valide': '1', 'locked': '0', '_id':ObjectId(str(diction['_id']))},
|
||||
{ "indexed": 0, "indexed_desc": 0, "indexed_obj": 0, "indexed_title": 0,
|
||||
"valide": 0, "locked": 0, }).sort([("title_formation",pymongo.ASCENDING),
|
||||
("date_avis",pymongo.ASCENDING),
|
||||
("note", pymongo.DESCENDING),
|
||||
]) :
|
||||
cpt = cpt + 1
|
||||
user = x
|
||||
insertObject.append(JSONEncoder().encode(user))
|
||||
|
||||
if( cpt == 0 ):
|
||||
return False, "Identifiant de l'article est invalide"
|
||||
|
||||
#print(" getObject = ", str(insertObject))
|
||||
return True, insertObject
|
||||
|
||||
|
||||
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 récupérer l'article/avis"
|
||||
|
||||
|
||||
|
||||
'''
|
||||
Cette fonction crée un articles avis, avec les element de traàabilité :
|
||||
- user_recid,
|
||||
|
@ -319,7 +396,9 @@ def add_articles_avis(diction):
|
|||
field_list = ['token', 'title_formation', 'user_ip', 'user_country_code', 'user_country_name',
|
||||
'user_city', 'user_postal', 'user_latitude', 'user_longitude', 'user_state',
|
||||
'type_formation', 'qualite', 'avis', 'note', 'qualityrating','avisrating',
|
||||
'comment', 'postedby', 'url_formation', 'user_recid']
|
||||
'comment', 'postedby', 'url_formation', 'user_recid', 'display_header_img',
|
||||
'img_path', 'date_publication']
|
||||
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
if val not in field_list and val.startswith('my_') is False:
|
||||
|
@ -331,7 +410,7 @@ def add_articles_avis(diction):
|
|||
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 = ['title_formation', 'url_formation', 'token', 'avis', 'avis', 'user_ip',
|
||||
field_list_obligatoire = ['title_formation', 'token', 'avis', 'user_ip',
|
||||
'qualite', 'note']
|
||||
|
||||
for val in field_list_obligatoire:
|
||||
|
@ -347,36 +426,24 @@ def add_articles_avis(diction):
|
|||
# recuperation des paramettre
|
||||
mydata = {}
|
||||
|
||||
my_user_recid = 'None'
|
||||
my_token = 'None'
|
||||
|
||||
"""
|
||||
Verification de l'identité et autorisation de l'entité qui
|
||||
appelle cette API
|
||||
"""
|
||||
token = ""
|
||||
if ("token" in diction.keys()):
|
||||
if diction['token']:
|
||||
my_token = diction['token']
|
||||
token = diction['token']
|
||||
|
||||
# Verification de la validité du token
|
||||
'''
|
||||
Si un token est fourni, c'est que la personne est user connecté. on doit donc verifier la validé du token
|
||||
si le token est vide, alors c'est un user en mode non connecté
|
||||
|
||||
'''
|
||||
retval = mycommon.check_token_validity("", str(diction['token']))
|
||||
local_status, my_partner = mycommon.Check_Connexion_And_Return_Partner_Data({'token': str(token)})
|
||||
if (local_status is not True):
|
||||
return local_status, my_partner
|
||||
|
||||
if retval is False:
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - La session de connexion n'est pas valide")
|
||||
return False, "L'email ou le token ne sont pas valident"
|
||||
|
||||
# Recuperation du recid du partenaire
|
||||
user_recid = mycommon.get_user_recid_from_token(my_token)
|
||||
if user_recid is False:
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - Impossible de récupérer le recid de l'utilisateur")
|
||||
return False, " Les informations d'identification sont incorrectes"
|
||||
|
||||
my_user_recid = user_recid
|
||||
my_user_recid = my_partner['recid']
|
||||
|
||||
|
||||
mydata['user_recid'] = my_user_recid
|
||||
mydata['token'] = my_token
|
||||
mydata['token'] = token
|
||||
|
||||
if ("title_formation" in diction.keys()):
|
||||
if diction['title_formation']:
|
||||
|
@ -401,6 +468,271 @@ def add_articles_avis(diction):
|
|||
|
||||
mydata['internal_url'] = my_internal_url
|
||||
|
||||
if ("display_header_img" in diction.keys()):
|
||||
if diction['display_header_img']:
|
||||
mydata['display_header_img'] = diction['display_header_img']
|
||||
|
||||
if ("img_path" in diction.keys()):
|
||||
if diction['img_path']:
|
||||
mydata['img_path'] = diction['img_path']
|
||||
|
||||
if ("date_publication" in diction.keys()):
|
||||
if diction['date_publication']:
|
||||
date_publication = str(diction['date_publication']).strip()
|
||||
|
||||
local_status = mycommon.CheckisDate(date_publication)
|
||||
if (local_status is False):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " La date de publication n'est pas au format 'jj/mm/aaaa' ")
|
||||
return False, " La date de publication n'est pas au format 'jj/mm/aaaa' "
|
||||
|
||||
date_str = str(date_publication)[0:10]
|
||||
date_format = '%d/%m/%Y'
|
||||
date_obj = datetime.strptime(date_str, date_format)
|
||||
formated_date_publication = str(date_obj.strftime("%Y-%m-%d %H:%M:%S"))
|
||||
mydata['date_publication'] = formated_date_publication
|
||||
|
||||
|
||||
|
||||
if ("user_ip" in diction.keys()):
|
||||
if diction['user_ip']:
|
||||
mydata['user_ip'] = diction['user_ip']
|
||||
|
||||
if ("user_country_code" in diction.keys()):
|
||||
if diction['user_country_code']:
|
||||
mydata['user_country_code'] = diction['user_country_code']
|
||||
|
||||
if ("user_country_name" in diction.keys()):
|
||||
if diction['user_country_name']:
|
||||
mydata['user_country_name'] = diction['user_country_name']
|
||||
|
||||
if ("user_city" in diction.keys()):
|
||||
if diction['user_city']:
|
||||
mydata['user_city'] = diction['user_city']
|
||||
|
||||
if ("user_postal" in diction.keys()):
|
||||
if diction['user_postal']:
|
||||
mydata['user_postal'] = diction['user_postal']
|
||||
|
||||
if ("user_latitude" in diction.keys()):
|
||||
if diction['user_latitude']:
|
||||
mydata['user_latitude'] = diction['user_latitude']
|
||||
|
||||
if ("user_longitude" in diction.keys()):
|
||||
if diction['user_longitude']:
|
||||
mydata['user_longitude'] = diction['user_longitude']
|
||||
|
||||
if ("user_state" in diction.keys()):
|
||||
if diction['user_state']:
|
||||
mydata['user_state'] = diction['user_state']
|
||||
|
||||
if ("type_formation" in diction.keys()):
|
||||
if diction['type_formation']:
|
||||
mydata['type_formation'] = diction['type_formation']
|
||||
|
||||
if ("qualite" in diction.keys()):
|
||||
if diction['qualite']:
|
||||
mydata['qualite'] = diction['qualite']
|
||||
|
||||
if ("avis" in diction.keys()):
|
||||
if diction['avis']:
|
||||
mydata['avis'] = diction['avis']
|
||||
|
||||
if ("note" in diction.keys()):
|
||||
if diction['note']:
|
||||
mydata['note'] = diction['note']
|
||||
|
||||
if ("comment" in diction.keys()):
|
||||
if diction['comment']:
|
||||
mydata['comment'] = diction['comment']
|
||||
|
||||
if ("postedby" in diction.keys()):
|
||||
if diction['postedby']:
|
||||
mydata['postedby'] = diction['postedby']
|
||||
|
||||
if ("url_formation" in diction.keys()):
|
||||
if diction['url_formation']:
|
||||
mydata['url_formation'] = diction['url_formation']
|
||||
|
||||
if ("avisrating" in diction.keys()):
|
||||
if diction['avisrating']:
|
||||
mydata['avisrating'] = diction['avisrating']
|
||||
|
||||
if ("qualityrating" in diction.keys()):
|
||||
if diction['qualityrating']:
|
||||
mydata['qualityrating'] = diction['qualityrating']
|
||||
|
||||
mydata['valide'] = '1'
|
||||
mydata['locked'] = '0'
|
||||
mydata['indexed'] = '0'
|
||||
mydata['indexed'] = '0'
|
||||
mydata['date_update'] = str(datetime.now())
|
||||
mydata['date_avis'] = str(datetime.now())
|
||||
mydata['isalaune'] = "0"
|
||||
|
||||
#print(mydata)
|
||||
|
||||
coll_name = MYSY_GV.dbname['articles_avis']
|
||||
ret_val = coll_name.insert_one(mydata)
|
||||
|
||||
return True, " L'article/avis a été bien ajouté"
|
||||
"""
|
||||
if (ret_val and ret_val.inserted_id):
|
||||
nb_doc = str(ret_val.inserted_id)
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " - L'article/avis a été bien ajouté =" + str(nb_doc))
|
||||
|
||||
'''
|
||||
Vu que l'ajout a bien ete fait, on declenche l'envoie de l'email (enregistrement
|
||||
dans la collection "user_message". c'est un cron qui enverra l'email plus tard.
|
||||
'''
|
||||
notif_dict = {}
|
||||
|
||||
notif_dict['type'] = 'email'
|
||||
notif_dict['sender_mail']= MYSY_GV.INTERNAL_MAIL_SENDER
|
||||
notif_dict['sender_tel'] = MYSY_GV.INTERNAL_TEL_SENDER
|
||||
notif_dict['recever_mail'] = MYSY_GV.INTERNAL_MAIL_RECEVER
|
||||
notif_dict['recever_tel'] = MYSY_GV.INTERNAL_TEL_RECEVER
|
||||
notif_dict['object'] = 'Nouvel article par utilisateur : '+str(ret_val.inserted_id)
|
||||
notif_dict['message'] = 'Merci de verifier et valider article _id='+str(ret_val.inserted_id)
|
||||
notif_dict['token'] = ''
|
||||
notif_dict['user_ip'] = ''
|
||||
notif_dict['user_country_code'] = ''
|
||||
notif_dict['user_country_name'] = ''
|
||||
notif_dict['user_city'] = ''
|
||||
notif_dict['user_postal'] = ''
|
||||
notif_dict['user_latitude'] = ''
|
||||
notif_dict['user_longitude'] = ''
|
||||
notif_dict['user_state'] = ''
|
||||
notif_dict['sender_name'] = 'systeme automatique'
|
||||
|
||||
|
||||
umm.add_user_message(notif_dict)
|
||||
|
||||
return True, " L'article/avis a été bien ajouté"
|
||||
|
||||
else:
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - Impossible d'ajouter L'article/avis. "+str(mydata) )
|
||||
return False, "Impossible d'ajouter L'article/avis "
|
||||
"""
|
||||
|
||||
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 créer l'article/avis"
|
||||
|
||||
|
||||
"""
|
||||
Cette fonction met à jour un article avis
|
||||
|
||||
/!\ : la mise à jour du titre ne modifie pas l'url interne car elle est potentiellement deja utilisée
|
||||
"""
|
||||
|
||||
|
||||
def update_articles_avis(diction):
|
||||
try:
|
||||
|
||||
'''
|
||||
# Verification que les champs reçus dans l'API sont bien dans la liste des champs autorisés
|
||||
# Cela evite le cas ou une entité tierce ajouter les valeurs inconnu dans l'API
|
||||
# Ici on doit mettre tous les champs possible (obligatoire ou non) de la BDD dans la liste
|
||||
# field_list.
|
||||
'''
|
||||
field_list = ['token', 'title_formation', 'user_ip', 'user_country_code', 'user_country_name',
|
||||
'user_city', 'user_postal', 'user_latitude', 'user_longitude', 'user_state',
|
||||
'type_formation', 'qualite', 'avis', 'note', 'qualityrating', 'avisrating',
|
||||
'comment', 'postedby', 'url_formation', 'user_recid', '_id','display_header_img',
|
||||
'img_path', 'date_publication']
|
||||
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
if val not in field_list and val.startswith('my_') is False:
|
||||
mycommon.myprint(str(inspect.stack()[0][
|
||||
3]) + " - Creation formation : Le champ '" + val + "' n'est pas autorisé, Creation formation annulée")
|
||||
return False, " Verifier votre API"
|
||||
|
||||
'''
|
||||
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 = ['title_formation', 'token', 'avis', 'user_ip',
|
||||
'qualite', 'note', '_id']
|
||||
|
||||
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, " Verifier les parametres de votre API"
|
||||
|
||||
'''
|
||||
Verification si le token et l'email sont valident
|
||||
'''
|
||||
|
||||
# recuperation des paramettre
|
||||
mydata = {}
|
||||
|
||||
my_user_recid = 'None'
|
||||
my_token = 'None'
|
||||
|
||||
"""
|
||||
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']
|
||||
|
||||
local_status, my_partner = mycommon.Check_Connexion_And_Return_Partner_Data({'token':str(token)})
|
||||
if (local_status is not True):
|
||||
return local_status, my_partner
|
||||
|
||||
"""
|
||||
Verifier la validité de l'article à mettre à jour
|
||||
"""
|
||||
|
||||
is_valide_article_avis_count = MYSY_GV.dbname['articles_avis'].count_documents({'_id':ObjectId(str(diction['_id'])),
|
||||
'valide':'1'})
|
||||
|
||||
if (is_valide_article_avis_count != 1):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " L'identifiant de l'article n'est pas valide ")
|
||||
return False, " L'identifiant de l'article n'est pas valide "
|
||||
|
||||
mydata['user_recid'] = my_partner['recid']
|
||||
mydata['token'] = my_token
|
||||
|
||||
if ("title_formation" in diction.keys()):
|
||||
if diction['title_formation']:
|
||||
mydata['title_formation'] = diction['title_formation']
|
||||
|
||||
|
||||
if ("display_header_img" in diction.keys()):
|
||||
if diction['display_header_img']:
|
||||
mydata['display_header_img'] = diction['display_header_img']
|
||||
|
||||
if ("img_path" in diction.keys()):
|
||||
if diction['img_path']:
|
||||
mydata['img_path'] = diction['img_path']
|
||||
|
||||
if ("date_publication" in diction.keys()):
|
||||
if diction['date_publication']:
|
||||
date_publication = str(diction['date_publication']).strip()
|
||||
|
||||
local_status = mycommon.CheckisDate(date_publication)
|
||||
if (local_status is False):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " La date de publication n'est pas au format 'jj/mm/aaaa' ")
|
||||
return False, " La date de publication n'est pas au format 'jj/mm/aaaa' "
|
||||
|
||||
date_str = str(date_publication)[0:10]
|
||||
date_format = '%d/%m/%Y'
|
||||
date_obj = datetime.strptime(date_str, date_format)
|
||||
formated_date_publication = str(date_obj.strftime("%Y-%m-%d %H:%M:%S"))
|
||||
mydata['date_publication'] = formated_date_publication
|
||||
|
||||
|
||||
if ("user_ip" in diction.keys()):
|
||||
if diction['user_ip']:
|
||||
|
@ -475,56 +807,27 @@ def add_articles_avis(diction):
|
|||
mydata['indexed'] = '0'
|
||||
mydata['indexed'] = '0'
|
||||
mydata['date_update'] = str(datetime.now())
|
||||
mydata['date_avis'] = str(datetime.now())
|
||||
mydata['isalaune'] = "0"
|
||||
|
||||
#print(mydata)
|
||||
mydata['valide'] = "1"
|
||||
mydata['locked'] = "0"
|
||||
mydata['date_update'] = str(datetime.now())
|
||||
mydata['update_by'] = str(my_partner['_id'])
|
||||
mydata['partner_owner_recid'] = str(my_partner['recid'])
|
||||
|
||||
coll_name = MYSY_GV.dbname['articles_avis']
|
||||
ret_val = coll_name.insert_one(mydata)
|
||||
ret_val = MYSY_GV.dbname['articles_avis'].find_one_and_update(
|
||||
{'_id': ObjectId(str(diction['_id'])), },
|
||||
{"$set": mydata},
|
||||
return_document=ReturnDocument.AFTER,
|
||||
upsert=False,
|
||||
)
|
||||
|
||||
if (ret_val and ret_val.inserted_id):
|
||||
nb_doc = str(ret_val.inserted_id)
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " - L'article/avis a été bien ajouté =" + str(nb_doc))
|
||||
|
||||
'''
|
||||
Vu que l'ajout a bien ete fait, on declenche l'envoie de l'email (enregistrement
|
||||
dans la collection "user_message". c'est un cron qui enverra l'email plus tard.
|
||||
'''
|
||||
notif_dict = {}
|
||||
|
||||
notif_dict['type'] = 'email'
|
||||
notif_dict['sender_mail']= MYSY_GV.INTERNAL_MAIL_SENDER
|
||||
notif_dict['sender_tel'] = MYSY_GV.INTERNAL_TEL_SENDER
|
||||
notif_dict['recever_mail'] = MYSY_GV.INTERNAL_MAIL_RECEVER
|
||||
notif_dict['recever_tel'] = MYSY_GV.INTERNAL_TEL_RECEVER
|
||||
notif_dict['object'] = 'Nouvel article par utilisateur : '+str(ret_val.inserted_id)
|
||||
notif_dict['message'] = 'Merci de verifier et valider article _id='+str(ret_val.inserted_id)
|
||||
notif_dict['token'] = ''
|
||||
notif_dict['user_ip'] = ''
|
||||
notif_dict['user_country_code'] = ''
|
||||
notif_dict['user_country_name'] = ''
|
||||
notif_dict['user_city'] = ''
|
||||
notif_dict['user_postal'] = ''
|
||||
notif_dict['user_latitude'] = ''
|
||||
notif_dict['user_longitude'] = ''
|
||||
notif_dict['user_state'] = ''
|
||||
notif_dict['sender_name'] = 'systeme automatique'
|
||||
|
||||
|
||||
umm.add_user_message(notif_dict)
|
||||
|
||||
return True, " L'article/avis a été bien ajouté"
|
||||
|
||||
else:
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - Impossible d'ajouter L'article/avis. "+str(mydata) )
|
||||
return False, "Impossible d'ajouter L'article/avis "
|
||||
return True, "L'article/avis 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) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
|
||||
return False, " Impossible de créer l'article/avis"
|
||||
return False, " Impossible de mettre à jour l'article/avis"
|
||||
|
||||
|
||||
'''
|
||||
|
|
34
main.py
34
main.py
|
@ -1268,17 +1268,33 @@ def get_last_3_articles():
|
|||
|
||||
|
||||
'''
|
||||
Cette API recupere un article/avis donné
|
||||
Cette API recupere un article/avis donné en partant de l'internal_url
|
||||
'''
|
||||
@app.route('/myclass/api/get_articles_avis/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def get_articles_avis():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### get_articles_avis : payload = ",payload)
|
||||
print(" ### get_articles_avis : payload = (trop long cherif) ",)
|
||||
status, retval = aa.get_articles_avis(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
|
||||
'''
|
||||
Cette API recupere un article/avis donné en partant de l'_id
|
||||
'''
|
||||
@app.route('/myclass/api/get_articles_avis_from_id/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def get_articles_avis_from_id():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### get_articles_avis_from_id : payload = (trop long cherif)")
|
||||
status, retval = aa.get_articles_avis_from_id(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
|
||||
'''
|
||||
Cette API ajouter un article/avis
|
||||
'''
|
||||
|
@ -1287,10 +1303,22 @@ Cette API ajouter un article/avis
|
|||
def add_articles_avis():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### payload = ",payload)
|
||||
print(" ### payload = payload = (trop long cherif) ")
|
||||
status, retval = aa.add_articles_avis(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
'''
|
||||
Cette API met à jour un article/avis
|
||||
'''
|
||||
@app.route('/myclass/api/update_articles_avis/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def update_articles_avis():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### update_articles_avis = payload = (trop long cherif) ")
|
||||
status, retval = aa.update_articles_avis(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
'''
|
||||
Cette API indexe les articles et avis postés
|
||||
|
|
Loading…
Reference in New Issue