qsdsqqs
parent
1853e18ecf
commit
c87b8141ce
|
@ -1,10 +1,11 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="13/10/2024 - sdfqsdqs14h">
|
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="qsdsq">
|
||||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
<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$/Log/log_file.log" beforeDir="false" afterPath="$PROJECT_DIR$/Log/log_file.log" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/partner_order.py" beforeDir="false" afterPath="$PROJECT_DIR$/partner_order.py" 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>
|
</list>
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||||
|
@ -74,13 +75,6 @@
|
||||||
<option name="presentableId" value="Default" />
|
<option name="presentableId" value="Default" />
|
||||||
<updated>1680804787304</updated>
|
<updated>1680804787304</updated>
|
||||||
</task>
|
</task>
|
||||||
<task id="LOCAL-00361" summary="29/07/2024 - 21h">
|
|
||||||
<created>1722279870243</created>
|
|
||||||
<option name="number" value="00361" />
|
|
||||||
<option name="presentableId" value="LOCAL-00361" />
|
|
||||||
<option name="project" value="LOCAL" />
|
|
||||||
<updated>1722279870244</updated>
|
|
||||||
</task>
|
|
||||||
<task id="LOCAL-00362" summary="30/07/2024 - 12h">
|
<task id="LOCAL-00362" summary="30/07/2024 - 12h">
|
||||||
<created>1722338918391</created>
|
<created>1722338918391</created>
|
||||||
<option name="number" value="00362" />
|
<option name="number" value="00362" />
|
||||||
|
@ -417,7 +411,14 @@
|
||||||
<option name="project" value="LOCAL" />
|
<option name="project" value="LOCAL" />
|
||||||
<updated>1729008318165</updated>
|
<updated>1729008318165</updated>
|
||||||
</task>
|
</task>
|
||||||
<option name="localTasksCounter" value="410" />
|
<task id="LOCAL-00410" summary="qsdsq">
|
||||||
|
<created>1729505558584</created>
|
||||||
|
<option name="number" value="00410" />
|
||||||
|
<option name="presentableId" value="LOCAL-00410" />
|
||||||
|
<option name="project" value="LOCAL" />
|
||||||
|
<updated>1729505558584</updated>
|
||||||
|
</task>
|
||||||
|
<option name="localTasksCounter" value="411" />
|
||||||
<servers />
|
<servers />
|
||||||
</component>
|
</component>
|
||||||
<component name="Vcs.Log.Tabs.Properties">
|
<component name="Vcs.Log.Tabs.Properties">
|
||||||
|
@ -459,7 +460,6 @@
|
||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
<component name="VcsManagerConfiguration">
|
<component name="VcsManagerConfiguration">
|
||||||
<MESSAGE value="31082024" />
|
|
||||||
<MESSAGE value="31/08/2024 - 18h50" />
|
<MESSAGE value="31/08/2024 - 18h50" />
|
||||||
<MESSAGE value="01/09/2024 - 14:00" />
|
<MESSAGE value="01/09/2024 - 14:00" />
|
||||||
<MESSAGE value="01/09/2024 - 20:00" />
|
<MESSAGE value="01/09/2024 - 20:00" />
|
||||||
|
@ -484,6 +484,7 @@
|
||||||
<MESSAGE value="13/10/2024 - 14h" />
|
<MESSAGE value="13/10/2024 - 14h" />
|
||||||
<MESSAGE value="13/10/2024 - sdf14h" />
|
<MESSAGE value="13/10/2024 - sdf14h" />
|
||||||
<MESSAGE value="13/10/2024 - sdfqsdqs14h" />
|
<MESSAGE value="13/10/2024 - sdfqsdqs14h" />
|
||||||
<option name="LAST_COMMIT_MESSAGE" value="13/10/2024 - sdfqsdqs14h" />
|
<MESSAGE value="qsdsq" />
|
||||||
|
<option name="LAST_COMMIT_MESSAGE" value="qsdsq" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
1566
Log/log_file.log
1566
Log/log_file.log
File diff suppressed because it is too large
Load Diff
|
@ -102,6 +102,93 @@ def get_all_articles_avis(diction):
|
||||||
return False, " Impossible de récupérer les articles et avis"
|
return False, " Impossible de récupérer les articles et avis"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
'''
|
||||||
|
Recuperation des derniers avis tous avis et commentaires
|
||||||
|
difference de celui en argument (les 3 derniers autre que celui en argument)
|
||||||
|
'''
|
||||||
|
def get_last_3_articles(diction):
|
||||||
|
try:
|
||||||
|
|
||||||
|
# Dictionnaire des champs utilisables
|
||||||
|
field_list = ['token', 'user_ip', 'user_country_code', 'user_country_name', 'user_city',
|
||||||
|
'user_postal', 'user_latitude', 'user_longitude', 'user_state', 'internal_url']
|
||||||
|
|
||||||
|
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 les articles et avis"
|
||||||
|
|
||||||
|
"""
|
||||||
|
Verification des champs obligatoires
|
||||||
|
"""
|
||||||
|
field_list_obligatoire = ['token', "internal_url", ]
|
||||||
|
|
||||||
|
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"
|
||||||
|
|
||||||
|
|
||||||
|
coll_name = MYSY_GV.dbname['articles_avis']
|
||||||
|
|
||||||
|
qry = {'internal_url' :{'$ne':str(diction['internal_url'])}, 'valide': '1', 'locked': '0'}
|
||||||
|
#print(" ### qry = ", qry)
|
||||||
|
val_tmp = 0
|
||||||
|
insertObject = []
|
||||||
|
for x in coll_name.find(qry,
|
||||||
|
{ "indexed": 0, "indexed_desc": 0, "indexed_obj": 0, "indexed_title": 0,
|
||||||
|
"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] + " ..."
|
||||||
|
|
||||||
|
else:
|
||||||
|
x['qualite'] = val[:MYSY_GV.MAX_CARACT]
|
||||||
|
|
||||||
|
val = x['avis']
|
||||||
|
CLEANR = re.compile('<.*?>')
|
||||||
|
|
||||||
|
clean_avis = re.sub(CLEANR, '', str(val))
|
||||||
|
clean_avis = str(clean_avis).replace(" ", " ");
|
||||||
|
|
||||||
|
#print(" ### CLEANRCLEANR = "+str(clean_avis))
|
||||||
|
|
||||||
|
if (len(clean_avis) > MYSY_GV.MAX_CARACT):
|
||||||
|
x['avis'] = clean_avis[:MYSY_GV.MAX_CARACT] + " ..."
|
||||||
|
|
||||||
|
else:
|
||||||
|
x['avis'] = str(clean_avis)
|
||||||
|
|
||||||
|
# mycommon.myprint("APRES ==> " + str(x['description']))
|
||||||
|
|
||||||
|
user = x
|
||||||
|
user['id'] = str(val_tmp)
|
||||||
|
insertObject.append(JSONEncoder().encode(user))
|
||||||
|
val_tmp = val_tmp + 1
|
||||||
|
|
||||||
|
#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 les articles et avis"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
'''
|
'''
|
||||||
Cette API recupere et retourne un articles / avis
|
Cette API recupere et retourne un articles / avis
|
||||||
'''
|
'''
|
||||||
|
|
16
main.py
16
main.py
|
@ -1245,11 +1245,25 @@ Cette API récupérer tous les articles et avis sur les formations
|
||||||
def get_all_articles_avis():
|
def get_all_articles_avis():
|
||||||
# On recupere le corps (payload) de la requete
|
# On recupere le corps (payload) de la requete
|
||||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||||
print(" ### payload = ",payload)
|
print(" ### payload get_all_articles_avis = ",payload)
|
||||||
status, retval = aa.get_all_articles_avis(payload)
|
status, retval = aa.get_all_articles_avis(payload)
|
||||||
return jsonify(status=status, message=retval)
|
return jsonify(status=status, message=retval)
|
||||||
|
|
||||||
|
|
||||||
|
'''
|
||||||
|
Cette API de Recuperation des derniers avis tous avis et commentaires
|
||||||
|
difference de celui en argument (les 3 derniers autre que celui en argument)
|
||||||
|
'''
|
||||||
|
@app.route('/myclass/api/get_last_3_articles/', methods=['POST','GET'])
|
||||||
|
@crossdomain(origin='*')
|
||||||
|
def get_last_3_articles():
|
||||||
|
# On recupere le corps (payload) de la requete
|
||||||
|
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||||
|
print(" ### payload get_last_3_articles_avis = ",payload)
|
||||||
|
status, retval = aa.get_last_3_articles(payload)
|
||||||
|
return jsonify(status=status, message=retval)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
'''
|
'''
|
||||||
Cette API recupere un article/avis donné
|
Cette API recupere un article/avis donné
|
||||||
|
|
Loading…
Reference in New Issue