20/12/2023 - 22h30
parent
79308bd98b
commit
bb3751168a
|
@ -1,11 +1,12 @@
|
|||
<?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="18/12/2023 - 22:00">
|
||||
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="20/12/2023 - 18h">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Inscription_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/Inscription_mgt.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$/Session_Formation.py" beforeDir="false" afterPath="$PROJECT_DIR$/Session_Formation.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/apprenant_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/apprenant_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" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
|
@ -75,13 +76,6 @@
|
|||
<option name="presentableId" value="Default" />
|
||||
<updated>1680804787304</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00129" summary="17/10/2023 - 22h40">
|
||||
<created>1697571685666</created>
|
||||
<option name="number" value="00129" />
|
||||
<option name="presentableId" value="LOCAL-00129" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1697571685666</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00130" summary="17/10/2023 - 22h45">
|
||||
<created>1697626088499</created>
|
||||
<option name="number" value="00130" />
|
||||
|
@ -418,7 +412,14 @@
|
|||
<option name="project" value="LOCAL" />
|
||||
<updated>1702933100880</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="178" />
|
||||
<task id="LOCAL-00178" summary="20/12/2023 - 18h">
|
||||
<created>1703092066442</created>
|
||||
<option name="number" value="00178" />
|
||||
<option name="presentableId" value="LOCAL-00178" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1703092066442</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="179" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="Vcs.Log.Tabs.Properties">
|
||||
|
@ -433,7 +434,6 @@
|
|||
</option>
|
||||
</component>
|
||||
<component name="VcsManagerConfiguration">
|
||||
<MESSAGE value="18/11/2023 - 17h00" />
|
||||
<MESSAGE value="20/11/2023 - 21h00" />
|
||||
<MESSAGE value="22/11/2023 - 23h00" />
|
||||
<MESSAGE value="23/11/23 - 13:30" />
|
||||
|
@ -458,6 +458,7 @@
|
|||
<MESSAGE value="16/12/2023 - 23h12" />
|
||||
<MESSAGE value="18/12/2023 - 18:00" />
|
||||
<MESSAGE value="18/12/2023 - 22:00" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="18/12/2023 - 22:00" />
|
||||
<MESSAGE value="20/12/2023 - 18h" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="20/12/2023 - 18h" />
|
||||
</component>
|
||||
</project>
|
|
@ -5508,7 +5508,7 @@ def Get_Statgaire_List_Partner_with_filter(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 autorisé, Creation partenaire annulée")
|
||||
return False, "de récupérer la liste des stagiaires . Toutes les informations fournies ne sont pas valables"
|
||||
return False, "Toutes les informations fournies ne sont pas valables"
|
||||
|
||||
"""
|
||||
Verification de la liste des champs obligatoires
|
||||
|
@ -5518,7 +5518,7 @@ def Get_Statgaire_List_Partner_with_filter(diction):
|
|||
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 la liste des stagiaires, Toutes les informations necessaires n'ont pas été fournies"
|
||||
return False, "Toutes les informations necessaires n'ont pas été fournies"
|
||||
|
||||
# Recuperation du recid du partner
|
||||
mydata = {}
|
||||
|
@ -5527,16 +5527,11 @@ def Get_Statgaire_List_Partner_with_filter(diction):
|
|||
if diction['token']:
|
||||
mytoken = diction['token']
|
||||
|
||||
# Verifier la validité du token
|
||||
retval = mycommon.check_partner_token_validity("", mytoken)
|
||||
if retval is False:
|
||||
return "Err_Connexion", " La session de connexion n'est pas valide"
|
||||
local_status, my_partner = mycommon.Check_Connexion_And_Return_Partner_Data(diction)
|
||||
if (local_status is not True):
|
||||
return local_status, my_partner
|
||||
|
||||
|
||||
partner_recid = mycommon.get_parnter_recid_from_token(mytoken)
|
||||
if (partner_recid is False):
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - Impossible de récupérer la liste des stagiaires, ")
|
||||
return False, "Impossible de récupérer la liste des stagiaires, Les informations d'identification sont incorrectes "
|
||||
partner_recid = my_partner['recid']
|
||||
|
||||
|
||||
|
||||
|
|
382
apprenant_mgt.py
382
apprenant_mgt.py
|
@ -378,6 +378,91 @@ def Get_Given_Apprenant_Data(diction):
|
|||
return False, " Impossible de récupérer les données de l'apprenant "
|
||||
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Fonction pour supprimer un apprenant si toutes les conditions sont remplies.
|
||||
|
||||
Condition :
|
||||
- pas d'inscription en cours ou validé
|
||||
"""
|
||||
def Delete_Given_Apprenant(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', 'apprenant_id']
|
||||
|
||||
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]) + " Le champ '" + val + "' n'est pas autorisé")
|
||||
return False, " Les informations fournies sont incorrectes",
|
||||
|
||||
"""
|
||||
Verification des champs obligatoires
|
||||
"""
|
||||
field_list_obligatoire = ['token', 'apprenant_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, " Les informations fournies sont incorrectes",
|
||||
|
||||
"""
|
||||
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(diction)
|
||||
if (local_status is not True):
|
||||
return local_status, my_partner
|
||||
|
||||
# Verifier que l'apprenant existe deja
|
||||
is_apprenant_exist = MYSY_GV.dbname['apprenant'].count_documents({'_id':ObjectId(str(diction['apprenant_id'])),
|
||||
'partner_owner_recid':str(my_partner['recid']),
|
||||
'valide':'1',
|
||||
'locked':'0'})
|
||||
if( is_apprenant_exist <= 0 ):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " L'identifiant de l'apprenant n'est pas valide ")
|
||||
return False, " L'identifiant de l'apprenant n'est pas valide "
|
||||
|
||||
|
||||
"""
|
||||
Verifier que l'apprenant n'as pas d'incripiotn en cours ou valide
|
||||
"""
|
||||
is_apprenant_has_valide_inscription_count = MYSY_GV.dbname['inscription'].count_documents({'apprenant_id':str(diction['apprenant_id']),
|
||||
'status': {'$in': ['0','1','2'], },
|
||||
'partner_owner_recid':str(my_partner['recid'])})
|
||||
|
||||
if( is_apprenant_has_valide_inscription_count > 0 ):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " Impossible de supprimer l'apprenant, il a "+str(is_apprenant_has_valide_inscription_count)+" inscription(s) en cours ou déjà validée(s) ")
|
||||
return False, " Impossible de supprimer l'apprenant, il a "+str(is_apprenant_has_valide_inscription_count)+" inscription(s) en cours ou déjà validée(s) "
|
||||
|
||||
delete_retval = MYSY_GV.dbname['apprenant'].delete_one(
|
||||
{'_id': ObjectId(str(diction['session_id'])),
|
||||
'partner_owner_recid':str(my_partner['recid'])}
|
||||
)
|
||||
|
||||
return True, " L'apprenant a été correctement supprimé "
|
||||
|
||||
except Exception as e:
|
||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - Line : " + str(exc_tb.tb_lineno))
|
||||
return False, " Impossible de supprimer de l'apprenant "
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Récuperer la liste des apprenants d'un partenaire
|
||||
"""
|
||||
|
@ -447,6 +532,77 @@ def Get_List_Partner_Apprenant(diction):
|
|||
return False, " Impossible de récupérer la liste des apprenants "
|
||||
|
||||
|
||||
"""
|
||||
Recuperer la liste des apprenant avec des filtrer
|
||||
"""
|
||||
|
||||
|
||||
def Get_Apprenant_List_Partner_with_filter(diction):
|
||||
try:
|
||||
field_list = ['token', 'nom', 'prenom', 'email']
|
||||
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]) + " - Le champ '" + val + "' n'est pas autorisé, Creation partenaire annulée")
|
||||
return False, " Toutes les informations fournies ne sont pas valables"
|
||||
|
||||
"""
|
||||
Verification de la liste des champs obligatoires
|
||||
"""
|
||||
field_list_obligatoire = ['token']
|
||||
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, " Toutes les informations necessaires n'ont pas été fournies"
|
||||
|
||||
# Recuperation du recid du partner
|
||||
mydata = {}
|
||||
mytoken = ""
|
||||
if ("token" in diction.keys()):
|
||||
if diction['token']:
|
||||
mytoken = diction['token']
|
||||
|
||||
local_status, my_partner = mycommon.Check_Connexion_And_Return_Partner_Data(diction)
|
||||
if (local_status is not True):
|
||||
return local_status, my_partner
|
||||
|
||||
filt_email = {}
|
||||
if ("email" in diction.keys()):
|
||||
filt_email = {'email': {'$regex': str(diction['email']), "$options": "i"}}
|
||||
|
||||
filt_nom = {}
|
||||
if ("nom" in diction.keys()):
|
||||
filt_nom = {'nom': {'$regex': str(diction['nom']), "$options": "i"}}
|
||||
|
||||
filt_prenom = {}
|
||||
if ("nom" in diction.keys()):
|
||||
filt_prenom = {'prenom': {'$regex': str(diction['prenom']), "$options": "i"}}
|
||||
|
||||
filt_class_partner_recid = {'partner_owner_recid': str(my_partner['recid'])}
|
||||
|
||||
query = [{'$match': {'$and': [filt_email, filt_nom, {'partner_owner_recid': str(my_partner['recid'])}]}},
|
||||
|
||||
]
|
||||
print("#### Get_Apprenant_List_Partner_with_filter laa 01 : query = ", query)
|
||||
RetObject = []
|
||||
cpt = 1
|
||||
for retVal in MYSY_GV.dbname['inscription'].aggregate(query):
|
||||
val = retVal
|
||||
val['id'] = str(cpt)
|
||||
cpt = cpt + 1
|
||||
|
||||
RetObject.append(mycommon.JSONEncoder().encode(val))
|
||||
|
||||
return True, RetObject
|
||||
|
||||
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 la liste des apprenants"
|
||||
|
||||
|
||||
"""
|
||||
Inscrire un apprenant à un session de formation.
|
||||
|
||||
|
@ -575,3 +731,229 @@ def Apprenant_Inscrire_Session(diction):
|
|||
return False, " Impossible d'inscrire l'apprenant à la session de formation "
|
||||
|
||||
|
||||
"""
|
||||
Cette fonction ajoute ou met à jour une image de profil d'un apprenant
|
||||
"""
|
||||
def Add_Update_Apprenant_Image(file_img=None, Folder=None, diction=None):
|
||||
try:
|
||||
|
||||
# Dictionnaire des champs utilisables
|
||||
'''
|
||||
# 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', 'file_img_recid', 'apprenant_id' ]
|
||||
|
||||
|
||||
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]) + " : Le champ '"+val + "' n'est pas autorisé ")
|
||||
return False, " Le champ '" + val + "' n'est pas accepté "
|
||||
|
||||
'''
|
||||
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', 'file_img_recid', 'apprenant_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, " La valeur '" + val + "' n'est pas presente dans liste "
|
||||
|
||||
# recuperation des paramettre
|
||||
token = ""
|
||||
if ("token" in diction.keys()):
|
||||
if diction['token']:
|
||||
token = diction['token']
|
||||
|
||||
local_status, my_partner = mycommon.Check_Connexion_And_Return_Partner_Data(diction)
|
||||
if (local_status is not True):
|
||||
return local_status, my_partner
|
||||
|
||||
# Verifier que l'apprenant est valide
|
||||
is_apprenant_id_valide_count = MYSY_GV.dbname['apprenant'].count_documents({'_id':ObjectId(diction['apprenant_id']),
|
||||
'valide':'1',
|
||||
'locked':'0',
|
||||
'partner_owner_recid':str(my_partner['recid'])})
|
||||
|
||||
if( is_apprenant_id_valide_count != 1):
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " L'identifiant de l'apprenant est invalide ")
|
||||
return False, " L'identifiant de l'apprenant est invalide "
|
||||
|
||||
apprenant_id_data = MYSY_GV.dbname['apprenant'].find_one(
|
||||
{'_id': ObjectId(diction['apprenant_id']),
|
||||
'valide': '1',
|
||||
'locked': '0',
|
||||
'partner_owner_recid': str(my_partner['recid'])})
|
||||
|
||||
if( file_img ):
|
||||
recordimage_diction = {}
|
||||
recordimage_diction['token'] = diction['token']
|
||||
recordimage_diction['related_collection'] = "apprenant"
|
||||
recordimage_diction['type_img'] = "user"
|
||||
recordimage_diction['related_collection_recid'] = str(apprenant_id_data['_id'])
|
||||
recordimage_diction['image_recid'] = diction['file_img_recid']
|
||||
|
||||
print(" ### recordimage_diction stagaire = ", recordimage_diction)
|
||||
local_status, local_message = mycommon.recordClassImage_v2(file_img, MYSY_GV.upload_folder, recordimage_diction)
|
||||
if( local_status is False):
|
||||
return local_status, local_message
|
||||
|
||||
return True, "L'image du stagiaire a été correctement enregistrée"
|
||||
|
||||
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'enregistrer l'image de l'apprenant"
|
||||
|
||||
|
||||
""" Recuperation de l'image d'un apprenant
|
||||
|
||||
/!\ important : on prend le 'related_collection_recid' comme le '_id' de la collection de l'apprenant
|
||||
"""
|
||||
def Get_Apprenant_Recorded_Image_from_front(diction=None):
|
||||
try:
|
||||
# Dictionnaire des champs utilisables
|
||||
field_list = ['token', 'apprenant_id']
|
||||
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]) + " - Le champ '" + val + "' n'existe pas, requete annulée")
|
||||
return False, " Impossible de récupérer les informations"
|
||||
|
||||
'''
|
||||
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', 'apprenant_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 les informations"
|
||||
|
||||
|
||||
local_status, my_partner = mycommon.Check_Connexion_And_Return_Partner_Data(diction)
|
||||
if (local_status is not True):
|
||||
return local_status, my_partner
|
||||
|
||||
# Verifier que l'apprenant est valide
|
||||
is_apprenant_id_valide_count = MYSY_GV.dbname['apprenant'].count_documents(
|
||||
{'_id': ObjectId(diction['apprenant_id']),
|
||||
'valide': '1',
|
||||
'locked': '0',
|
||||
'partner_owner_recid': str(my_partner['recid'])})
|
||||
|
||||
if (is_apprenant_id_valide_count != 1):
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " L'identifiant de l'apprenant est invalide ")
|
||||
return False, " L'identifiant de l'apprenant est invalide "
|
||||
|
||||
apprenant_id_data = MYSY_GV.dbname['apprenant'].find_one(
|
||||
{'_id': ObjectId(diction['apprenant_id']),
|
||||
'valide': '1',
|
||||
'locked': '0',
|
||||
'partner_owner_recid': str(my_partner['recid'])})
|
||||
|
||||
|
||||
|
||||
qery_images = {'locked': '0', 'valide': '1', 'related_collection': 'apprenant',
|
||||
'related_collection_recid': str(apprenant_id_data['_id'])}
|
||||
|
||||
|
||||
RetObject = []
|
||||
partner_images = {}
|
||||
# Recuperation des image 'logo' et 'cachet' si le partenaire en a
|
||||
for retVal in MYSY_GV.dbname['mysy_images'].find(qery_images):
|
||||
if ('type_img' in retVal.keys()):
|
||||
if (retVal['type_img'] == "user"):
|
||||
partner_images['logo_img'] = retVal['img'].decode()
|
||||
partner_images['logo_img_recid'] = retVal['recid']
|
||||
|
||||
|
||||
RetObject.append(mycommon.JSONEncoder().encode(partner_images))
|
||||
|
||||
return True, RetObject
|
||||
|
||||
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, " Impossible de recupérer l'image de l'apprenant"
|
||||
|
||||
"""
|
||||
Suppresion d'un image de l'apprenant
|
||||
"""
|
||||
def Delete_Apprenant_Image(diction=None):
|
||||
try:
|
||||
|
||||
# Dictionnaire des champs utilisables
|
||||
field_list = ['token', 'image_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():
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " Le champ '" + val + "' n'est pas accepté dans cette API")
|
||||
return False, " Le champ '" + val + "' n'est pas accepté "
|
||||
|
||||
'''
|
||||
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', 'image_recid']
|
||||
for val in field_list_obligatoire:
|
||||
if str(val).lower() not in diction:
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " La valeur '" + val + "' n'est pas presente dans liste des champs")
|
||||
return False, " La valeur '" + val + "' n'est pas presente dans liste "
|
||||
|
||||
mydata = {}
|
||||
mytoken = ""
|
||||
|
||||
# recuperation des paramettre
|
||||
if ("token" in diction.keys()):
|
||||
if diction['token']:
|
||||
mytoken = diction['token']
|
||||
|
||||
image_recid = ""
|
||||
if ("image_recid" in diction.keys()):
|
||||
if diction['image_recid']:
|
||||
image_recid = diction['image_recid']
|
||||
|
||||
local_status, my_partner = mycommon.Check_Connexion_And_Return_Partner_Data(diction)
|
||||
if (local_status is not True):
|
||||
return local_status, my_partner
|
||||
|
||||
# " Lecture du fichier "
|
||||
# print(" Lecture du fichier : " + saved_file + ". le token est :" + str(mytoken))
|
||||
nb_line = 0
|
||||
coll_name = MYSY_GV.dbname['mysy_images']
|
||||
|
||||
query_delete = {"recid": image_recid,}
|
||||
|
||||
|
||||
ret_val = coll_name.delete_one({"recid": image_recid,}, )
|
||||
|
||||
|
||||
|
||||
#print(" ### recordClassImage_v2 :L'image a été correctement supprimée ")
|
||||
return True, "L'image a été correctement supprimée"
|
||||
|
||||
|
||||
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, "Impossible de supprimer l'image "
|
||||
|
||||
|
||||
|
|
117
main.py
117
main.py
|
@ -67,6 +67,7 @@ import Dashbord_queries.common_tdb_qries as common_tdb_qries
|
|||
import Dashbord_queries.formation_tbd_qries as formation_tbd_qries
|
||||
import Collection_Historique as Collection_Historique
|
||||
import purchase_prices as purchase_prices
|
||||
import apprenant_mgt as apprenant_mgt
|
||||
|
||||
app = Flask(__name__)
|
||||
cors = CORS(app, resources={r"/foo": {"origins": "*"}})
|
||||
|
@ -6485,6 +6486,122 @@ def Get_Partner_Given_Group_Purchase_Price():
|
|||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
"""
|
||||
API Pour ajouter un apprenant
|
||||
"""
|
||||
@app.route('/myclass/api/Add_Apprenant/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Add_Apprenant():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Add_Apprenant payload = ",payload)
|
||||
status, retval = apprenant_mgt.Add_Apprenant(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
"""
|
||||
API pour mettre à jour un apprenant
|
||||
"""
|
||||
@app.route('/myclass/api/Update_Apprenant/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Update_Apprenant():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Update_Apprenant payload = ",payload)
|
||||
status, retval = apprenant_mgt.Update_Apprenant(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
"""
|
||||
API pour supprimer un apprenant
|
||||
"""
|
||||
def Delete_Given_Apprenant():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Delete_Given_Apprenant payload = ",payload)
|
||||
status, retval = apprenant_mgt.Delete_Given_Apprenant(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
"""
|
||||
API pour recuperer une apprenant donnée
|
||||
"""
|
||||
@app.route('/myclass/api/Get_Given_Apprenant_Data/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Get_Given_Apprenant_Data():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Get_Given_Apprenant_Data payload = ",payload)
|
||||
status, retval = apprenant_mgt.Get_Given_Apprenant_Data(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
"""
|
||||
API pour recuperer la liste des apprenant d'un partenaire
|
||||
"""
|
||||
@app.route('/myclass/api/Get_List_Partner_Apprenant/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Get_List_Partner_Apprenant():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Get_List_Partner_Apprenant payload = ",payload)
|
||||
status, retval = apprenant_mgt.Get_List_Partner_Apprenant(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
"""
|
||||
API pour recuperer la liste des apprenant d'un partenaire avec filtre
|
||||
"""
|
||||
@app.route('/myclass/api/Get_Apprenant_List_Partner_with_filter/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Get_Apprenant_List_Partner_with_filter():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Get_Apprenant_List_Partner_with_filter payload = ",payload)
|
||||
status, retval = apprenant_mgt.Get_Apprenant_List_Partner_with_filter(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
"""
|
||||
API Pour Inscrire un apprenant à une session de formation
|
||||
"""
|
||||
@app.route('/myclass/api/Apprenant_Inscrire_Session/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Apprenant_Inscrire_Session():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Apprenant_Inscrire_Session payload = ",payload)
|
||||
status, retval = apprenant_mgt.Apprenant_Inscrire_Session(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
"""
|
||||
API pour enregister ou mettre à jour une image d'un apprenant
|
||||
"""
|
||||
@app.route('/myclass/api/Add_Update_Apprenant_Image/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Add_Update_Apprenant_Image():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Add_Update_Apprenant_Image payload = ",payload)
|
||||
status, retval = apprenant_mgt.Add_Update_Apprenant_Image(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
"""
|
||||
API pour supprimer l'image d'un apprenant
|
||||
"""
|
||||
@app.route('/myclass/api/Delete_Apprenant_Image/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Delete_Apprenant_Image():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Delete_Apprenant_Image payload = ",payload)
|
||||
status, retval = apprenant_mgt.Delete_Apprenant_Image(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
@ -1939,9 +1939,8 @@ def recordClassImage_v2(file=None, Folder=None, diction=None):
|
|||
|
||||
if( ret_val is None or '_id' not in ret_val.keys()):
|
||||
myprint(" IMPOSSIBLE D'ENREGISTRER L'IMAGE")
|
||||
return False, "IMPOSSIBLE D'ENREGISTRER L'IMAGE de la formation "
|
||||
return False, "IMPOSSIBLE D'ENREGISTRER L'IMAGE "
|
||||
|
||||
print(" ### recordClassImage_v2 :L'image a été correctement enregistrée ")
|
||||
return True, "L'image a été correctement enregistrée"
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue