10/04/2024 - 22h50
parent
e4f23ec32c
commit
5ce4aa4e4d
|
@ -1,10 +1,13 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="09/04/2024 - 23h50">
|
||||
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="10/04/2024 - 11h50">
|
||||
<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$/survey_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/survey_mgt.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/class_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/class_mgt.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/prj_common.py" beforeDir="false" afterPath="$PROJECT_DIR$/prj_common.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/wrapper.py" beforeDir="false" afterPath="$PROJECT_DIR$/wrapper.py" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
|
@ -74,13 +77,6 @@
|
|||
<option name="presentableId" value="Default" />
|
||||
<updated>1680804787304</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00215" summary="06/02/2024 -20h">
|
||||
<created>1707246725386</created>
|
||||
<option name="number" value="00215" />
|
||||
<option name="presentableId" value="LOCAL-00215" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1707246725386</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00216" summary="08/02/2024 -20h">
|
||||
<created>1707425449893</created>
|
||||
<option name="number" value="00216" />
|
||||
|
@ -417,7 +413,14 @@
|
|||
<option name="project" value="LOCAL" />
|
||||
<updated>1712699498318</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="264" />
|
||||
<task id="LOCAL-00264" summary="10/04/2024 - 11h50">
|
||||
<created>1712742562300</created>
|
||||
<option name="number" value="00264" />
|
||||
<option name="presentableId" value="LOCAL-00264" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1712742562301</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="265" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="Vcs.Log.Tabs.Properties">
|
||||
|
@ -459,7 +462,6 @@
|
|||
</option>
|
||||
</component>
|
||||
<component name="VcsManagerConfiguration">
|
||||
<MESSAGE value="ssdqs" />
|
||||
<MESSAGE value="07/03/2024 - 22h30" />
|
||||
<MESSAGE value="ddd" />
|
||||
<MESSAGE value="ddds" />
|
||||
|
@ -484,6 +486,7 @@
|
|||
<MESSAGE value="07/04/2024 - 19h19" />
|
||||
<MESSAGE value="09/04/2024 - 15h19" />
|
||||
<MESSAGE value="09/04/2024 - 23h50" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="09/04/2024 - 23h50" />
|
||||
<MESSAGE value="10/04/2024 - 11h50" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="10/04/2024 - 11h50" />
|
||||
</component>
|
||||
</project>
|
8232
Log/log_file.log
8232
Log/log_file.log
File diff suppressed because it is too large
Load Diff
222
class_mgt.py
222
class_mgt.py
|
@ -63,7 +63,7 @@ def add_class(diction):
|
|||
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, " Le champ '" + val + "' n'est pas autorisé, Creation formation annulée "
|
||||
return False, " Le champ '" + val + "' n'est pas autorisé, Creation formation annulée ", False
|
||||
|
||||
'''
|
||||
Une fois qu'on a controlé que toutes les clés mise dans l'API sont correcte. etape precedente,
|
||||
|
@ -74,7 +74,7 @@ def add_class(diction):
|
|||
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, " La valeur '" + val + "' n'est pas presente dans liste"
|
||||
return False, " La valeur '" + val + "' n'est pas presente dans liste", False
|
||||
|
||||
'''
|
||||
Verification si le token et l'email sont valident
|
||||
|
@ -99,13 +99,13 @@ def add_class(diction):
|
|||
|
||||
if retval is False:
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - La session de connexion n'est pas valide")
|
||||
return False, "Les informations d'identification ne sont pas valident"
|
||||
return False, "Les informations d'identification ne sont pas valident", False
|
||||
|
||||
# Recuperation du recid du partenaire
|
||||
user_recid = mycommon.get_parnter_recid_from_token(str(mydata['token']))
|
||||
if user_recid is False:
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - Impossible de récupérer le recid du partenaire")
|
||||
return False, " Les informations d'identification sont incorrectes"
|
||||
return False, " Les informations d'identification sont incorrectes", False
|
||||
|
||||
local_status, my_partner = mycommon.Check_Connexion_And_Return_Partner_Data({'token':str(diction['token'])})
|
||||
if (local_status is not True):
|
||||
|
@ -114,7 +114,7 @@ def add_class(diction):
|
|||
part_status, part_pack, part_pack_nb_training_auto = mycommon.Partner_Get_pack_nbTraining(user_recid)
|
||||
if( part_status is False):
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - Impossible de récupérer le pack et le nombre de formation du partenaire")
|
||||
return False, "Votre pack / abonnement ne permet pas de créer les formations. Verifiez votre abonnement "
|
||||
return False, "Votre pack / abonnement ne permet pas de créer les formations. Verifiez votre abonnement ", False
|
||||
"""
|
||||
Recuperation du nombre de formations actif de ce partner
|
||||
"""
|
||||
|
@ -122,7 +122,7 @@ def add_class(diction):
|
|||
if (part_status2 is False):
|
||||
mycommon.myprint(str(
|
||||
inspect.stack()[0][3]) + " - Impossible de récupérer le pack et le nombre de formation du partenaire")
|
||||
return False, " Les informations d'identification sont incorrectes"
|
||||
return False, " Les informations d'identification sont incorrectes", False
|
||||
|
||||
mydata['partner_owner_recid'] = user_recid
|
||||
|
||||
|
@ -180,7 +180,7 @@ def add_class(diction):
|
|||
return False, " - Impossible d'ajouter la formation "+str(diction['title'])+" Vous avez atteint le nombre maximum de formations autorisées (" + str(
|
||||
part_pack_nb_training_auto) + "" \
|
||||
"). La formation '" + str(
|
||||
diction['external_code']) + "' n'a pas été enregistrée"
|
||||
diction['external_code']) + "' n'a pas été enregistrée", False
|
||||
|
||||
status, class_internal_url = mycommon.CreateInternalUrl(diction['title'])
|
||||
|
||||
|
@ -240,7 +240,7 @@ def add_class(diction):
|
|||
|
||||
if (is_formateur_id_ok <= 0):
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - L'identifiant du formateur est invalide")
|
||||
return False, " L'identifiant du formateur est invalide "
|
||||
return False, " L'identifiant du formateur est invalide ", False
|
||||
|
||||
mydata['formateur_id'] = formateur_id
|
||||
|
||||
|
@ -259,7 +259,7 @@ def add_class(diction):
|
|||
str(inspect.stack()[0][3]) + " : le champ 'objectif' de la formation " + str(
|
||||
diction['external_code']) + " a plus de " + str(MYSY_GV.CLASS_ZONE_OBJECTIF_LIMIT) + " caractères")
|
||||
return False, " le champ 'objectif' de la formation " + str(
|
||||
mydata['external_code']) + " a plus de " + str(MYSY_GV.CLASS_ZONE_OBJECTIF_LIMIT) + " caractères"
|
||||
mydata['external_code']) + " a plus de " + str(MYSY_GV.CLASS_ZONE_OBJECTIF_LIMIT) + " caractères", False
|
||||
|
||||
mydata['objectif'] = objectif
|
||||
|
||||
|
@ -272,7 +272,7 @@ def add_class(diction):
|
|||
str(inspect.stack()[0][3]) + " : le champ 'Progamme' de La formation " + str(
|
||||
mydata['external_code']) + " a plus de " + str(MYSY_GV.CLASS_ZONE_PROGRAM_LIMIT) + " caractères")
|
||||
return False, " le champ 'Progamme' de La formation " + str(
|
||||
mydata['external_code']) + " a plus de " + str(MYSY_GV.CLASS_ZONE_PROGRAM_LIMIT) + " caractères"
|
||||
mydata['external_code']) + " a plus de " + str(MYSY_GV.CLASS_ZONE_PROGRAM_LIMIT) + " caractères", False
|
||||
|
||||
mydata['programme'] = programme
|
||||
|
||||
|
@ -286,7 +286,7 @@ def add_class(diction):
|
|||
mydata['external_code']) + " a plus de " + str(
|
||||
MYSY_GV.CLASS_ZONE_PROGRAM_LIMIT) + " caractères")
|
||||
return False, " le champ 'methode pedagogique' de La formation " + str(
|
||||
mydata['external_code']) + " a plus de " + str(MYSY_GV.CLASS_ZONE_PROGRAM_LIMIT) + " caractères"
|
||||
mydata['external_code']) + " a plus de " + str(MYSY_GV.CLASS_ZONE_PROGRAM_LIMIT) + " caractères", False
|
||||
|
||||
mydata['methode_pedagogique'] = methode_pedagogique
|
||||
|
||||
|
@ -300,7 +300,7 @@ def add_class(diction):
|
|||
mydata['external_code']) + " a plus de " + str(
|
||||
MYSY_GV.CLASS_ZONE_PROGRAM_LIMIT) + " caractères")
|
||||
return False, " le champ 'condition handicape' de La formation " + str(
|
||||
mydata['external_code']) + " a plus de " + str(MYSY_GV.CLASS_ZONE_PROGRAM_LIMIT) + " caractères"
|
||||
mydata['external_code']) + " a plus de " + str(MYSY_GV.CLASS_ZONE_PROGRAM_LIMIT) + " caractères", False
|
||||
|
||||
mydata['condition_handicape'] = condition_handicape
|
||||
|
||||
|
@ -314,7 +314,7 @@ def add_class(diction):
|
|||
mydata['external_code']) + " a plus de " + str(
|
||||
MYSY_GV.CLASS_ZONE_PROGRAM_LIMIT) + " caractères")
|
||||
return False, " le champ 'suivi et evaluation' de La formation " + str(
|
||||
mydata['external_code']) + " a plus de " + str(MYSY_GV.CLASS_ZONE_PROGRAM_LIMIT) + " caractères"
|
||||
mydata['external_code']) + " a plus de " + str(MYSY_GV.CLASS_ZONE_PROGRAM_LIMIT) + " caractères", False
|
||||
|
||||
mydata['suivi_eval'] = suivi_eval
|
||||
|
||||
|
@ -337,7 +337,7 @@ def add_class(diction):
|
|||
diction['external_code']) + " a plus de " + str(
|
||||
MYSY_GV.CLASS_ZONE_DESCRIP_LIMIT) + " caractères")
|
||||
return False, " le champ 'description' de La formation " + str(
|
||||
mydata['external_code']) + " a plus de " + str(MYSY_GV.CLASS_ZONE_DESCRIP_LIMIT) + " caractères"
|
||||
mydata['external_code']) + " a plus de " + str(MYSY_GV.CLASS_ZONE_DESCRIP_LIMIT) + " caractères", False
|
||||
|
||||
|
||||
|
||||
|
@ -427,7 +427,7 @@ def add_class(diction):
|
|||
mydata['external_code']) + " contient des valeurs vides")
|
||||
|
||||
return False, " La formation " + str(
|
||||
mydata['external_code']) + " contient des valeurs vides"
|
||||
mydata['external_code']) + " contient des valeurs vides", False
|
||||
|
||||
|
||||
nb_keyword = local_val.split(";")
|
||||
|
@ -435,7 +435,7 @@ def add_class(diction):
|
|||
if( len(nb_keyword) > MYSY_GV.MAX_KEYWORD ):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " : La formation "+str(mydata['external_code'])+" a plus de "+ str(MYSY_GV.MAX_KEYWORD)+" mots clés")
|
||||
return False, " La formation "+str(mydata['external_code'])+" a plus de "+ str(MYSY_GV.MAX_KEYWORD)+" mots clés"
|
||||
return False, " La formation "+str(mydata['external_code'])+" a plus de "+ str(MYSY_GV.MAX_KEYWORD)+" mots clés", False
|
||||
|
||||
|
||||
domaine = ""
|
||||
|
@ -453,7 +453,7 @@ def add_class(diction):
|
|||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " : l'url de l'image de la formation " + str(
|
||||
mydata['external_code']) + " est incorrecte ")
|
||||
return False, " l'url de l'image de la formation " + str(mydata['external_code']) + " est incorrecte "
|
||||
return False, " l'url de l'image de la formation " + str(mydata['external_code']) + " est incorrecte ", False
|
||||
|
||||
mydata['img_url'] = diction['img_url']
|
||||
else:
|
||||
|
@ -467,7 +467,7 @@ def add_class(diction):
|
|||
" Les valeurs acceptées sont " + str(
|
||||
MYSY_GV.CLASS_DURATION_UNIT) + " ")
|
||||
return False, " : le champ 'duration_unit' contient une valeur erronées." \
|
||||
" Les valeurs acceptées sont " + str(MYSY_GV.CLASS_DURATION_UNIT)
|
||||
" Les valeurs acceptées sont " + str(MYSY_GV.CLASS_DURATION_UNIT), False
|
||||
|
||||
mydata['duration_unit'] = diction['duration_unit']
|
||||
else:
|
||||
|
@ -488,7 +488,7 @@ def add_class(diction):
|
|||
if (";" not in tmp_str2):
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - la zone de diffusion de la formation : A" + str(
|
||||
diction['external_code']) + " est incorrecte")
|
||||
return False, "La zone de diffusion de la formation " + str(diction['external_code']) + " est incorrecte"
|
||||
return False, "La zone de diffusion de la formation " + str(diction['external_code']) + " est incorrecte ", False
|
||||
|
||||
|
||||
tmp_str = tmp_str2.split(";") #==> ce qui va donner un tableau de : Country_Code-City : ['fr-paris', 'fr-marseille', 'bn-cotonou']
|
||||
|
@ -502,13 +502,13 @@ def add_class(diction):
|
|||
|
||||
if( "-" not in str(val)):
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - la zone de diffusion de la formation : B" + str( diction['external_code']) + " est incorrecte")
|
||||
return False, "La zone de diffusion de la formation " + str(diction['external_code']) + " est incorrecte"
|
||||
return False, "La zone de diffusion de la formation " + str(diction['external_code']) + " est incorrecte", False
|
||||
|
||||
|
||||
tab_val = len(val.split("-"))
|
||||
if( len(val.split("-")) != 1 and len(val.split("-")) != 2 ):
|
||||
mycommon.myprint( str(inspect.stack()[0][3]) + " - la zone de diffusion de la formation : C" + str(diction['external_code'])+" est incorrecte")
|
||||
return False, "La zone de diffusion de la formation " + str(diction['external_code'])+" est incorrecte"
|
||||
return False, "La zone de diffusion de la formation " + str(diction['external_code'])+" est incorrecte", False
|
||||
|
||||
if( val.split("-")[0]):
|
||||
tab_country.append(val.split("-")[0])
|
||||
|
@ -538,7 +538,7 @@ def add_class(diction):
|
|||
'locked': '0'}) != 1):
|
||||
mycommon.myprint(str(
|
||||
inspect.stack()[0][3]) + " Le champ '" + val + "' n'est pas autorisé ")
|
||||
return False, " Les informations fournies sont incorrectes"
|
||||
return False, " Les informations fournies sont incorrectes", False
|
||||
|
||||
mydata[str(val)] = diction[str(val)]
|
||||
|
||||
|
@ -627,15 +627,15 @@ def add_class(diction):
|
|||
eibdd.ela_index_class_key_word(mydata['external_code'], "keyword", user_recid)
|
||||
|
||||
|
||||
return True, "La formation a bien été ajoutée"
|
||||
return True, "La formation a bien été ajoutée", str(ret_val['_id'])
|
||||
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']))
|
||||
return False, " Impossible d'ajouter la formation "+str(str(mydata['external_code'])), False
|
||||
|
||||
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'ajouter la formation"+ str(e)
|
||||
return False, "Impossible d'ajouter la formation"+ str(e), False
|
||||
|
||||
|
||||
'''
|
||||
|
@ -666,7 +666,7 @@ def update_class(diction):
|
|||
if val not in field_list and val.startswith('my_') is False:
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3])+" - Le champ '" + val + "' n'est pas accepté, Creation formation annulée")
|
||||
return False, " Impossible de mettre à jour la formation"
|
||||
return False, " Impossible de mettre à jour la formation", False
|
||||
|
||||
'''
|
||||
Une fois qu'on a controlé que toutes les clés mise dans l'API sont correcte. etape precedente,
|
||||
|
@ -677,7 +677,7 @@ def update_class(diction):
|
|||
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 mettre à jour la formation"
|
||||
return False, " Impossible de mettre à jour la formation", False
|
||||
|
||||
# recuperation des paramettre
|
||||
mydata = {}
|
||||
|
@ -705,13 +705,13 @@ def update_class(diction):
|
|||
|
||||
if retval is False:
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - Le token ne sont pas valident")
|
||||
return False, "L'email ou le token ne sont pas valident"
|
||||
return False, "L'email ou le token ne sont pas valident", False
|
||||
|
||||
# Recuperation du recid de l'utilisateur
|
||||
user_recid = mycommon.get_parnter_recid_from_token(str(mydata['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"
|
||||
return False, " Les informations d'identification sont incorrectes", False
|
||||
|
||||
partner_recid = user_recid
|
||||
my_internal_code = ""
|
||||
|
@ -753,7 +753,7 @@ def update_class(diction):
|
|||
|
||||
if (is_formateur_id_ok <= 0):
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - L'identifiant du formateur est invalide")
|
||||
return False, " L'identifiant du formateur est invalide "
|
||||
return False, " L'identifiant du formateur est invalide ", False
|
||||
|
||||
mydata['formateur_id'] = formateur_id
|
||||
|
||||
|
@ -777,7 +777,7 @@ def update_class(diction):
|
|||
diction['external_code']) + " a plus de " + str(
|
||||
MYSY_GV.CLASS_ZONE_OBJECTIF_LIMIT) + " caractères")
|
||||
return False, " le champ 'objectif' de La formation " + str(
|
||||
diction['external_code']) + " a plus de " + str(MYSY_GV.CLASS_ZONE_OBJECTIF_LIMIT) + " caractères"
|
||||
diction['external_code']) + " a plus de " + str(MYSY_GV.CLASS_ZONE_OBJECTIF_LIMIT) + " caractères", False
|
||||
|
||||
|
||||
if ("programme" in diction.keys()):
|
||||
|
@ -788,7 +788,7 @@ def update_class(diction):
|
|||
diction['external_code']) + " a plus de " + str(
|
||||
MYSY_GV.CLASS_ZONE_PROGRAM_LIMIT) + " caractères")
|
||||
return False, " le champ 'Progamme' de La formation " + str(
|
||||
diction['external_code']) + " a plus de " + str(MYSY_GV.CLASS_ZONE_PROGRAM_LIMIT) + " caractères"
|
||||
diction['external_code']) + " a plus de " + str(MYSY_GV.CLASS_ZONE_PROGRAM_LIMIT) + " caractères", False
|
||||
|
||||
|
||||
if ("methode_pedagogique" in diction.keys()):
|
||||
|
@ -799,7 +799,7 @@ def update_class(diction):
|
|||
diction['external_code']) + " a plus de " + str(
|
||||
MYSY_GV.CLASS_ZONE_PROGRAM_LIMIT) + " caractères")
|
||||
return False, " le champ 'methode pedagogique' de La formation " + str(
|
||||
diction['external_code']) + " a plus de " + str(MYSY_GV.CLASS_ZONE_PROGRAM_LIMIT) + " caractères"
|
||||
diction['external_code']) + " a plus de " + str(MYSY_GV.CLASS_ZONE_PROGRAM_LIMIT) + " caractères", False
|
||||
|
||||
|
||||
if ("condition_handicape" in diction.keys()):
|
||||
|
@ -810,7 +810,7 @@ def update_class(diction):
|
|||
diction['external_code']) + " a plus de " + str(
|
||||
MYSY_GV.CLASS_ZONE_PROGRAM_LIMIT) + " caractères")
|
||||
return False, " le champ 'condition handicape' de La formation " + str(
|
||||
diction['external_code']) + " a plus de " + str(MYSY_GV.CLASS_ZONE_PROGRAM_LIMIT) + " caractères"
|
||||
diction['external_code']) + " a plus de " + str(MYSY_GV.CLASS_ZONE_PROGRAM_LIMIT) + " caractères", False
|
||||
|
||||
|
||||
if ("suivi_eval" in diction.keys()):
|
||||
|
@ -821,7 +821,7 @@ def update_class(diction):
|
|||
diction['external_code']) + " a plus de " + str(
|
||||
MYSY_GV.CLASS_ZONE_PROGRAM_LIMIT) + " caractères")
|
||||
return False, " le champ 'suivi et evaluation' de La formation " + str(
|
||||
diction['external_code']) + " a plus de " + str(MYSY_GV.CLASS_ZONE_PROGRAM_LIMIT) + " caractères"
|
||||
diction['external_code']) + " a plus de " + str(MYSY_GV.CLASS_ZONE_PROGRAM_LIMIT) + " caractères", False
|
||||
|
||||
|
||||
|
||||
|
@ -852,7 +852,7 @@ def update_class(diction):
|
|||
if (status_tmp is False):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " : l'url de l'image de la formation " + str(my_internal_code) + " est incorrecte ")
|
||||
return False, " l'url de l'image de la formation " + str(my_internal_code) + " est incorrecte "
|
||||
return False, " l'url de l'image de la formation " + str(my_internal_code) + " est incorrecte ", False
|
||||
|
||||
|
||||
mydata['img_url'] = diction['img_url']
|
||||
|
@ -869,7 +869,7 @@ def update_class(diction):
|
|||
diction['external_code']) + " a plus de " + str(
|
||||
MYSY_GV.CLASS_ZONE_DESCRIP_LIMIT) + " caractères")
|
||||
return False, " le champ 'description' de La formation " + str(
|
||||
diction['external_code']) + " a plus de " + str(MYSY_GV.CLASS_ZONE_DESCRIP_LIMIT) + " caractères"
|
||||
diction['external_code']) + " a plus de " + str(MYSY_GV.CLASS_ZONE_DESCRIP_LIMIT) + " caractères", False
|
||||
|
||||
|
||||
if ("metier" in diction.keys()):
|
||||
|
@ -909,7 +909,7 @@ def update_class(diction):
|
|||
str(inspect.stack()[0][3]) + " : le champ 'duration_unit' contient une valeur erronées."
|
||||
" Les valeurs acceptées sont " + str(MYSY_GV.CLASS_DURATION_UNIT) + " ")
|
||||
return False, " : le champ 'duration_unit' contient une valeur erronées." \
|
||||
" Les valeurs acceptées sont " + str(MYSY_GV.CLASS_DURATION_UNIT)
|
||||
" Les valeurs acceptées sont " + str(MYSY_GV.CLASS_DURATION_UNIT), False
|
||||
|
||||
mydata['duration_unit'] = diction['duration_unit']
|
||||
else:
|
||||
|
@ -934,14 +934,14 @@ def update_class(diction):
|
|||
str(inspect.stack()[0][3]) + " : La formation " + str(
|
||||
diction['external_code']) + " contient des valeurs vides (1)")
|
||||
|
||||
return False, " La formation " + str(diction['external_code']) + " contient des valeurs vides"
|
||||
return False, " La formation " + str(diction['external_code']) + " contient des valeurs vides", False
|
||||
|
||||
if (len(nb_keyword) > MYSY_GV.MAX_KEYWORD):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " : La formation " + str(
|
||||
diction['external_code']) + " a plus de " + str(MYSY_GV.MAX_KEYWORD) + " mots clés")
|
||||
return False, " La formation " + str(diction['external_code']) + " a plus de " + str(
|
||||
MYSY_GV.MAX_KEYWORD) + " mots clés"
|
||||
MYSY_GV.MAX_KEYWORD) + " mots clés", False
|
||||
|
||||
|
||||
mydata['mots_cle'] =mots_cle
|
||||
|
@ -966,7 +966,7 @@ def update_class(diction):
|
|||
if (";" not in tmp_str2):
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - la zone de diffusion de la formation 0: " + str(
|
||||
my_external_code) + " est incorrecte")
|
||||
return False, "La zone de diffusion de la formation " + str(my_external_code) + " est incorrecte"
|
||||
return False, "La zone de diffusion de la formation " + str(my_external_code) + " est incorrecte", False
|
||||
|
||||
|
||||
tmp_str = tmp_str2.split(";") #==> ce qui va donner un tableau de : Country_Code-City : ['fr-paris', 'fr-marseille', 'bn-cotonou']
|
||||
|
@ -981,13 +981,13 @@ def update_class(diction):
|
|||
|
||||
if( "-" not in str(val)):
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - la zone de diffusion de la formation 1: " + str( my_external_code) + " est incorrecte")
|
||||
return False, "La zone de diffusion de la formation " + str(my_external_code) + " est incorrecte"
|
||||
return False, "La zone de diffusion de la formation " + str(my_external_code) + " est incorrecte", False
|
||||
|
||||
|
||||
tab_val = len(val.split("-"))
|
||||
if( len(val.split("-")) != 1 and len(val.split("-")) != 2 ):
|
||||
mycommon.myprint( str(inspect.stack()[0][3]) + " - la zone de diffusion de la formation 2: " + str(my_external_code)+" est incorrecte")
|
||||
return False, "La zone de diffusion de la formation " + str(my_external_code)+" est incorrecte"
|
||||
return False, "La zone de diffusion de la formation " + str(my_external_code)+" est incorrecte", False
|
||||
|
||||
if( val.split("-")[0]):
|
||||
tab_country.append(val.split("-")[0])
|
||||
|
@ -1002,125 +1002,6 @@ def update_class(diction):
|
|||
|
||||
mydata['zone_diffusion'] = {'country':tab_country, 'city':tab_city}
|
||||
|
||||
'''
|
||||
Traitement date_lieu.
|
||||
Date_lieu definit une session et au format :
|
||||
date_du;data_au;ville;code_postal; adresse
|
||||
|
||||
mydata['datelieu'] = ""
|
||||
if ("date_lieu" in diction.keys()):
|
||||
if(len(str(diction['date_lieu'])) == 0 ):
|
||||
mydata['datelieu'] = {}
|
||||
|
||||
else:
|
||||
tmp_str2 = str(diction['date_lieu']).lower().replace(",", ";").replace("\r\n", "")
|
||||
|
||||
if (not tmp_str2.endswith(";")):
|
||||
tmp_str2 = tmp_str2 + ";"
|
||||
|
||||
# print("tmp_str2 = " + tmp_str2)
|
||||
|
||||
if (";" not in tmp_str2):
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - les dates et lieux de la formation : " + str(
|
||||
diction['external_code']) + " sont incorrectes 1")
|
||||
return False, "Les Dates et Lieux de la formation " + str(
|
||||
diction['external_code']) + " sont incorrectes. Le format attendu : " \
|
||||
"jj/mm/aaaa-jj/mm/aaaa-ville-code_postale-adresse;jj/mm/aaaa-jj/mm/aaaa-ville-code_postale-adresse"
|
||||
|
||||
tmp_str = tmp_str2.split(
|
||||
";") # ==> ce qui va donner un tableau de : Country_Code-City : ['11/02/2012-paris-75001', '24/04/2022-marseille-13002',]
|
||||
|
||||
i = 0
|
||||
for tmp_val in tmp_str:
|
||||
tmp_str[i] = str(tmp_str[i]).strip()
|
||||
i = i + 1
|
||||
|
||||
dl_cpt = 0
|
||||
tab_dl = []
|
||||
for tmp_dl in tmp_str:
|
||||
#print(" ### tmp_dl = "+str(tmp_dl))
|
||||
if (len(str(tmp_dl)) > 0 and ("-" in tmp_dl)):
|
||||
# print(" ###### DATE LIEU = "+tmp_dl)
|
||||
#tab_date_lieu = tmp_dl.split('-')
|
||||
tab_date_lieu = [x.strip() for x in tmp_dl.split('-')]
|
||||
if (len(tab_date_lieu) != 5):
|
||||
return False, "Les Dates et Lieux de la formation " + str(
|
||||
diction['external_code']) + " sont incorrectes. Le format attendu : " \
|
||||
"jj/mm/aaaa-jj/mm/aaaa-ville-code_postale-adresse;jj/mm/aaaa-jj/mm/aaaa-ville-code_postale-adresse"
|
||||
|
||||
isdate = mycommon.CheckisDate(str(tab_date_lieu[0]))
|
||||
if (isdate is False):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " - les dates et lieux de la formation : A" + str(
|
||||
diction['external_code']) + " sont incorrectes 2")
|
||||
return False, "Les Dates et Lieux de la formation " + str(
|
||||
diction['external_code']) + " sont incorrectes. Le format attendu : " \
|
||||
"jj/mm/aaaa-jj/mm/aaaa-ville-code_postale-adresse;jj/mm/aaaa-jj/mm/aaaa-ville-code_postale-adresse 3"
|
||||
|
||||
isdate_au = mycommon.CheckisDate(str(tab_date_lieu[1]))
|
||||
if (isdate is False):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " - les dates et lieux de la formation : A" + str(
|
||||
diction['external_code']) + " sont incorrectes 3")
|
||||
return False, "Les Dates et Lieux de la formation " + str(
|
||||
diction['external_code']) + " sont incorrectes. Le format attendu : " \
|
||||
"jj/mm/aaaa-jj/mm/aaaa-ville-code_postale-adresse;jj/mm/aaaa-jj/mm/aaaa-ville-code_postale-adresse 2"
|
||||
|
||||
|
||||
#print("### isdate = " + str(tab_date_lieu[0]) + " CM isdate_au = " + str(tab_date_lieu[1]))
|
||||
if (datetime.strptime(str(tab_date_lieu[0]).strip(), '%d/%m/%Y') > datetime.strptime(str(tab_date_lieu[1]).strip(), '%d/%m/%Y')):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " - la date debut est postérieur à la date de fin pour la formation : " + str(
|
||||
diction['external_code']) + " ")
|
||||
return False, " La date debut est postérieur à la date de fin pour la formation : " + str(
|
||||
diction['external_code']) + " "
|
||||
|
||||
mytoday = datetime.today().strftime("%d/%m/%Y")
|
||||
if (datetime.strptime(str(tab_date_lieu[0]), '%d/%m/%Y') < datetime.strptime(str(mytoday), '%d/%m/%Y')):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " - la date debut est postérieur à la date du jour pour la formation : " + str(
|
||||
diction['external_code']) + " ")
|
||||
return False, " La date debut est postérieur à la date du jour pour la formation : " + str(
|
||||
diction['external_code']) + " "
|
||||
|
||||
"""
|
||||
On créé un identifiant unique par session
|
||||
Session_id = date_du+date_au+code_postal+adresse
|
||||
"""
|
||||
|
||||
session_id = str(str(tab_date_lieu[0]) + str(tab_date_lieu[1]) + str(tab_date_lieu[3]) + str(
|
||||
tab_date_lieu[4])).replace(' ','')
|
||||
|
||||
session_id = mycommon.remove_non_ascii(session_id)
|
||||
session_id = re.sub(r'[^a-zA-Z0-9]', '', session_id)
|
||||
|
||||
## Verifier si le CP n'est composé que de "0", au quel cas il s'agit d'une formation en ligne.
|
||||
local_cp = str(tab_date_lieu[3]).replace("0", "").strip()
|
||||
class_cp = ""
|
||||
if (local_cp == ""):
|
||||
class_cp = "0"
|
||||
else:
|
||||
class_cp = str(tab_date_lieu[3]).strip()
|
||||
|
||||
val_dl = {'date_du': str(tab_date_lieu[0]).strip(), 'date_au': str(tab_date_lieu[1]).strip(),
|
||||
'ville': str(tab_date_lieu[2]).strip(), 'code_postal': str(class_cp).strip(),
|
||||
'adresse': str(tab_date_lieu[4]).strip(), 'session_id':str(session_id).strip()}
|
||||
tab_dl.append(val_dl)
|
||||
# mydata['date_lieu'][dl_cpt] = {'date': str(tab_date_lieu[0]), 'ville': str(tab_date_lieu[1])}
|
||||
# print(str(mydata['date_lieu'] ))
|
||||
# print(" ######### date_lieu = " + str(tab_date_lieu[0]) + " ----- " + str(tab_date_lieu[1]))
|
||||
|
||||
dl_cpt = dl_cpt + 1
|
||||
|
||||
elif (len(str(tmp_dl)) > 0 and ("-" not in tmp_dl)):
|
||||
return False, "Les Dates et Lieux de la formation " + str(
|
||||
diction['external_code']) + " sont incorrectes. Le format attendu : " \
|
||||
"jj/mm/aaaa-jj/mm/aaaa-ville-code_postale-adresse;jj/mm/aaaa-jj/mm/aaaa-ville-code_postale-adresse 1"
|
||||
|
||||
mydata['datelieu'] = tab_dl
|
||||
'''
|
||||
mydata['date_update'] = str(datetime.now())
|
||||
mydata['update_by'] = str(my_partner['recid'])
|
||||
|
||||
|
@ -1135,7 +1016,7 @@ def update_class(diction):
|
|||
'locked': '0'}) != 1):
|
||||
mycommon.myprint(str(
|
||||
inspect.stack()[0][3]) + " Le champ '" + val + "' n'est pas autorisé ")
|
||||
return False, " Les informations fournies sont incorrectes"
|
||||
return False, " Les informations fournies sont incorrectes", False
|
||||
|
||||
mydata[str(val)] = diction[str(val)]
|
||||
|
||||
|
@ -1170,7 +1051,7 @@ def update_class(diction):
|
|||
if (part_status is False):
|
||||
mycommon.myprint(str(inspect.stack()[0][
|
||||
3]) + " - Impossible de récupérer le pack et le nombre de formation du partenaire")
|
||||
return False, "Votre pack / abonnement ne permet pas de créer les formations. Verifiez votre abonnement "
|
||||
return False, "Votre pack / abonnement ne permet pas de créer les formations. Verifiez votre abonnement ", False
|
||||
|
||||
|
||||
coll_pack = MYSY_GV.dbname['pack']
|
||||
|
@ -1184,8 +1065,6 @@ def update_class(diction):
|
|||
## For demo only
|
||||
mydata['display_rank'] = "999"
|
||||
|
||||
|
||||
|
||||
coll_name = MYSY_GV.dbname['myclass']
|
||||
|
||||
#print(" ### Update class : internal_url = ", str(my_internal_url), " -- partner_owner_recid = ", partner_recid)
|
||||
|
@ -1212,17 +1091,18 @@ def update_class(diction):
|
|||
# Indexation Title des mots clées
|
||||
eibdd.ela_index_given_classes_keywords(training_to_index_title)
|
||||
|
||||
return True, " La formation a été mise à jour"
|
||||
|
||||
return True, " La formation a été mise à jour", str(ret_val['_id'])
|
||||
|
||||
else:
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - Impossible de mettre à jour la formation : "+str(my_external_code) )
|
||||
return False, "Impossible de mettre à jour la formation "+str(my_external_code)
|
||||
return False, "Impossible de mettre à jour la formation "+str(my_external_code), False
|
||||
|
||||
|
||||
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 mettre à jour la formation "
|
||||
return False, " Impossible de mettre à jour la formation ", False
|
||||
|
||||
|
||||
|
||||
|
@ -1888,8 +1768,6 @@ def get_class(diction):
|
|||
if diction['token']:
|
||||
my_token = diction['token']
|
||||
|
||||
print(" #### my token = ", my_token)
|
||||
|
||||
|
||||
client_connected_recid = ""
|
||||
connection_type = ""
|
||||
|
@ -2018,7 +1896,7 @@ def get_class(diction):
|
|||
|
||||
pipe = [
|
||||
{'$match': {'internal_url': internal_url, 'published': '1'}},
|
||||
{'$project': {'_id': 0, 'indexed': 0, 'indexed_desc': 0, 'indexed_obj': 0, "indexed_title": 0, "valide": 0,
|
||||
{'$project': { 'indexed': 0, 'indexed_desc': 0, 'indexed_obj': 0, "indexed_title": 0, "valide": 0,
|
||||
"locked": 0}},
|
||||
{'$lookup':
|
||||
{
|
||||
|
|
30
main.py
30
main.py
|
@ -341,8 +341,8 @@ def create_class():
|
|||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### payload = ",payload)
|
||||
status, retval = cm.add_class(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
status, retval, class_id = cm.add_class(payload)
|
||||
return jsonify(status=status, message=retval, class_id=class_id)
|
||||
|
||||
|
||||
|
||||
|
@ -433,8 +433,10 @@ def update_class():
|
|||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### update_class payload = ",payload)
|
||||
status, retval = cm.update_class(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
status, retval, class_id = cm.update_class(payload)
|
||||
print(" ### class_id = ", class_id)
|
||||
|
||||
return jsonify(status=status, message=retval, class_id=class_id)
|
||||
|
||||
|
||||
'''
|
||||
|
@ -1730,6 +1732,24 @@ def getRecodedClassImage():
|
|||
status, myimg= mycommon.getRecodedClassImage(payload)
|
||||
return jsonify(status=status, message=myimg)
|
||||
|
||||
|
||||
"""
|
||||
Cette API récupérer l'image de profils d'une formation sans que
|
||||
l'utilisateur ne soit connecté.
|
||||
|
||||
par exemple lorsqu'une personne lambda affiche les formation
|
||||
|
||||
"""
|
||||
@app.route('/myclass/api/getRecodedClassImage_no_token/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def getRecodedClassImage_no_token():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### getRecodedClassImage_no_token payload = ",payload)
|
||||
status, myimg= mycommon.getRecodedClassImage_no_token(payload)
|
||||
return jsonify(status=status, message=myimg)
|
||||
|
||||
|
||||
"""
|
||||
Cette API supprimer une l'image de profil d'une formation
|
||||
"""
|
||||
|
@ -1764,7 +1784,7 @@ Enregistrement d'une image de profil d'une formation
|
|||
def recordClassImage():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### payload = ",payload)
|
||||
print(" ### recordClassImage payload = ",payload)
|
||||
print(request.files)
|
||||
|
||||
if request.method == 'POST':
|
||||
|
|
145
prj_common.py
145
prj_common.py
|
@ -1620,7 +1620,7 @@ def recordImage(file=None, Folder=None, diction=None):
|
|||
try:
|
||||
|
||||
# Dictionnaire des champs utilisables
|
||||
field_list = ['token', 'type']
|
||||
field_list = ['token', 'type',]
|
||||
incom_keys = diction.keys()
|
||||
|
||||
'''
|
||||
|
@ -1740,7 +1740,7 @@ def recordClassImage(file=None, Folder=None, diction=None):
|
|||
try:
|
||||
|
||||
# Dictionnaire des champs utilisables
|
||||
field_list = ['token', 'type', 'class_external_code']
|
||||
field_list = ['token', 'type', 'class_external_code', 'related_collection', 'related_collection_recid']
|
||||
incom_keys = diction.keys()
|
||||
|
||||
'''
|
||||
|
@ -1759,7 +1759,7 @@ def recordClassImage(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', 'type', 'class_external_code']
|
||||
field_list_obligatoire = ['token', 'type', 'class_external_code', 'related_collection', 'related_collection_recid']
|
||||
for val in field_list_obligatoire:
|
||||
if str(val).lower() not in diction:
|
||||
myprint(
|
||||
|
@ -1786,28 +1786,11 @@ def recordClassImage(file=None, Folder=None, diction=None):
|
|||
if diction['class_external_code']:
|
||||
myclassexternalcode = diction['class_external_code']
|
||||
|
||||
'''
|
||||
Verification de la validité du token et recuperation du recid du user
|
||||
'''
|
||||
retval = check_user_validity("", str(mytoken))
|
||||
local_status, my_partner = Check_Connexion_And_Return_Partner_Data({'token':str(diction['token'])})
|
||||
if (local_status is not True):
|
||||
return local_status, my_partner
|
||||
|
||||
if retval is False:
|
||||
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"
|
||||
|
||||
|
||||
|
||||
if (mytype == "partner"):
|
||||
user_recid = get_parnter_recid_from_token(str(mytoken))
|
||||
if user_recid is False:
|
||||
myprint(str(inspect.stack()[0][3]) + " - Impossible de récupérer le recid du partner")
|
||||
return False, " Les informations d'identification sont incorrectes"
|
||||
else:
|
||||
myprint(str(inspect.stack()[0][3]) + " - l'API est incorrecte. le type n'est pas renseingé")
|
||||
return False, " Les informations d'identification sont incorrectes"
|
||||
|
||||
|
||||
myuserrecid = user_recid
|
||||
myuserrecid = str(my_partner['recid'])
|
||||
|
||||
status, saved_file = Upload_Save_IMG_File(file, Folder)
|
||||
if (status == False):
|
||||
|
@ -1832,11 +1815,15 @@ def recordClassImage(file=None, Folder=None, diction=None):
|
|||
new_diction['date_update'] = str(datetime.now())
|
||||
new_diction['locked'] = "0"
|
||||
|
||||
ret_val = coll_name.find_one_and_update({"recid": myuserrecid, "valide": "1", "locked": "0", "class_external_code":str(myclassexternalcode)},
|
||||
{"$set": {"img": strimg, "date_update": str(datetime.now()),
|
||||
"type": "profil_class", "recid": myuserrecid, "valide": "1",
|
||||
"locked": "0",
|
||||
"class_external_code":str(myclassexternalcode)}},
|
||||
new_diction['partner_owner_recid'] = str(my_partner['recid'])
|
||||
new_diction['update_by'] = str(my_partner['_id'])
|
||||
new_diction['related_collection'] = str(diction['related_collection'])
|
||||
new_diction['related_collection_recid'] = str(diction['related_collection_recid'])
|
||||
|
||||
|
||||
ret_val = coll_name.find_one_and_update({"partner_owner_recid": str(my_partner['recid']), "valide": "1", "locked": "0", "related_collection":str(diction['related_collection']),
|
||||
"related_collection_recid": str(diction['related_collection_recid'])},
|
||||
{"$set": new_diction},
|
||||
upsert=True,
|
||||
return_document=ReturnDocument.AFTER
|
||||
)
|
||||
|
@ -2164,7 +2151,7 @@ Recuperation d'une image de profils d'une formation
|
|||
def getRecodedClassImage(diction=None):
|
||||
try:
|
||||
# Dictionnaire des champs utilisables
|
||||
field_list = ['token', 'type', 'class_external_code']
|
||||
field_list = ['token', 'type', 'class_external_code', 'related_collection', 'related_collection_recid']
|
||||
incom_keys = diction.keys()
|
||||
|
||||
'''
|
||||
|
@ -2235,7 +2222,93 @@ def getRecodedClassImage(diction=None):
|
|||
coll_name = MYSY_GV.dbname['image_ch']
|
||||
RetObject = []
|
||||
|
||||
for retVal in coll_name.find({'recid':myuserrecid, "type":"profil_class", "class_external_code":str(myclassexternalcode)} ):
|
||||
qry = {'recid':myuserrecid, "type":"profil_class", "class_external_code":str(myclassexternalcode),
|
||||
'related_collection_recid':str(diction['related_collection_recid']),
|
||||
"related_collection":str(diction['related_collection'])}
|
||||
|
||||
print(" qry = ", qry)
|
||||
|
||||
for retVal in coll_name.find({'recid':myuserrecid, "type":"profil_class", "class_external_code":str(myclassexternalcode),
|
||||
'related_collection_recid':str(diction['related_collection_recid']),
|
||||
"related_collection":str(diction['related_collection'])} ):
|
||||
user2={}
|
||||
user2['date_update'] = retVal['date_update']
|
||||
decode = retVal['img'].decode()
|
||||
user2['img'] = decode
|
||||
data1 = json.loads(json.dumps(user2))
|
||||
|
||||
return True, data1
|
||||
|
||||
return False, ""
|
||||
|
||||
except Exception as e:
|
||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||
print(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
|
||||
return False, ""
|
||||
|
||||
|
||||
'''
|
||||
Recuperation d'une image de profils d'une formation sans que
|
||||
l'utilisateur ne soit connecté.
|
||||
|
||||
par exemple lorsqu'une personne lambda affiche les formation
|
||||
'''
|
||||
def getRecodedClassImage_no_token(diction=None):
|
||||
try:
|
||||
# Dictionnaire des champs utilisables
|
||||
field_list = [ 'type', 'class_external_code', 'related_collection', 'related_collection_recid']
|
||||
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():
|
||||
myprint(
|
||||
str(inspect.stack()[0][3]) + " Le champ '" + val + "' n'est pas accepté dans cette API")
|
||||
return False, " Impossible de se connecter"
|
||||
|
||||
'''
|
||||
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 = ['type','class_external_code']
|
||||
for val in field_list_obligatoire:
|
||||
if str(val).lower() not in diction:
|
||||
myprint(
|
||||
str(inspect.stack()[0][3]) + " La valeur '" + val + "' n'est pas presente dans liste des champs")
|
||||
return False, "Impossible de se connecter"
|
||||
|
||||
mydata = {}
|
||||
|
||||
mytype = ""
|
||||
if ("type" in diction.keys()):
|
||||
if diction['type']:
|
||||
mytype = diction['type']
|
||||
|
||||
myclassexternalcode = ""
|
||||
if ("class_external_code" in diction.keys()):
|
||||
if diction['class_external_code']:
|
||||
myclassexternalcode = diction['class_external_code']
|
||||
|
||||
|
||||
|
||||
|
||||
coll_name = MYSY_GV.dbname['image_ch']
|
||||
RetObject = []
|
||||
|
||||
qry = {"type":"profil_class", "class_external_code":str(myclassexternalcode),
|
||||
'related_collection_recid':str(diction['related_collection_recid']),
|
||||
"related_collection":str(diction['related_collection'])}
|
||||
|
||||
print(" qry = ", qry)
|
||||
|
||||
for retVal in coll_name.find({ "type":"profil_class", "class_external_code":str(myclassexternalcode),
|
||||
'related_collection_recid':str(diction['related_collection_recid']),
|
||||
"related_collection":str(diction['related_collection'])} ):
|
||||
user2={}
|
||||
user2['date_update'] = retVal['date_update']
|
||||
decode = retVal['img'].decode()
|
||||
|
@ -2259,7 +2332,7 @@ Suppression d'une image de profils d'une formation
|
|||
def DeleteRecodedClassImage(diction=None):
|
||||
try:
|
||||
# Dictionnaire des champs utilisables
|
||||
field_list = ['token', 'type', 'class_external_code']
|
||||
field_list = ['token', 'type', 'class_external_code', 'related_collection', 'related_collection_recid']
|
||||
incom_keys = diction.keys()
|
||||
|
||||
'''
|
||||
|
@ -2330,7 +2403,9 @@ def DeleteRecodedClassImage(diction=None):
|
|||
coll_name = MYSY_GV.dbname['image_ch']
|
||||
|
||||
|
||||
myquery = {'recid':myuserrecid, "type":"profil_class", "class_external_code":str(myclassexternalcode)}
|
||||
myquery = { "class_external_code":str(myclassexternalcode), 'related_collection':str(diction['related_collection']),
|
||||
'related_collection_recid':str(diction['related_collection_recid'])}
|
||||
|
||||
delete_row = coll_name.delete_many(myquery)
|
||||
myprint(str(inspect.stack()[0][3]) + "- "+str(delete_row.deleted_count)+" image logo supprimée(s) pour la formation class_external_code = "+str(myclassexternalcode))
|
||||
|
||||
|
@ -2726,6 +2801,10 @@ def InsertStatistic(diction_class, type_view, user_location):
|
|||
|
||||
|
||||
coll_name = MYSY_GV.dbname['user_recherche_result']
|
||||
|
||||
if("_id" in mydict_combined.keys() ):
|
||||
del mydict_combined['_id']
|
||||
|
||||
ret_val = coll_name.insert_one(mydict_combined)
|
||||
if (ret_val is False):
|
||||
myprint(
|
||||
|
|
|
@ -251,7 +251,7 @@ def get_all_class(diction):
|
|||
{'display_rank': {'$nin': []}}
|
||||
]}
|
||||
},
|
||||
{'$project': {'_id': 0, 'indexed': 0, 'indexed_desc': 0, 'indexed_obj': 0, "indexed_title": 0,
|
||||
{'$project': { 'indexed': 0, 'indexed_desc': 0, 'indexed_obj': 0, "indexed_title": 0,
|
||||
"valide": 0, "locked": 0}},
|
||||
{'$lookup':
|
||||
{
|
||||
|
@ -678,7 +678,7 @@ def recherche_text_simple(diction):
|
|||
nb_result = 0
|
||||
|
||||
for x in coll_name.find({"external_code": {"$in": final_message2}, 'published':'1'},
|
||||
{"_id": 0, "indexed": 0, "indexed_desc": 0, "indexed_obj": 0,
|
||||
{ "indexed": 0, "indexed_desc": 0, "indexed_obj": 0,
|
||||
"indexed_title": 0, "valide": 0, "locked": 0, }).\
|
||||
sort([("display_rank", pymongo.DESCENDING), ("price", pymongo.ASCENDING), ("date_update", pymongo.DESCENDING), ]):
|
||||
|
||||
|
|
Loading…
Reference in New Issue