25/12/2023 - 11h
parent
d5f66144f8
commit
c46acf323f
|
@ -3,8 +3,13 @@
|
|||
<component name="ChangeListManager">
|
||||
<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$/GlobalVariable.py" beforeDir="false" afterPath="$PROJECT_DIR$/GlobalVariable.py" 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$/agenda.py" beforeDir="false" afterPath="$PROJECT_DIR$/agenda.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" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
|
|
|
@ -533,7 +533,7 @@ Par defaut il en y a 2 :
|
|||
- ressource_humaine et
|
||||
- ressource_materielle
|
||||
"""
|
||||
ALLOWED_AGENDA_RELATED_COLLECTION = ['ressource_humaine', 'ressource_materielle', 'inscription']
|
||||
ALLOWED_AGENDA_RELATED_COLLECTION = ['ressource_humaine', 'ressource_materielle', 'inscription', 'apprenant']
|
||||
|
||||
"""
|
||||
Les types de location pour une session (intra ou extra ou autre)
|
||||
|
@ -576,3 +576,8 @@ Gestion des prix d'achat / cout employé / cout location materiel
|
|||
Ici on definit la périodicité
|
||||
"""
|
||||
PURCHASE_PRICE_PERIODICITY = ['fixe', 'heure', 'jour', 'mois', 'annee', ]
|
||||
|
||||
"""
|
||||
Les civilité
|
||||
"""
|
||||
CIVILITE = ['m', 'mme', 'neutre', ]
|
|
@ -65,7 +65,7 @@ def AddStagiairetoClass(diction):
|
|||
field_list = ['nom', 'prenom', 'email', 'telephone', 'modefinancement', 'opco',
|
||||
'class_internal_url', 'session_id', 'employeur', 'status', 'price',
|
||||
'inscription_validation_date', 'token', 'client_rattachement_id',
|
||||
'adresse', 'code_postal', 'ville', 'pays', 'type_apprenant' ]
|
||||
'adresse', 'code_postal', 'ville', 'pays', 'type_apprenant', 'apprenant_id' ]
|
||||
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
|
@ -94,6 +94,10 @@ def AddStagiairetoClass(diction):
|
|||
mydata['session_id'] = str(diction['session_id']).strip()
|
||||
session_id = str(diction['session_id']).strip()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Verififier l'existance et la valididé de la session
|
||||
"""
|
||||
|
@ -111,6 +115,11 @@ def AddStagiairetoClass(diction):
|
|||
if diction['token']:
|
||||
mytoken = str(diction['token']).strip()
|
||||
|
||||
apprenant_id = ""
|
||||
if ("apprenant_id" in diction.keys()):
|
||||
if diction['apprenant_id']:
|
||||
mydata['apprenant_id'] = str(diction['apprenant_id']).strip()
|
||||
apprenant_id = str(diction['session_id']).strip()
|
||||
|
||||
"""
|
||||
Recuperation des info de la session de formation
|
||||
|
@ -371,6 +380,8 @@ def AddStagiairetoClass(diction):
|
|||
# Ajout de l'evenement dans l'historique
|
||||
"""
|
||||
now = str(datetime.now().strftime("%d/%m/%Y %H:%M:%S"))
|
||||
#print(" ####### laaaa diction = ", diction)
|
||||
|
||||
history_event_dict = {}
|
||||
history_event_dict['token'] = diction['token']
|
||||
history_event_dict['related_collection'] = "inscription"
|
||||
|
@ -1858,16 +1869,11 @@ def AddStagiairetoClass_mass(file=None, Folder=None, diction=None):
|
|||
if diction['token']:
|
||||
my_token = diction['token']
|
||||
|
||||
partner_recid = mycommon.get_parnter_recid_from_token(my_token)
|
||||
if (partner_recid is False):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " - partner_recid KO : Impossible d'importer la liste des participants ")
|
||||
return False, " Les information de connexion sont incorrectes. Impossible d'importer la liste des participants"
|
||||
local_status, my_partner = mycommon.Check_Connexion_And_Return_Partner_Data({'token': str(diction['token'])})
|
||||
if (local_status is not True):
|
||||
return local_status, my_partner
|
||||
|
||||
# Verifier la validité du token
|
||||
retval = mycommon.check_partner_token_validity("", my_token)
|
||||
if retval is False:
|
||||
return "Err_Connexion", " La session de connexion n'est pas valide"
|
||||
partner_recid = my_partner['recid']
|
||||
|
||||
|
||||
session_id = ""
|
||||
|
@ -1881,7 +1887,6 @@ def AddStagiairetoClass_mass(file=None, Folder=None, diction=None):
|
|||
class_internal_url = diction['class_internal_url']
|
||||
|
||||
|
||||
# Verification de l'existance de la session
|
||||
## Verification de l'existance de session et recuperation du "code_session"
|
||||
session_count = MYSY_GV.dbname['session_formation'].count_documents(
|
||||
{'class_internal_url': str(class_internal_url), 'valide': '1',
|
||||
|
@ -2174,7 +2179,7 @@ def AddStagiairetoClass_mass(file=None, Folder=None, diction=None):
|
|||
|
||||
print(str(total_rows)+" participants ont été inserés")
|
||||
|
||||
return True, str(total_rows)+" participants ont été inserées / Mises à jour"
|
||||
return True, str(total_rows)+" participants ont été inserés / mis à jour"
|
||||
|
||||
except Exception as e:
|
||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||
|
|
5454
Log/log_file.log
5454
Log/log_file.log
File diff suppressed because it is too large
Load Diff
|
@ -545,15 +545,11 @@ def GetSessionFormation(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({'token':str(diction['token'])})
|
||||
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']
|
||||
|
||||
class_internal_url = ""
|
||||
if ("class_internal_url" in diction.keys()):
|
||||
|
@ -5136,3 +5132,4 @@ def Create_Convention_By_Stagiaire_PDF(diction):
|
|||
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - Line : " + str(exc_tb.tb_lineno))
|
||||
return False, " Impossible de créer le fichier pdf de convention par stagiaire "
|
||||
|
||||
|
||||
|
|
34
agenda.py
34
agenda.py
|
@ -234,16 +234,34 @@ def Add_Update_Agenda_Event_Stagiaire(diction):
|
|||
|
||||
|
||||
# Verifier que 'related_collection_email' existe et est valide dans la collection 'related_collection'
|
||||
is_existe_valide_related_collection_recid = MYSY_GV.dbname[str(diction['related_collection'])].count_documents({'email':str(diction['related_collection_email']),
|
||||
'partner_owner_recid':str(my_partner['recid']),
|
||||
'status':'1'
|
||||
})
|
||||
"""
|
||||
/!\ : 24/12/2023 -
|
||||
Quand on est sur une inscription, on travail avec l'adresse emai. Cela devra bientot changé
|
||||
une fois que le module 'apprenant' est ok, alors on pourra tout basculer sur l'apprenant et travailler avec l'_id
|
||||
"""
|
||||
if( str(str(diction['related_collection'])) == "inscription") :
|
||||
is_existe_valide_related_collection_recid = MYSY_GV.dbname[str(diction['related_collection'])].count_documents({'email':str(diction['related_collection_email']),
|
||||
'partner_owner_recid':str(my_partner['recid']),
|
||||
'status':'1'
|
||||
})
|
||||
|
||||
if( is_existe_valide_related_collection_recid <= 0):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " - L'identifiant du 'related_collection_recid' n'est pas valide ")
|
||||
return False, " L'identifiant du 'related_collection_recid' n'est pas valide "
|
||||
if( is_existe_valide_related_collection_recid <= 0):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " - L'identifiant du 'related_collection_recid' n'est pas valide ")
|
||||
return False, " L'identifiant du 'related_collection_recid' n'est pas valide "
|
||||
|
||||
else:
|
||||
is_existe_valide_related_collection_recid = MYSY_GV.dbname[
|
||||
str(diction['related_collection'])].count_documents({'_id': ObjectId(str(diction['inscription_id'])),
|
||||
'partner_owner_recid': str(my_partner['recid']),
|
||||
'valide': '1',
|
||||
'locked':'0'
|
||||
})
|
||||
|
||||
if (is_existe_valide_related_collection_recid <= 0):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " - L'identifiant du 'related_collection_recid' n'est pas valide ")
|
||||
return False, " L'identifiant du 'related_collection_recid' n'est pas valide "
|
||||
|
||||
if (datetime.strptime(str(diction['event_start'])[0:16], '%Y-%m-%dT%H:%M') >= datetime.strptime(str(diction['event_end'])[0:16],
|
||||
'%Y-%m-%dT%H:%M')):
|
||||
|
|
586
apprenant_mgt.py
586
apprenant_mgt.py
|
@ -4,6 +4,8 @@ Ce fichier permet de gerer les apprenants.
|
|||
Un apprenant est crée apres la validation d'une inscription ou sans.
|
||||
|
||||
"""
|
||||
import ast
|
||||
|
||||
import pymongo
|
||||
from pymongo import MongoClient
|
||||
import json
|
||||
|
@ -23,7 +25,7 @@ import GlobalVariable as MYSY_GV
|
|||
import ela_index_bdd_classes as eibdd
|
||||
import email_mgt as email
|
||||
import Inscription_mgt as Inscription_mgt
|
||||
|
||||
import Session_Formation as sf
|
||||
|
||||
"""
|
||||
Ajout d'un apprenant.
|
||||
|
@ -207,7 +209,7 @@ def Update_Apprenant(diction):
|
|||
'tuteur1_nom', 'tuteur1_prenom', 'tuteur1_email', 'tuteur1_telephone', 'tuteur1_adresse',
|
||||
'tuteur1_cp', 'tuteur1_ville', 'tuteur1_pays', 'tuteur1_include_com',
|
||||
'tuteur2_nom', 'tuteur2_prenom', 'tuteur2_email', 'tuteur2_telephone', 'tuteur2_adresse',
|
||||
'tuteur2_cp', 'tuteur2_ville', 'tuteur2_pays', 'tuteur2_include_com',
|
||||
'tuteur2_cp', 'tuteur2_ville', 'tuteur2_pays', 'tuteur2_include_com', 'civilite'
|
||||
]
|
||||
|
||||
incom_keys = diction.keys()
|
||||
|
@ -288,6 +290,7 @@ def Update_Apprenant(diction):
|
|||
return False, " L'identifiant du client n'est pas valide ",
|
||||
|
||||
apprenant_id = str(diction['_id'])
|
||||
stored_token = str(diction['token'])
|
||||
new_data = diction
|
||||
del new_data['token']
|
||||
del new_data['_id']
|
||||
|
@ -312,9 +315,9 @@ def Update_Apprenant(diction):
|
|||
## Add to log history
|
||||
now = str(datetime.now().strftime("%d/%m/%Y %H:%M:%S"))
|
||||
history_event_dict = {}
|
||||
history_event_dict['token'] = diction['token']
|
||||
history_event_dict['token'] = stored_token
|
||||
history_event_dict['related_collection'] = "apprenant"
|
||||
history_event_dict['related_collection_recid'] = str(diction['inscription_id'])
|
||||
history_event_dict['related_collection_recid'] = apprenant_id
|
||||
history_event_dict['action_date'] = str(now)
|
||||
history_event_dict['action_description'] = "Mise à jour "
|
||||
local_status, local_retval = mycommon.Collection_Historique.Add_Historique_Event(history_event_dict)
|
||||
|
@ -483,7 +486,7 @@ def Delete_Given_Apprenant(diction):
|
|||
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'])),
|
||||
{'_id': ObjectId(str(diction['apprenant_id'])),
|
||||
'partner_owner_recid':str(my_partner['recid'])}
|
||||
)
|
||||
|
||||
|
@ -648,7 +651,7 @@ def Apprenant_Inscrire_Session(diction):
|
|||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', '_id', 'session_id', 'type_apprenant' ]
|
||||
field_list = ['token', '_id', 'session_id', 'type_apprenant' , 'modefinancement']
|
||||
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
|
@ -702,7 +705,7 @@ def Apprenant_Inscrire_Session(diction):
|
|||
return False, " L'identifiant de l'apprenant n'est pas valide ",
|
||||
|
||||
# Recuperer les données de l'apprenant
|
||||
apprenant_data = MYSY_GV.dbname['apprenant'].count_documents({'_id': ObjectId(str(diction['_id'])),
|
||||
apprenant_data = MYSY_GV.dbname['apprenant'].find_one({'_id': ObjectId(str(diction['_id'])),
|
||||
'partner_owner_recid': str(my_partner['recid']),
|
||||
'valide': '1',
|
||||
'locked': '0'})
|
||||
|
@ -727,7 +730,14 @@ def Apprenant_Inscrire_Session(diction):
|
|||
|
||||
|
||||
new_data = {}
|
||||
new_data['token'] = diction['token']
|
||||
new_data['email'] = apprenant_data['email']
|
||||
new_data['nom'] = apprenant_data['nom']
|
||||
new_data['prenom'] = apprenant_data['prenom']
|
||||
new_data['telephone'] = apprenant_data['telephone']
|
||||
new_data['modefinancement'] = str(diction['modefinancement'])
|
||||
|
||||
|
||||
new_data['apprenant_id'] = str(apprenant_data['_id'])
|
||||
new_data['session_id'] = str(session_data['_id'])
|
||||
new_data['class_internal_url'] = session_data['class_internal_url']
|
||||
|
@ -736,9 +746,9 @@ def Apprenant_Inscrire_Session(diction):
|
|||
|
||||
|
||||
new_data['inscription_validation_date'] = str(datetime.now().strftime("%d/%m/%Y %H:%M:%S"))
|
||||
new_data['date_update'] = str(datetime.now())
|
||||
new_data['update_by'] = str(my_partner['_id'])
|
||||
new_data['partner_owner_recid'] = str(my_partner['recid'])
|
||||
#new_data['date_update'] = str(datetime.now())
|
||||
#new_data['update_by'] = str(my_partner['_id'])
|
||||
#new_data['partner_owner_recid'] = str(my_partner['recid'])
|
||||
|
||||
local_status, local_retval = Inscription_mgt.AddStagiairetoClass(new_data)
|
||||
if( local_status is False ):
|
||||
|
@ -749,7 +759,7 @@ def Apprenant_Inscrire_Session(diction):
|
|||
history_event_dict = {}
|
||||
history_event_dict['token'] = diction['token']
|
||||
history_event_dict['related_collection'] = "apprenant"
|
||||
history_event_dict['related_collection_recid'] = str(diction['inscription_id'])
|
||||
history_event_dict['related_collection_recid'] = str(diction['_id'])
|
||||
history_event_dict['action_date'] = str(now)
|
||||
history_event_dict['action_description'] = "Inscription session "+str(session_data["code_session"])
|
||||
local_status, local_retval = mycommon.Collection_Historique.Add_Historique_Event(history_event_dict)
|
||||
|
@ -765,6 +775,124 @@ def Apprenant_Inscrire_Session(diction):
|
|||
return False, " Impossible d'inscrire l'apprenant à la session de formation "
|
||||
|
||||
|
||||
"""
|
||||
Recuperation de la liste des inscriptions de cet apprenant
|
||||
"""
|
||||
def Get_Apprenant_List_Inscription(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', '_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', '_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['_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 ",
|
||||
|
||||
RetObject = []
|
||||
val_tmp = 1
|
||||
|
||||
|
||||
for val in MYSY_GV.dbname['inscription'].find({'apprenant_id':str(diction['_id']),
|
||||
'partner_owner_recid':str(my_partner['recid']),
|
||||
}, {"_id":1, "class_internal_url":1,"session_id":1, 'status':1,
|
||||
"inscription_validation_date":1, "modefinancement":1, "inscription_refuse_date":1,}):
|
||||
user = val
|
||||
user['id'] = str(val_tmp)
|
||||
val_tmp = val_tmp + 1
|
||||
local_diction = {'token':str(diction['token']), 'class_internal_url':str(val['class_internal_url']), 'session_id':str(val['session_id'])}
|
||||
|
||||
local_status, local_retval_str = sf.GetSessionFormation(local_diction)
|
||||
if( local_status is False ):
|
||||
return local_status, local_retval
|
||||
|
||||
|
||||
local_retval = ast.literal_eval(local_retval_str[0])
|
||||
|
||||
if( local_retval and "title" in local_retval.keys()):
|
||||
user['class_title'] = local_retval['title']
|
||||
|
||||
if (local_retval and "formateur_nom_prenom" in local_retval.keys()):
|
||||
user['formateur_nom_prenom'] = local_retval['formateur_nom_prenom']
|
||||
|
||||
if (local_retval and "date_debut" in local_retval.keys()):
|
||||
user['date_debut'] = local_retval['date_debut']
|
||||
|
||||
if (local_retval and "date_fin" in local_retval.keys()):
|
||||
user['date_fin'] = local_retval['date_fin']
|
||||
|
||||
if (local_retval and "distantiel" in local_retval.keys()):
|
||||
user['distantiel'] = local_retval['distantiel']
|
||||
|
||||
if (local_retval and "presentiel" in local_retval.keys()):
|
||||
user['presentiel'] = local_retval['presentiel']
|
||||
|
||||
if (local_retval and "session_ondemande" in local_retval.keys()):
|
||||
user['session_ondemande'] = local_retval['session_ondemande']
|
||||
|
||||
if (local_retval and "prix_session" in local_retval.keys()):
|
||||
user['prix_session'] = local_retval['prix_session']
|
||||
|
||||
if (local_retval and "location_type" in local_retval.keys()):
|
||||
user['location_type'] = local_retval['location_type']
|
||||
|
||||
if (local_retval and "is_bpf" in local_retval.keys()):
|
||||
user['is_bpf'] = local_retval['is_bpf']
|
||||
|
||||
if (local_retval and "code_session" in local_retval.keys()):
|
||||
user['code_session'] = local_retval['code_session']
|
||||
|
||||
|
||||
RetObject.append(mycommon.JSONEncoder().encode(user))
|
||||
|
||||
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) + " - Line : " + str(exc_tb.tb_lineno))
|
||||
return False, " Impossible de récupérer les inscriptions de l'apprenant "
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Cette fonction ajoute ou met à jour une image de profil d'un apprenant
|
||||
"""
|
||||
|
@ -991,3 +1119,439 @@ def Delete_Apprenant_Image(diction=None):
|
|||
return False, "Impossible de supprimer l'image "
|
||||
|
||||
|
||||
"""
|
||||
Cette fonction import des apprenants en mass avec un fichier csv (utf-8)
|
||||
"""
|
||||
|
||||
def Add_Apprenant_mass(file=None, Folder=None, diction=None):
|
||||
try:
|
||||
|
||||
'''
|
||||
# Verification que les champs reçus dans l'API sont bien dans la liste des champs autorisés
|
||||
# Cela evite le cas ou une entité tierce ajouter les valeurs inconnu dans l'API
|
||||
# Ici on doit mettre tous les champs possible (obligatoire ou non) de la BDD dans la liste
|
||||
# field_list.
|
||||
'''
|
||||
field_list = ['token',]
|
||||
|
||||
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")
|
||||
return False, " Verifier votre API, Toutes les informations techniques ne sont pas fournies"
|
||||
|
||||
'''
|
||||
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 val not in diction:
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " - La valeur '" + val + "' n'est pas presente dans liste ")
|
||||
return False, " Verifier votre API, Toutes les informations techniques ne sont pas fournies"
|
||||
|
||||
my_token = ""
|
||||
if ("token" in diction.keys()):
|
||||
if diction['token']:
|
||||
my_token = diction['token']
|
||||
|
||||
local_status, my_partner = mycommon.Check_Connexion_And_Return_Partner_Data({'token': str(diction['token'])})
|
||||
if (local_status is not True):
|
||||
return local_status, my_partner
|
||||
|
||||
|
||||
status, saved_file = mycommon.Upload_Save_CSV_File(file, Folder)
|
||||
if (status == False):
|
||||
mycommon.myprint("Impossible de récupérer correctement le fichier à importer")
|
||||
return False, "Impossible d'importer la liste des apprenants, le nom du fichier est incorrect "
|
||||
|
||||
|
||||
nb_line = 0
|
||||
|
||||
local_controle_status, local_controle_message = Controle_Add_Apprenant_mass(saved_file, Folder, diction)
|
||||
|
||||
if (local_controle_status is False):
|
||||
return local_controle_status, local_controle_message
|
||||
|
||||
df = pd.read_csv(saved_file, encoding='utf8', on_bad_lines='skip', sep=';', encoding_errors='ignore')
|
||||
df = df.fillna('')
|
||||
|
||||
'''
|
||||
# Verification que les noms des colonne sont bien corrects"
|
||||
'''
|
||||
field_list = ['token', 'nom', 'email', 'prenom', 'civilite', 'telephone', 'employeur', 'client_rattachement_email',
|
||||
'adresse', 'code_postal',
|
||||
'ville', 'pays', 'tuteur1_nom', 'tuteur1_prenom', 'tuteur1_email', 'tuteur1_telephone',
|
||||
'tuteur2_nom', 'tuteur2_prenom',
|
||||
'tuteur2_email', 'tuteur2_telephone', 'opco', 'comment', 'tuteur1_adresse', 'tuteur1_cp',
|
||||
'tuteur1_ville', 'tuteur1_pays',
|
||||
'tuteur1_include_com', 'tuteur2_adresse', 'tuteur2_cp', 'tuteur2_ville', 'tuteur2_pays',
|
||||
'tuteur2_include_com']
|
||||
|
||||
# Controle du nombre de lignes dans le fichier.
|
||||
total_rows = len(df)
|
||||
if (total_rows > MYSY_GV.MAX_PARTICIPANT_BY_CSV):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " Le fichier comporte plus de " + str(
|
||||
MYSY_GV.MAX_PARTICIPANT_BY_CSV) + " lignes.")
|
||||
return False, " Le fichier comporte plus de " + str(MYSY_GV.MAX_PARTICIPANT_BY_CSV) + " lignes."
|
||||
|
||||
|
||||
for val in df.columns:
|
||||
if str(val).lower() not in field_list and val.startswith('my_') is False:
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3])+" : entete du fichier csv. '" + val + "' n'est pas acceptée")
|
||||
return False, " Entete du fichier csv. La Colonne '" + val + "' n'est pas acceptée"
|
||||
|
||||
# Verification des champs obligatoires dans le fichier
|
||||
field_list_obligatoire_file = ['prenom', 'nom', 'email', 'civilite']
|
||||
|
||||
for val in field_list_obligatoire_file:
|
||||
if val not in df.columns:
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " : Le champ '" + val + "' n'est pas présent dans le fichier. Il est obligatoire")
|
||||
return False, " Le champ '" + val + "' n'est pas présent dans le fichier. Il est obligatoire "
|
||||
|
||||
x = range(0, total_rows)
|
||||
for n in x:
|
||||
mydata = {}
|
||||
mydata['prenom'] = str(df['prenom'].values[n])
|
||||
mydata['nom'] = str(df['nom'].values[n])
|
||||
mydata['email'] = str(df['email'].values[n])
|
||||
mydata['civilite'] = str(df['civilite'].values[n])
|
||||
|
||||
|
||||
telephone = ""
|
||||
if ("telephone" in df.keys()):
|
||||
if (str(df['telephone'].values[n])):
|
||||
telephone = str(df['telephone'].values[n])
|
||||
mydata['telephone'] = telephone
|
||||
|
||||
employeur = ""
|
||||
if ("employeur" in df.keys()):
|
||||
if (str(df['employeur'].values[n])):
|
||||
employeur = str(df['employeur'].values[n])
|
||||
mydata['employeur'] = employeur
|
||||
|
||||
adresse = ""
|
||||
if ("adresse" in df.keys()):
|
||||
if (str(df['adresse'].values[n])):
|
||||
adresse = str(df['adresse'].values[n])
|
||||
mydata['adresse'] = adresse
|
||||
|
||||
code_postal = ""
|
||||
if ("code_postal" in df.keys()):
|
||||
if (str(df['code_postal'].values[n])):
|
||||
code_postal = str(df['code_postal'].values[n])
|
||||
mydata['code_postal'] = code_postal
|
||||
|
||||
ville = ""
|
||||
if ("ville" in df.keys()):
|
||||
if (str(df['ville'].values[n])):
|
||||
ville = str(df['ville'].values[n])
|
||||
mydata['ville'] = ville
|
||||
|
||||
pays = ""
|
||||
if ("pays" in df.keys()):
|
||||
if (str(df['pays'].values[n])):
|
||||
pays = str(df['pays'].values[n])
|
||||
mydata['pays'] = pays
|
||||
|
||||
tuteur1_nom = ""
|
||||
if ("tuteur1_nom" in df.keys()):
|
||||
if (str(df['tuteur1_nom'].values[n])):
|
||||
tuteur1_nom = str(df['tuteur1_nom'].values[n])
|
||||
mydata['tuteur1_nom'] = tuteur1_nom
|
||||
|
||||
tuteur1_prenom = ""
|
||||
if ("tuteur1_prenom" in df.keys()):
|
||||
if (str(df['tuteur1_prenom'].values[n])):
|
||||
tuteur1_prenom = str(df['tuteur1_prenom'].values[n])
|
||||
mydata['tuteur1_prenom'] = tuteur1_prenom
|
||||
|
||||
tuteur1_email = ""
|
||||
if ("tuteur1_email" in df.keys()):
|
||||
if (str(df['tuteur1_email'].values[n])):
|
||||
tuteur1_email = str(df['tuteur1_email'].values[n])
|
||||
mydata['tuteur1_email'] = tuteur1_email
|
||||
|
||||
tuteur1_telephone = ""
|
||||
if ("tuteur1_telephone" in df.keys()):
|
||||
if (str(df['tuteur1_telephone'].values[n])):
|
||||
tuteur1_telephone = str(df['tuteur1_telephone'].values[n])
|
||||
mydata['tuteur1_telephone'] = tuteur1_telephone
|
||||
|
||||
tuteur2_nom = ""
|
||||
if ("tuteur2_nom" in df.keys()):
|
||||
if (str(df['tuteur2_nom'].values[n])):
|
||||
tuteur2_nom = str(df['tuteur2_nom'].values[n])
|
||||
mydata['tuteur2_nom'] = tuteur2_nom
|
||||
|
||||
tuteur2_prenom = ""
|
||||
if ("tuteur2_prenom" in df.keys()):
|
||||
if (str(df['tuteur2_prenom'].values[n])):
|
||||
tuteur2_prenom = str(df['tuteur2_prenom'].values[n])
|
||||
mydata['tuteur2_prenom'] = tuteur2_prenom
|
||||
|
||||
tuteur2_email = ""
|
||||
if ("tuteur2_email" in df.keys()):
|
||||
if (str(df['tuteur2_email'].values[n])):
|
||||
tuteur2_email = str(df['tuteur2_email'].values[n])
|
||||
mydata['tuteur2_email'] = tuteur2_email
|
||||
|
||||
tuteur2_telephone = ""
|
||||
if ("tuteur2_telephone" in df.keys()):
|
||||
if (str(df['tuteur2_telephone'].values[n])):
|
||||
tuteur2_telephone = str(df['tuteur2_telephone'].values[n])
|
||||
mydata['tuteur2_telephone'] = tuteur2_telephone
|
||||
|
||||
opco = ""
|
||||
if ("opco" in df.keys()):
|
||||
if (str(df['opco'].values[n])):
|
||||
opco = str(df['opco'].values[n])
|
||||
mydata['opco'] = opco
|
||||
|
||||
tuteur1_adresse = ""
|
||||
if ("tuteur1_adresse" in df.keys()):
|
||||
if (str(df['tuteur1_adresse'].values[n])):
|
||||
tuteur1_adresse = str(df['tuteur1_adresse'].values[n])
|
||||
mydata['tuteur1_adresse'] = tuteur1_adresse
|
||||
|
||||
tuteur1_cp = ""
|
||||
if ("tuteur1_cp" in df.keys()):
|
||||
if (str(df['tuteur1_cp'].values[n])):
|
||||
tuteur1_cp = str(df['tuteur1_cp'].values[n])
|
||||
mydata['tuteur1_cp'] = tuteur1_cp
|
||||
|
||||
tuteur1_ville = ""
|
||||
if ("tuteur1_ville" in df.keys()):
|
||||
if (str(df['tuteur1_ville'].values[n])):
|
||||
tuteur1_ville = str(df['tuteur1_ville'].values[n])
|
||||
mydata['tuteur1_ville'] = tuteur1_ville
|
||||
|
||||
tuteur1_pays = ""
|
||||
if ("tuteur1_pays" in df.keys()):
|
||||
if (str(df['tuteur1_pays'].values[n])):
|
||||
tuteur1_pays = str(df['tuteur1_pays'].values[n])
|
||||
mydata['tuteur1_pays'] = tuteur1_pays
|
||||
|
||||
tuteur1_include_com = ""
|
||||
if ("tuteur1_include_com" in df.keys()):
|
||||
if (str(df['tuteur1_include_com'].values[n])):
|
||||
tuteur1_include_com = str(df['tuteur1_include_com'].values[n])
|
||||
mydata['tuteur1_include_com'] = tuteur1_include_com
|
||||
|
||||
tuteur2_adresse = ""
|
||||
if ("tuteur2_adresse" in df.keys()):
|
||||
if (str(df['tuteur2_adresse'].values[n])):
|
||||
tuteur2_adresse = str(df['tuteur2_adresse'].values[n])
|
||||
mydata['tuteur2_adresse'] = tuteur2_adresse
|
||||
|
||||
tuteur2_cp = ""
|
||||
if ("tuteur2_cp" in df.keys()):
|
||||
if (str(df['tuteur2_cp'].values[n])):
|
||||
tuteur2_cp = str(df['tuteur2_cp'].values[n])
|
||||
mydata['tuteur2_cp'] = tuteur2_cp
|
||||
|
||||
tuteur2_ville = ""
|
||||
if ("tuteur2_ville" in df.keys()):
|
||||
if (str(df['tuteur2_ville'].values[n])):
|
||||
tuteur2_ville = str(df['tuteur2_ville'].values[n])
|
||||
mydata['tuteur2_ville'] = tuteur2_ville
|
||||
|
||||
tuteur2_pays = ""
|
||||
if ("tuteur2_pays" in df.keys()):
|
||||
if (str(df['tuteur2_pays'].values[n])):
|
||||
tuteur2_pays = str(df['tuteur2_pays'].values[n])
|
||||
mydata['tuteur2_pays'] = tuteur2_pays
|
||||
|
||||
tuteur2_include_com = ""
|
||||
if ("tuteur2_include_com" in df.keys()):
|
||||
if (str(df['tuteur2_include_com'].values[n])):
|
||||
tuteur2_include_com = str(df['tuteur2_include_com'].values[n])
|
||||
mydata['tuteur2_include_com'] = tuteur2_include_com
|
||||
|
||||
comment = ""
|
||||
if ("comment" in df.keys()):
|
||||
if (str(df['comment'].values[n])):
|
||||
comment = str(df['comment'].values[n])
|
||||
mydata['comment'] = comment
|
||||
|
||||
client_rattachement_id = ""
|
||||
client_rattachement_email = ""
|
||||
if ("client_rattachement_email" in df.keys()):
|
||||
if (str(df['client_rattachement_email'].values[n])):
|
||||
client_rattachement_email = str(df['client_rattachement_email'].values[n])
|
||||
client_rattachement_data = MYSY_GV.dbname['partner_client'].find_one({'email':str(client_rattachement_email),
|
||||
'valide':'1',
|
||||
'locked':'0',
|
||||
'partner_recid':str(my_partner['recid'])},
|
||||
{'_id':1})
|
||||
|
||||
if( '_id' in client_rattachement_data.keys()):
|
||||
client_rattachement_id = client_rattachement_data['_id']
|
||||
|
||||
|
||||
|
||||
mydata['client_rattachement_id'] = client_rattachement_id
|
||||
|
||||
|
||||
clean_dict = {k: mydata[k] for k in mydata if (str(mydata[k]) != "nan")}
|
||||
|
||||
clean_dict['token'] = diction['token']
|
||||
|
||||
print("#### clean_dict ", clean_dict)
|
||||
email_to_check = ""
|
||||
if( "email" in clean_dict.keys() ):
|
||||
"""
|
||||
Si l'email existe on fait une mise à jour
|
||||
Si non on fait une insertion
|
||||
"""
|
||||
is_exist_apprenant = MYSY_GV.dbname['apprenant'].count_documents({'email':str(clean_dict['email']),
|
||||
'valide':'1',
|
||||
'partner_owner_recid':str(my_partner['recid'])})
|
||||
|
||||
if( is_exist_apprenant <= 0 ):
|
||||
status, retval = Add_Apprenant(clean_dict)
|
||||
if (status is False):
|
||||
return status, retval
|
||||
else:
|
||||
is_exist_apprenant_data = MYSY_GV.dbname['apprenant'].find_one({'email': str(clean_dict['email']),
|
||||
'valide': '1',
|
||||
'partner_owner_recid': str(
|
||||
my_partner['recid'])})
|
||||
print(" ### is_exist_apprenant_data = ", is_exist_apprenant_data)
|
||||
clean_dict['_id'] = str(is_exist_apprenant_data['_id'])
|
||||
status, retval = Update_Apprenant(clean_dict)
|
||||
if (status is False):
|
||||
return status, retval
|
||||
|
||||
|
||||
print(str(total_rows)+" participants ont été inserés")
|
||||
|
||||
return True, str(total_rows)+" apprenant ont été inserés / mis à jour"
|
||||
|
||||
except Exception as e:
|
||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
|
||||
return False, "Impossible d'importer les apprenants en masse "
|
||||
|
||||
|
||||
"""
|
||||
Controle du fichier et de sa cohérence
|
||||
"""
|
||||
def Controle_Add_Apprenant_mass(saved_file=None, Folder=None, diction=None):
|
||||
try:
|
||||
|
||||
local_status, my_partner = mycommon.Check_Connexion_And_Return_Partner_Data({'token': str(diction['token'])})
|
||||
if (local_status is not True):
|
||||
return local_status, my_partner
|
||||
|
||||
df = pd.read_csv(saved_file, encoding='utf8', on_bad_lines='skip', sep=';', encoding_errors='ignore')
|
||||
df = df.fillna('')
|
||||
|
||||
total_rows = len(df)
|
||||
|
||||
field_list = ['nom', 'email', 'prenom', 'civilite', 'telephone', 'employeur', 'client_rattachement_email',
|
||||
'adresse', 'code_postal',
|
||||
'ville', 'pays', 'tuteur1_nom', 'tuteur1_prenom', 'tuteur1_email', 'tuteur1_telephone',
|
||||
'tuteur2_nom', 'tuteur2_prenom',
|
||||
'tuteur2_email', 'tuteur2_telephone', 'opco', 'comment', 'tuteur1_adresse', 'tuteur1_cp',
|
||||
'tuteur1_ville', 'tuteur1_pays',
|
||||
'tuteur1_include_com', 'tuteur2_adresse', 'tuteur2_cp', 'tuteur2_ville', 'tuteur2_pays',
|
||||
'tuteur2_include_com', 'token']
|
||||
|
||||
x = range(0, total_rows)
|
||||
for n in x:
|
||||
mydata = {}
|
||||
mydata['prenom'] = str(df['prenom'].values[n])
|
||||
mydata['nom'] = str(df['nom'].values[n])
|
||||
mydata['email'] = str(df['email'].values[n])
|
||||
mydata['civilite'] = str(df['civilite'].values[n])
|
||||
|
||||
if (len(str(mydata['nom']).strip()) < 2):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " Le champ 'nom' de la ligne " + str(
|
||||
n + 2) + " doit faire plus de deux caractères.")
|
||||
return False, " Le champ 'nom' de la ligne " + str(
|
||||
n + 2) + " doit faire plus de deux caractères. "
|
||||
|
||||
if (len(str(mydata['prenom']).strip()) < 2):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " Le champ 'prenom' de la ligne " + str(
|
||||
n + 2) + " doit faire plus de deux caractères.")
|
||||
return False, " Le champ 'prenom' de la ligne " + str(
|
||||
n + 2) + " doit faire plus de deux caractères. "
|
||||
|
||||
if ( str(mydata['civilite']).lower() not in MYSY_GV.CIVILITE ):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " Le champ 'civilite' de la ligne " + str(
|
||||
n + 2) + " est invalide ")
|
||||
return False, " Le champ 'civilite' de la ligne " + str(
|
||||
n + 2) + " est invalide. "
|
||||
|
||||
|
||||
|
||||
tuteur1_email = ""
|
||||
if ("tuteur1_email" in df.keys() and df['tuteur1_email'].values[n]):
|
||||
tuteur1_email = str(df['tuteur1_email'].values[n])
|
||||
if (mycommon.isEmailValide(str(tuteur1_email)) is False):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " L'adresse email du tuteur1 '"+str(tuteur1_email)+"' de la ligne " + str(
|
||||
n + 2) + " est invalide ")
|
||||
return False, " L'adresse email du tuteur1 '"+str(tuteur1_email)+"' de la ligne " + str(
|
||||
n + 2) + " est invalide "
|
||||
|
||||
tuteur2_email = ""
|
||||
if ("tuteur2_email" in df.keys() and df['tuteur2_email'].values[n]):
|
||||
tuteur2_email = str(df['tuteur2_email'].values[n])
|
||||
if (mycommon.isEmailValide(str(tuteur2_email)) is False):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " L'adresse email du tuteur2 "+str(tuteur2_email)+" de la ligne " + str(
|
||||
n + 2) + " est invalide ")
|
||||
return False, " L'adresse email du tuteur2 "+str(tuteur2_email)+" de la ligne " + str(
|
||||
n + 2) + " est invalide "
|
||||
|
||||
client_rattachement_id = ""
|
||||
client_rattachement_email = ""
|
||||
if ("client_rattachement_email" in df.keys()):
|
||||
if (str(df['client_rattachement_email'].values[n])):
|
||||
client_rattachement_email = str(df['client_rattachement_email'].values[n])
|
||||
client_rattachement_data_count = MYSY_GV.dbname['partner_client'].count_documents(
|
||||
{'email': str(client_rattachement_email),
|
||||
'valide': '1',
|
||||
'locked': '0',
|
||||
'partner_recid': str(my_partner['recid'])})
|
||||
|
||||
if (client_rattachement_data_count < 0):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " L'email du client de rattachement de la ligne " + str(
|
||||
n + 2) + " est invalide ")
|
||||
return False, " L'email du client de rattachement de la ligne " + str(
|
||||
n + 2) + " est invalide "
|
||||
|
||||
|
||||
is_exist_apprenant_locked = MYSY_GV.dbname['apprenant'].count_documents({'email': str(mydata['email']),
|
||||
'locked': '1',
|
||||
'partner_owner_recid': str(
|
||||
my_partner['recid'])})
|
||||
|
||||
if (is_exist_apprenant_locked > 0):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " L'apprenant avec l'adresse email : "+str(mydata['email'])+" de la ligne " + str(
|
||||
n + 2) + " est verrouillé ")
|
||||
return False, " L'apprenant avec l'adresse email : "+str(mydata['email'])+" de la ligne " + str(
|
||||
n + 2) + " est verrouillé "
|
||||
|
||||
return True, str(total_rows) + " apprenants lus dans le fichier excel"
|
||||
|
||||
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 controler le fichier des apprenants "
|
||||
|
|
67
main.py
67
main.py
|
@ -2558,7 +2558,7 @@ def AddStagiairetoClass_mass():
|
|||
if request.method == 'POST':
|
||||
# Create variable for uploaded file
|
||||
f = request.files['File']
|
||||
localStatus, message = inscription.AddStagiairetoClass_mass(f, app.config['UPLOAD_FOLDER'], payload)
|
||||
localStatus, message = inscription.AddStagiairetoClass_mass(f, MYSY_GV.TEMPORARY_DIRECTORY_V2, payload)
|
||||
#status, retval = cm.add_class_mass(f, app.config['UPLOAD_FOLDER'], payload)
|
||||
|
||||
return jsonify(status=localStatus, message=message)
|
||||
|
@ -2579,7 +2579,7 @@ def AddStagiairetoClass_mass_for_many_session():
|
|||
if request.method == 'POST':
|
||||
# Create variable for uploaded file
|
||||
f = request.files['File']
|
||||
localStatus, message = inscription.AddStagiairetoClass_mass_for_many_session(f, app.config['UPLOAD_FOLDER'], payload)
|
||||
localStatus, message = inscription.AddStagiairetoClass_mass_for_many_session(f, MYSY_GV.TEMPORARY_DIRECTORY_V2, payload)
|
||||
#status, retval = cm.add_class_mass(f, app.config['UPLOAD_FOLDER'], payload)
|
||||
|
||||
return jsonify(status=localStatus, message=message)
|
||||
|
@ -6513,6 +6513,8 @@ def Update_Apprenant():
|
|||
"""
|
||||
API pour supprimer un apprenant
|
||||
"""
|
||||
@app.route('/myclass/api/Delete_Given_Apprenant/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Delete_Given_Apprenant():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
|
@ -6571,6 +6573,21 @@ def Apprenant_Inscrire_Session():
|
|||
status, retval = apprenant_mgt.Apprenant_Inscrire_Session(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
"""
|
||||
API Pour recuperer la liste des inscription et preinscription d'un apprenant
|
||||
"""
|
||||
@app.route('/myclass/api/Get_Apprenant_List_Inscription/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Get_Apprenant_List_Inscription():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Get_Apprenant_List_Inscription payload = ",payload)
|
||||
status, retval = apprenant_mgt.Get_Apprenant_List_Inscription(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
|
||||
"""
|
||||
API pour enregister ou mettre à jour une image d'un apprenant
|
||||
"""
|
||||
|
@ -6579,9 +6596,18 @@ API pour enregister ou mettre à jour une image d'un apprenant
|
|||
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)
|
||||
print(" ### Add_Update_Apprenant_Image : payload = ",payload)
|
||||
|
||||
if request.method == 'POST':
|
||||
# Create variable for uploaded file
|
||||
if ('file_img' in request.files.keys()):
|
||||
file_img = request.files['file_img']
|
||||
else:
|
||||
file_img = None
|
||||
return False, "Aucun fichier image à enregistrer"
|
||||
|
||||
localStatus, message = apprenant_mgt.Add_Update_Apprenant_Image(file_img, MYSY_GV.upload_folder, payload)
|
||||
return jsonify(status=localStatus, message=message)
|
||||
|
||||
|
||||
"""
|
||||
|
@ -6597,7 +6623,38 @@ def Delete_Apprenant_Image():
|
|||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
"""
|
||||
API pour importer en masse des apprenants
|
||||
"""
|
||||
@app.route('/myclass/api/Add_Apprenant_mass/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Add_Apprenant_mass():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### AddStagiairetoClass_mass_for_many_session payload = ",payload)
|
||||
#print(request.files)
|
||||
|
||||
if request.method == 'POST':
|
||||
# Create variable for uploaded file
|
||||
f = request.files['File']
|
||||
localStatus, message = apprenant_mgt.Add_Apprenant_mass(f, MYSY_GV.TEMPORARY_DIRECTORY_V2, payload)
|
||||
|
||||
return jsonify(status=localStatus, message=message)
|
||||
|
||||
|
||||
|
||||
|
||||
"""
|
||||
API pour recuperer l'image d'un apprenant
|
||||
"""
|
||||
@app.route('/myclass/api/Get_Apprenant_Recorded_Image_from_front/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Get_Apprenant_Recorded_Image_from_front():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Get_Apprenant_Recorded_Image_from_front payload = ",payload)
|
||||
status, retval = apprenant_mgt.Get_Apprenant_Recorded_Image_from_front(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue