26/11/22 - 23h30

master
cherif 2022-11-26 23:42:35 +01:00
parent d0b5aaefce
commit 2ce66f160f
6 changed files with 1253 additions and 19 deletions

View File

@ -1,9 +1,8 @@
<?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="1122d9e2-679f-46d6-8c4f-97e9ae4041b5" name="Changes" comment="23/11/22 - 22h30"> <list default="true" id="1122d9e2-679f-46d6-8c4f-97e9ae4041b5" name="Changes" comment="26/11/22 - 10h30">
<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$/GlobalVariable.py" beforeDir="false" afterPath="$PROJECT_DIR$/GlobalVariable.py" 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$/data_indexees.csv" beforeDir="false" afterPath="$PROJECT_DIR$/data_indexees.csv" afterDir="false" /> <change beforePath="$PROJECT_DIR$/data_indexees.csv" beforeDir="false" afterPath="$PROJECT_DIR$/data_indexees.csv" afterDir="false" />
<change beforePath="$PROJECT_DIR$/ela_output_test_file_pandas_2.txt" beforeDir="false" afterPath="$PROJECT_DIR$/ela_output_test_file_pandas_2.txt" afterDir="false" /> <change beforePath="$PROJECT_DIR$/ela_output_test_file_pandas_2.txt" beforeDir="false" afterPath="$PROJECT_DIR$/ela_output_test_file_pandas_2.txt" afterDir="false" />
@ -116,7 +115,14 @@
<option name="project" value="LOCAL" /> <option name="project" value="LOCAL" />
<updated>1669238673106</updated> <updated>1669238673106</updated>
</task> </task>
<option name="localTasksCounter" value="8" /> <task id="LOCAL-00008" summary="26/11/22 - 10h30">
<created>1669456627336</created>
<option name="number" value="00008" />
<option name="presentableId" value="LOCAL-00008" />
<option name="project" value="LOCAL" />
<updated>1669456627336</updated>
</task>
<option name="localTasksCounter" value="9" />
<servers /> <servers />
</component> </component>
<component name="Vcs.Log.Tabs.Properties"> <component name="Vcs.Log.Tabs.Properties">
@ -137,14 +143,15 @@
<MESSAGE value="22/11/22 - 11h30" /> <MESSAGE value="22/11/22 - 11h30" />
<MESSAGE value="22/11/22 - 22h30" /> <MESSAGE value="22/11/22 - 22h30" />
<MESSAGE value="23/11/22 - 22h30" /> <MESSAGE value="23/11/22 - 22h30" />
<option name="LAST_COMMIT_MESSAGE" value="23/11/22 - 22h30" /> <MESSAGE value="26/11/22 - 10h30" />
<option name="LAST_COMMIT_MESSAGE" value="26/11/22 - 10h30" />
</component> </component>
<component name="XDebuggerManager"> <component name="XDebuggerManager">
<breakpoint-manager> <breakpoint-manager>
<breakpoints> <breakpoints>
<line-breakpoint enabled="true" suspend="THREAD" type="python-line"> <line-breakpoint enabled="true" suspend="THREAD" type="python-line">
<url>file://$PROJECT_DIR$/main.py</url> <url>file://$PROJECT_DIR$/main.py</url>
<line>242</line> <line>251</line>
<option name="timeStamp" value="1" /> <option name="timeStamp" value="1" />
</line-breakpoint> </line-breakpoint>
</breakpoints> </breakpoints>

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,3 @@
,index,mots,occurence,moyenne,id_formation,source_field ,index,mots,occurence,moyenne,id_formation,source_field
0,0,objet,1,0.33,3IL_10003,title 0,0,gestion,1,0.5,3IL_10001,title
1,1,iot,1,0.33,3IL_10003,title 1,1,projet,1,0.5,3IL_10001,title
2,2,connecte,1,0.33,3IL_10003,title

1 index mots occurence moyenne id_formation source_field
2 0 0 objet gestion 1 0.33 0.5 3IL_10003 3IL_10001 title
3 1 1 iot projet 1 0.33 0.5 3IL_10003 3IL_10001 title
2 2 connecte 1 0.33 3IL_10003 title

View File

@ -1,4 +1,3 @@
mots occurence moyenne id_formation source_field mots occurence moyenne id_formation source_field
0 objet 1 0.33 3IL_10003 title 0 gestion 1 0.5 3IL_10001 title
1 iot 1 0.33 3IL_10003 title 1 projet 1 0.5 3IL_10001 title
2 connecte 1 0.33 3IL_10003 title

View File

