15/10/2023 - 22h40
parent
adfb4bde79
commit
5270f012dc
|
@ -3,13 +3,13 @@
|
|||
<component name="ChangeListManager">
|
||||
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="08/10/2023 - 22h40">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Activite.py" beforeDir="false" afterPath="$PROJECT_DIR$/Activite.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$/Template/MySy_annule_inscription_formation_tpl.html" beforeDir="false" afterPath="$PROJECT_DIR$/Template/MySy_annule_inscription_formation_tpl.html" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/email_inscription_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/email_inscription_mgt.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/lms_chamilo/mysy_lms.py" beforeDir="false" afterPath="$PROJECT_DIR$/lms_chamilo/mysy_lms.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Session_Formation.py" beforeDir="false" afterPath="$PROJECT_DIR$/Session_Formation.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$/ressources_humaines.py" beforeDir="false" afterPath="$PROJECT_DIR$/ressources_humaines.py" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
|
|
59
Activite.py
59
Activite.py
|
@ -45,7 +45,8 @@ def Add_activite(diction):
|
|||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', "description", "detail", "deadline", "type",
|
||||
"status", 'related_collection', 'related_collection_owner_email', ]
|
||||
"status", 'related_collection', 'related_collection_owner_email',
|
||||
'employee_assigned_to_id']
|
||||
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
|
@ -100,6 +101,26 @@ def Add_activite(diction):
|
|||
data = {}
|
||||
data['partner_recid'] = my_partner['recid']
|
||||
|
||||
employee_assigned_to_id = ""
|
||||
if ("employee_assigned_to_id" in diction.keys()):
|
||||
if diction['employee_assigned_to_id']:
|
||||
employee_assigned_to_id = diction['employee_assigned_to_id']
|
||||
|
||||
## Verifier que l'employé assigné existe et est valide
|
||||
is_employee_assigned_to_count = MYSY_GV.dbname['ressource_humaine'].count_documents(
|
||||
{'_id': ObjectId(str(employee_assigned_to_id)), 'valide': '1', 'locked': '0',
|
||||
'partner_recid': str(my_partner['recid'])})
|
||||
|
||||
if( is_employee_assigned_to_count != 1 ):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " - L'employé assigné est invalide")
|
||||
return False, str(inspect.stack()[0][3]) + " - L'employé assigné est invalide "
|
||||
|
||||
|
||||
data['employee_assigned_to_id'] = employee_assigned_to_id
|
||||
|
||||
|
||||
|
||||
description = ""
|
||||
if ("description" in diction.keys()):
|
||||
if diction['description']:
|
||||
|
@ -233,7 +254,7 @@ def Update_activite(diction):
|
|||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', "description", "detail", "deadline", "type",
|
||||
"status",'activite_recid' ]
|
||||
"status",'activite_recid' , 'employee_assigned_to_id']
|
||||
|
||||
|
||||
incom_keys = diction.keys()
|
||||
|
@ -347,7 +368,22 @@ def Update_activite(diction):
|
|||
|
||||
return False, " - La date deadline n'est pas au format jj/mm/aaaa "
|
||||
|
||||
employee_assigned_to_id = ""
|
||||
if ("employee_assigned_to_id" in diction.keys()):
|
||||
if diction['employee_assigned_to_id']:
|
||||
employee_assigned_to_id = diction['employee_assigned_to_id']
|
||||
|
||||
## Verifier que l'employé assigné existe et est valide
|
||||
is_employee_assigned_to_count = MYSY_GV.dbname['ressource_humaine'].count_documents(
|
||||
{'_id': ObjectId(str(employee_assigned_to_id)), 'valide': '1', 'locked': '0',
|
||||
'partner_recid': str(my_partner['recid'])})
|
||||
|
||||
if (is_employee_assigned_to_count != 1):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " - L'employé assigné est invalide")
|
||||
return False, str(inspect.stack()[0][3]) + " - L'employé assigné est invalide "
|
||||
|
||||
data_update['employee_assigned_to_id'] = diction['employee_assigned_to_id']
|
||||
|
||||
status = ""
|
||||
if ("status" in diction.keys()):
|
||||
|
@ -584,6 +620,25 @@ def Get_Given_Activite(diction):
|
|||
user = retval
|
||||
user['id'] = str(val_tmp)
|
||||
val_tmp = val_tmp + 1
|
||||
|
||||
# Si le champ 'employee_assigned_to_id' alors on va chercher le nom et prenom de l'employe au quel est assigné la tache (employe)
|
||||
if ('employee_assigned_to_id' in retval.keys()):
|
||||
Employee_data = MYSY_GV.dbname['ressource_humaine'].find_one(
|
||||
{'_id': ObjectId(str(retval['employee_assigned_to_id'])), 'valide': '1', 'locked': '0',
|
||||
'partner_recid': str(my_partner['recid'])})
|
||||
|
||||
employee_assigned_to_nom_prenom = ""
|
||||
if (Employee_data and 'nom' in Employee_data.keys()):
|
||||
employee_assigned_to_nom_prenom = str(Employee_data['nom'])
|
||||
|
||||
if (Employee_data and 'prenom' in Employee_data.keys()):
|
||||
employee_assigned_to_nom_prenom = str(employee_assigned_to_nom_prenom) + " " + str(
|
||||
Employee_data['prenom'])
|
||||
|
||||
user['employee_assigned_to_nom_prenom'] = str(employee_assigned_to_nom_prenom)
|
||||
|
||||
|
||||
|
||||
RetObject.append(mycommon.JSONEncoder().encode(user))
|
||||
|
||||
#print(" ### RetObject = ", RetObject)
|
||||
|
|
|
@ -4640,9 +4640,11 @@ def AcceptAttendeeInscription(diction):
|
|||
return False, " Impossible de valider l'inscription"
|
||||
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Cette fonction supprime un stagiaire.
|
||||
/!\ : seuls les preinscrit, ou les inscription annulés (donct status : 0 ou 1)
|
||||
/!\ : seuls les preinscrit, ou les inscription annulés (donc status : 0 ou -1)
|
||||
"""
|
||||
def DeleteAttendeeInscription(diction):
|
||||
try:
|
||||
|
@ -4755,7 +4757,83 @@ def DeleteAttendeeInscription(diction):
|
|||
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'insciption "
|
||||
return False, " Impossible de supprimer l'inscription "
|
||||
|
||||
|
||||
"""
|
||||
Fonction de suppression d'une liste de stagiaires en partant de l'_id, ceci si
|
||||
les conditions sont reunies.
|
||||
/!\ : seuls les preinscrit, ou les inscription annulés (donc status : 0 ou -1)
|
||||
"""
|
||||
def Delete_List_AttendeeInscription(diction):
|
||||
try:
|
||||
"""
|
||||
Verification de la liste des champs obligatoires
|
||||
"""
|
||||
field_list_obligatoire = ['token', 'list_inscription_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 ne sont pas correctes"
|
||||
|
||||
mytoken = ""
|
||||
if ("token" in diction.keys()):
|
||||
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"
|
||||
|
||||
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 le recid du partenaire")
|
||||
return False, "Impossible de récupérer le recid du partenaire"
|
||||
|
||||
list_inscription_id = []
|
||||
if ("list_inscription_id" in diction.keys()):
|
||||
if diction['list_inscription_id']:
|
||||
list_inscription_id = str(diction['list_inscription_id']).replace(",", ";").split(";")
|
||||
|
||||
|
||||
|
||||
data_mail = {}
|
||||
|
||||
|
||||
for inscription_id in list_inscription_id :
|
||||
# Verification que l'inscription existe et qu'elle est supprimable (donc status = 0 ou -1)
|
||||
ret_val2_count = MYSY_GV.dbname['inscription'].count_documents(
|
||||
{'_id': ObjectId(str(inscription_id)), },
|
||||
)
|
||||
|
||||
if( ret_val2_count != 1):
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - Impossible de supprimer l'inscription. Il y a plusieurs inscription pour ce mail et cette formation")
|
||||
return False, " Impossible de supprimer l'inscription (1)"
|
||||
|
||||
ret_val2 = MYSY_GV.dbname['inscription'].find_one(
|
||||
{'_id': ObjectId(str(inscription_id)),},
|
||||
)
|
||||
|
||||
if( "status" in ret_val2.keys()):
|
||||
if( str(ret_val2['status']) != "0" and str(ret_val2['status']) != "-1"):
|
||||
mycommon.myprint(str(inspect.stack()[0][
|
||||
3]) + " - Impossible de supprimer l'inscription de l'utilisateur "+str(ret_val2['email'])+" à la session "+str(ret_val2['session_id'])+". L'inscription doit être annulée ou à l'etat 'préinscrit' avant d'être supprimé")
|
||||
return False, " Impossible de supprimer l'inscription de l'utilisateur "+str(ret_val2['email'])+" à la session "+str(ret_val2['session_id'])+". L'inscription doit être annulée ou à l'etat 'préinscrit' avant d'être supprimé"
|
||||
|
||||
for inscription_id in list_inscription_id:
|
||||
detlete_retval = MYSY_GV.dbname['inscription'].delete_one(
|
||||
{'_id': ObjectId(str(inscription_id)),},
|
||||
)
|
||||
|
||||
return True, "La liste des inscriptions 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 la liste des inscriptions "
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
3364
Log/log_file.log
3364
Log/log_file.log
File diff suppressed because it is too large
Load Diff
|
@ -2586,3 +2586,96 @@ def Delete_SessionFormation(diction):
|
|||
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 supprimer la session de formation"
|
||||
|
||||
|
||||
"""
|
||||
Cette fonction prends une liste '_id' de session et effectue la suppresion
|
||||
si les conditions sont remplie.
|
||||
|
||||
list_session_id = ['id1', 'id2', 'id3,]
|
||||
"""
|
||||
def Delete_List_SessionFormation(diction):
|
||||
try:
|
||||
|
||||
field_list = ['token', 'list_session_id', ]
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
if val not in field_list:
|
||||
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"
|
||||
|
||||
"""
|
||||
Verification de la liste des champs obligatoires
|
||||
"""
|
||||
field_list_obligatoire = ['token', 'list_session_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 la liste des stagiaires, 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']
|
||||
|
||||
# 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"
|
||||
|
||||
partner_recid = mycommon.get_parnter_recid_from_token(mytoken)
|
||||
if (partner_recid is False):
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - Les informations d'identification sont incorrectes ")
|
||||
return False, "Impossible de récupérer la liste des stagiaires, Les informations d'identification sont incorrectes "
|
||||
|
||||
|
||||
list_session_id = []
|
||||
if ("list_session_id" in diction.keys()):
|
||||
if diction['list_session_id']:
|
||||
list_session_id = str(diction['list_session_id']).replace(",", ";").split(";")
|
||||
|
||||
|
||||
|
||||
# Verifier qu'il n'y a pas d'incription valide
|
||||
for session_id in list_session_id :
|
||||
inscription_count_qry = {'session_id':str(session_id), 'status':{'$in':['0', '1', '2']} , 'partner_owner_recid':str(partner_recid)}
|
||||
#print(" #### inscription_count_qry aa =", inscription_count_qry)
|
||||
inscription_count = MYSY_GV.dbname['inscription'].count_documents(inscription_count_qry)
|
||||
if( inscription_count > 0 ):
|
||||
session_formation_data = MYSY_GV.dbname['session_formation'].find_one({'_id':ObjectId(str(session_id)), 'partner_owner_recid':str(partner_recid)})
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - Impossible de supprimer la session "+str(session_formation_data['code_session'])+". Vous avez "+str(inscription_count)+" inscriptions associées.Suppression en masse annulée ")
|
||||
return False, "Impossible de supprimer la session "+str(session_formation_data['code_session'])+". Vous avez "+str(inscription_count)+" inscriptions associées. Suppression en masse annulée"
|
||||
|
||||
# Suppression des insciption eventuellement annulées
|
||||
MYSY_GV.dbname['inscription'].delete_many({'session_id':{'$in':list_session_id}})
|
||||
|
||||
# Suppression des affectation de ressources associées
|
||||
delete_affectation_qry = {'related_target_collection':'session_formation', 'related_target_collection_id':{'$in':list_session_id},
|
||||
'partner_owner_recid': str(partner_recid)
|
||||
}
|
||||
|
||||
# Pour les Ressource Humaine
|
||||
MYSY_GV.dbname['ressource_humaine_affectation'].delete_many(delete_affectation_qry)
|
||||
|
||||
# Pour le materiel
|
||||
MYSY_GV.dbname['ressource_materielle_affectation'].delete_many(delete_affectation_qry)
|
||||
|
||||
|
||||
# Suppression des sessions
|
||||
for session_id in list_session_id:
|
||||
deleted_session_qry = {'_id':ObjectId(str(session_id)), 'partner_owner_recid':str(partner_recid)}
|
||||
deleted_data = MYSY_GV.dbname['session_formation'].delete_many(deleted_session_qry)
|
||||
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + str(deleted_data.deleted_count)+" Document supprimé. La session_id " + str(
|
||||
session_id) + " a été correctement supprimée ")
|
||||
|
||||
return True, "Les sessions ont correctement supprimées"
|
||||
|
||||
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 supprimer la liste des sessions de formation"
|
||||
|
|
202
class_mgt.py
202
class_mgt.py
|
@ -2249,6 +2249,34 @@ def get_partner_class(diction):
|
|||
filt_external_code, filt_title, filt_internal_url]},
|
||||
):
|
||||
#mycommon.myprint(str(retVal))
|
||||
if ("title" not in retVal.keys()):
|
||||
retVal['title'] = ""
|
||||
|
||||
|
||||
if ("domain" not in retVal.keys()):
|
||||
retVal['domain'] = ""
|
||||
|
||||
|
||||
if ("metier" not in retVal.keys()):
|
||||
retVal['metier'] = ""
|
||||
|
||||
|
||||
if ("price" not in retVal.keys()):
|
||||
retVal['price'] = "0"
|
||||
|
||||
|
||||
if ("description" not in retVal.keys()):
|
||||
retVal['description'] = ""
|
||||
|
||||
|
||||
if ("published" not in retVal.keys()):
|
||||
retVal['published'] = "0"
|
||||
|
||||
|
||||
if ("lms_class_code" not in retVal.keys()):
|
||||
retVal['lms_class_code'] = "0"
|
||||
|
||||
|
||||
user = retVal
|
||||
user['id'] = str(val_tmp)
|
||||
|
||||
|
@ -2266,10 +2294,13 @@ def get_partner_class(diction):
|
|||
i = i+1
|
||||
|
||||
user['zone_diffusion_str'] = str(tmp_zone_diffusion[:-1])
|
||||
|
||||
|
||||
|
||||
RetObject.append(JSONEncoder().encode(user))
|
||||
val_tmp = val_tmp + 1
|
||||
|
||||
#print(str(RetObject))
|
||||
print(str(RetObject))
|
||||
return True, RetObject
|
||||
|
||||
|
||||
|
@ -2407,6 +2438,37 @@ def find_partner_class_like(diction):
|
|||
):
|
||||
# mycommon.myprint(str(retVal))
|
||||
user = retVal
|
||||
if ("title" not in retVal.keys()):
|
||||
retVal['title'] = ""
|
||||
|
||||
|
||||
if ("domain" not in retVal.keys()):
|
||||
retVal['domain'] = ""
|
||||
|
||||
|
||||
if ("metier" not in retVal.keys()):
|
||||
retVal['metier'] = ""
|
||||
|
||||
|
||||
if ("price" not in retVal.keys()):
|
||||
retVal['price'] = "0"
|
||||
|
||||
|
||||
if ("description" not in retVal.keys()):
|
||||
retVal['description'] = ""
|
||||
|
||||
|
||||
if ("published" not in retVal.keys()):
|
||||
retVal['published'] = "0"
|
||||
|
||||
|
||||
if ("lms_class_code" not in retVal.keys()):
|
||||
retVal['lms_class_code'] = "0"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
user['id'] = str(val_tmp)
|
||||
|
||||
'''
|
||||
|
@ -3176,10 +3238,43 @@ def Controle_add_class_mass(saved_file=None, Folder=None, diction=None):
|
|||
mydata['external_code'] = str(df['external_code'].values[n]).strip()
|
||||
mydata['title'] = str(df['titre'].values[n]).strip()
|
||||
mydata['domaine'] = str(df['domaine'].values[n]).strip()
|
||||
|
||||
# Verifier que l'external code et le titre on bien des valeurs
|
||||
if(len(str(mydata['external_code']).strip()) < 2):
|
||||
mycommon.myprint(str(
|
||||
inspect.stack()[0][3]) + " - Le code externe '" + str(
|
||||
mydata['external_code']) + "' pour la formation à la ligne " + str(
|
||||
n + 2) + " doit avoir plus de 2 caractères.")
|
||||
return False, " - Le code externe '" + str(
|
||||
mydata['external_code']) + "' pour la formation à la ligne " + str(
|
||||
n + 2) + " doit avoir plus de 2 caractères."
|
||||
|
||||
# Verifier que le titre a plus 5 caractères
|
||||
if (len(str(mydata['title']).strip()) < 5):
|
||||
mycommon.myprint(str(
|
||||
inspect.stack()[0][3]) + " - Le titre '" + str(
|
||||
mydata['title']) + "' pour la formation à la ligne " + str(
|
||||
n + 2) + " doit avoir plus de 5 caractères.")
|
||||
return False, " - Le titre '" + str(
|
||||
mydata['title']) + "' pour la formation à la ligne " + str(
|
||||
n + 2) + " doit avoir plus de 5 caractères."
|
||||
|
||||
|
||||
tmp_desc = str(df['description'].values[n]).strip()
|
||||
tmp_desc = mycommon.format_MySy_Text_Tag(tmp_desc)
|
||||
mydata['description'] = tmp_desc
|
||||
|
||||
# Verifier que la description a plus 5 caractères
|
||||
if (len(str(mydata['description']).strip()) < 5):
|
||||
mycommon.myprint(str(
|
||||
inspect.stack()[0][3]) + " - La description '" + str(
|
||||
mydata['description']) + "' pour la formation à la ligne " + str(
|
||||
n + 2) + " doit avoir plus de 5 caractères.")
|
||||
return False, " -La description '" + str(
|
||||
mydata['description']) + "' pour la formation à la ligne " + str(
|
||||
n + 2) + " doit avoir plus de 5 caractères."
|
||||
|
||||
|
||||
"""
|
||||
Verifier que le domaine est bien dans la liste acceptée
|
||||
"""
|
||||
|
@ -3296,6 +3391,16 @@ def Controle_add_class_mass(saved_file=None, Folder=None, diction=None):
|
|||
|
||||
mydata['objectif'] = objectif
|
||||
|
||||
# Verifier que l'objectif a plus 5 caractères
|
||||
if (len(str(mydata['objectif']).strip()) < 5):
|
||||
mycommon.myprint(str(
|
||||
inspect.stack()[0][3]) + " - L'objectif '" + str(
|
||||
mydata['objectif']) + "' pour la formation à la ligne " + str(
|
||||
n + 2) + " doit avoir plus de 5 caractères.")
|
||||
return False, " - L'objectif '" + str(
|
||||
mydata['objectif']) + "' pour la formation à la ligne " + str(
|
||||
n + 2) + " doit avoir plus de 5 caractères."
|
||||
|
||||
note = ""
|
||||
if ("note" in df.keys()):
|
||||
if (str(df['note'].values[n])):
|
||||
|
@ -3911,6 +4016,101 @@ def delete_Class(diction):
|
|||
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - Line : " + str(exc_tb.tb_lineno))
|
||||
return False, " Impossible de supprimer la formation "
|
||||
|
||||
"""
|
||||
Fonction de suppression des formations en masse, si les conditions sont reunies
|
||||
"""
|
||||
def delete_list_Class(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', 'list_class_id', ]
|
||||
|
||||
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
if val not in field_list:
|
||||
mycommon.myprint(str(
|
||||
inspect.stack()[0][3]) + " Le champ '" + val + "' n'existe pas")
|
||||
return False, " Les informations fournies sont incorrectes",
|
||||
|
||||
"""
|
||||
Verification des champs obligatoires
|
||||
"""
|
||||
field_list_obligatoire = ['token', 'list_class_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']
|
||||
|
||||
# Verifier la validité du token
|
||||
local_status, my_partner = mycommon.Check_Connexion_And_Return_Partner_Data(diction)
|
||||
if (local_status is not True):
|
||||
return local_status, my_partner
|
||||
|
||||
list_class_id = []
|
||||
if ("list_class_id" in diction.keys()):
|
||||
if diction['list_class_id']:
|
||||
list_class_id = str(diction['list_class_id']).replace(",", ";").split(";")
|
||||
|
||||
|
||||
for class_id in list_class_id :
|
||||
# Receprer la liste des 'internal_url_"
|
||||
Myclass_Data = MYSY_GV.dbname['myclass'].find_one({'_id':ObjectId(str(class_id)),
|
||||
'partner_owner_recid':str(my_partner['recid'])})
|
||||
|
||||
if( Myclass_Data is None):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " - La formation avec l'identifiant "+str(class_id)+ " est invalide ")
|
||||
return False, "La formation avec l'identifiant "+str(class_id)+ "est invalide ",
|
||||
|
||||
# Verifier qu'il n'y a pas de session associée à cette formation
|
||||
existe_Session_count = MYSY_GV.dbname['session_formation'].count_documents({'class_internal_url':str(Myclass_Data['internal_url']),
|
||||
'partner_owner_recid':str(my_partner['recid']),
|
||||
'valide':'1'})
|
||||
|
||||
|
||||
if( existe_Session_count > 0 ):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " - La formation avec le code externe "+str(Myclass_Data['external_code'])+" a "+str(existe_Session_count)+" session(s) valide(s). Suppression impossible")
|
||||
return False, "La formation avec le code externe "+str(Myclass_Data['external_code'])+" a "+str(existe_Session_count)+" session(s) valide(s). Suppression impossible"
|
||||
|
||||
|
||||
|
||||
for class_id in list_class_id :
|
||||
# Receprer la liste des 'internal_url_"
|
||||
Myclass_Data = MYSY_GV.dbname['myclass'].find_one({'_id':ObjectId(str(class_id)),
|
||||
'partner_owner_recid':str(my_partner['recid'])})
|
||||
|
||||
# Une formation va etre supprimée, maintenant il faut supprimer les champs associés dans la collection "elaindex"
|
||||
qry_elaindex_to_delete = {"partner_owner_recid": str(my_partner['recid']),
|
||||
"id_formation": str(Myclass_Data['external_code'])}
|
||||
MYSY_GV.dbname['elaindex'].delete_many(qry_elaindex_to_delete)
|
||||
|
||||
delete_doc = MYSY_GV.dbname['myclass'].delete_many({'_id':ObjectId(str(class_id)),
|
||||
'partner_owner_recid':str(my_partner['recid'])})
|
||||
|
||||
|
||||
return True, " La liste des formations a été supprimée"
|
||||
|
||||
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 la liste des formations "
|
||||
|
||||
|
||||
"""
|
||||
Cette fonction supprime definitivement une formation, en utilisant l'internal_url
|
||||
|
|
41
main.py
41
main.py
|
@ -2033,6 +2033,18 @@ def Delete_SessionFormation():
|
|||
return jsonify(status=localStatus, message=message )
|
||||
|
||||
|
||||
"""
|
||||
Suppression d'une liste de sessions de formation
|
||||
"""
|
||||
@app.route('/myclass/api/Delete_List_SessionFormation/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Delete_List_SessionFormation():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Delete_List_SessionFormation : payload = ",str(payload))
|
||||
localStatus, message= SF.Delete_List_SessionFormation(payload)
|
||||
return jsonify(status=localStatus, message=message )
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -2148,6 +2160,21 @@ def delete_Class():
|
|||
localStatus, message= cm.delete_Class(payload)
|
||||
return jsonify(status=localStatus, message=message )
|
||||
|
||||
|
||||
"""
|
||||
API de suppression d'une liste de formation en utilisant l'_id
|
||||
|
||||
"""
|
||||
@app.route('/myclass/api/delete_list_Class/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def delete_list_Class():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### delete_list_Class : payload = ",str(payload))
|
||||
localStatus, message= cm.delete_list_Class(payload)
|
||||
return jsonify(status=localStatus, message=message )
|
||||
|
||||
|
||||
"""
|
||||
Cette API permet de supprimer une formation si elle n'a aucune session
|
||||
de formation valide. la fonction utilise l'internal_url
|
||||
|
@ -3083,6 +3110,20 @@ def DeleteAttendeeInscription():
|
|||
localStatus, message= inscription.DeleteAttendeeInscription(payload)
|
||||
return jsonify(status=localStatus, message=message )
|
||||
|
||||
|
||||
"""
|
||||
API de suppression en masse des stagiaires
|
||||
"""
|
||||
@app.route('/myclass/api/Delete_List_AttendeeInscription/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Delete_List_AttendeeInscription():
|
||||
# On CancelAttendeeInscription le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Delete_List_AttendeeInscription : payload = ",payload)
|
||||
localStatus, message= inscription.Delete_List_AttendeeInscription(payload)
|
||||
return jsonify(status=localStatus, message=message )
|
||||
|
||||
|
||||
"""
|
||||
API de d'annulation d'une inscription avec mise à jour du motif
|
||||
"""
|
||||
|
|
|
@ -1243,7 +1243,7 @@ def Get_List_Ressource_Humaine_no_filter(diction):
|
|||
|
||||
data_cle['locked'] = "0"
|
||||
data_cle['valide'] = "1"
|
||||
data_cle['is_partner_admin_account'] = "0"
|
||||
|
||||
|
||||
find_qry = {'partner_recid': str(my_partner['recid']), 'valide':'1', 'locked':'0' }
|
||||
|
||||
|
@ -1256,7 +1256,9 @@ def Get_List_Ressource_Humaine_no_filter(diction):
|
|||
user = retval
|
||||
user['id'] = str(val_tmp)
|
||||
val_tmp = val_tmp + 1
|
||||
RetObject.append(mycommon.JSONEncoder().encode(user))
|
||||
is_admin_account_count = MYSY_GV.dbname['partnair_account'].count_documents({'ressource_humaine_id':str(retval['_id']), 'is_partner_admin_account':'1'}) # exclure les comptes admin
|
||||
if( is_admin_account_count <= 0 ):
|
||||
RetObject.append(mycommon.JSONEncoder().encode(user))
|
||||
|
||||
return True, RetObject
|
||||
|
||||
|
|
Loading…
Reference in New Issue