@ -118,7 +118,7 @@ def get_user_objectif(diction):
user = retVal user = retVal
user['id'] = str(val_tmp) user['id'] = str(val_tmp)
val_tmp = val_tmp+1 val_tmp = val_tmp+1
print(" #### user 1= "+str(user)) #print(" #### user 1= "+str(user))
RetObject.append(JSONEncoder().encode(user)) RetObject.append(JSONEncoder().encode(user))
else : else :
for retVal in coll_name.find(query): for retVal in coll_name.find(query):
@ -131,7 +131,7 @@ def get_user_objectif(diction):
user['id'] = str(val_tmp) user['id'] = str(val_tmp)
user['description'] = val user['description'] = val
val_tmp = val_tmp+1 val_tmp = val_tmp+1
print(" #### user 2 = "+str(user)) #print(" #### user 2 = "+str(user))
RetObject.append(JSONEncoder().encode(user)) RetObject.append(JSONEncoder().encode(user))
return True, RetObject return True, RetObject
@ -420,7 +420,7 @@ def add_update_user_profile(diction):
#mycommon.myprint(" on recherche recid "+user_recid) #mycommon.myprint(" on recherche recid "+user_recid)
ret_val = coll_name.find_one_and_update( ret_val = coll_name.find_one_and_update(
{'user_recid': user_recid, 'name':str(diction['name']), 'active': '1'}, {'user_recid': user_recid, 'active': '1'},
{"$set": my_data}, {"$set": my_data},
upsert=True, upsert=True,
return_document=ReturnDocument.AFTER return_document=ReturnDocument.AFTER
@ -441,6 +441,68 @@ def add_update_user_profile(diction):
return False, " Impossible de mettre à jour les objectifs utilisateur" return False, " Impossible de mettre à jour les objectifs utilisateur"
"""
Recuperation du profil d'un utilisateur
"""
def Get_user_profile(diction):
try:
# Dictionnaire des champs utilisables
field_list = [ 'token']
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(" Le champ '" + val + "' n'existe pas, MAJ annulée")
return False, " Impossible de recuperer le profil de l'utilisateur"
'''
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']
for val in field_list_obligatoire :
if str(val).lower() not in diction:
mycommon.myprint(" La valeur '"+val+"' n'est pas presente dans liste ")
return False, " Impossible de recuperer le profil de l'utilisateur"
# recuperation des paramettre
user_token = ""
user_recid = ""
if ("token" in diction.keys()):
if diction['token']:
user_token = diction['token']
# Recuperation du recid de l'utilisateur
user_recid = mycommon.get_user_recid_from_token(user_token)
if user_token is False :
mycommon.myprint(" Impossible de recuperer le profil de l'utilisateur")
return False, " Impossible de recuperer le profil de l'utilisateur"
coll_name = MYSY_GV.dbname['user_profil']
insertObject = []
for val in coll_name.find( {'user_recid': str(user_recid), 'active': '1'}, {'_id':0, 'user_recid':0}):
insertObject.append(mycommon.JSONEncoder().encode(val))
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 recuperer le profil de l'utilisateur"
def add_user_account(diction): def add_user_account(diction):
try: try:

17
main.py
View File

@ -137,7 +137,7 @@ si le nom de la formation est fourni, alors l'api va retourner la formation donn
def get_user_objectif(): def get_user_objectif():
# On recupere le corps (payload) de la requete # On recupere le corps (payload) de la requete
payload = request.form.to_dict() payload = request.form.to_dict()
print(" ### get_user_objectif : payload = ",payload) print(" ### get_user_objectif : payload = ",payload)
status, retval = eua.get_user_objectif(payload) status, retval = eua.get_user_objectif(payload)
return jsonify(status=status, message=retval) return jsonify(status=status, message=retval)
@ -196,12 +196,21 @@ Cette API met à jour le profile d'un utilisateur
def add_update_user_profile(): def add_update_user_profile():
# On recupere le corps (payload) de la requete # On recupere le corps (payload) de la requete
payload = request.form.to_dict() payload = request.form.to_dict()
print(" ### payload = ",payload) print(" ### add_update_user_profile : payload = ",payload)
status, retval = eua.add_update_user_profile(payload) status, retval = eua.add_update_user_profile(payload)
return jsonify(status=status, message=retval) return jsonify(status=status, message=retval)
"""
API de recuperation du profils d'un utilisateur
"""
@app.route('/myclass/api/Get_user_profile/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_user_profile():
# On recupere le corps (payload) de la requete
payload = request.form.to_dict()
print(" ### Get_user_profile : payload = ",payload)
status, retval = eua.Get_user_profile(payload)
return jsonify(status=status, message=retval)
''' '''
Cette Api retourne les info d'un user accout identifié par Cette Api retourne les info d'un user accout identifié par
son adresse email. son adresse email.