02/05/2024 - 17h
parent
a1056e8fc4
commit
e07ffc3551
|
@ -1,12 +1,19 @@
|
|||
<?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="27/04/2024 - 22h">
|
||||
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="28/04/2024 - 22h">
|
||||
<change afterPath="$PROJECT_DIR$/unite_enseignement_mgt.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Dashbord_queries/common_tdb_qries.py" beforeDir="false" afterPath="$PROJECT_DIR$/Dashbord_queries/common_tdb_qries.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Dashbord_queries/factures_tbd_qries.py" beforeDir="false" afterPath="$PROJECT_DIR$/Dashbord_queries/factures_tbd_qries.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$/class_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/class_mgt.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/email_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/email_mgt.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/emargement.py" beforeDir="false" afterPath="$PROJECT_DIR$/emargement.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/module_editique.py" beforeDir="false" afterPath="$PROJECT_DIR$/module_editique.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/partners.py" beforeDir="false" afterPath="$PROJECT_DIR$/partners.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/tools_cherif/tools_cherif.py" beforeDir="false" afterPath="$PROJECT_DIR$/tools_cherif/tools_cherif.py" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
|
@ -76,13 +83,6 @@
|
|||
<option name="presentableId" value="Default" />
|
||||
<updated>1680804787304</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00231" summary="29/02/2024 - 21h30">
|
||||
<created>1709239297473</created>
|
||||
<option name="number" value="00231" />
|
||||
<option name="presentableId" value="LOCAL-00231" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1709239297474</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00232" summary="01/03/2024 - 23h30">
|
||||
<created>1709333684065</created>
|
||||
<option name="number" value="00232" />
|
||||
|
@ -419,7 +419,14 @@
|
|||
<option name="project" value="LOCAL" />
|
||||
<updated>1714248179439</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="280" />
|
||||
<task id="LOCAL-00280" summary="28/04/2024 - 22h">
|
||||
<created>1714332210979</created>
|
||||
<option name="number" value="00280" />
|
||||
<option name="presentableId" value="LOCAL-00280" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1714332210979</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="281" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="Vcs.Log.Tabs.Properties">
|
||||
|
@ -461,7 +468,6 @@
|
|||
</option>
|
||||
</component>
|
||||
<component name="VcsManagerConfiguration">
|
||||
<MESSAGE value="01/04/24 - 23h50" />
|
||||
<MESSAGE value="2/04/24 - 20h30" />
|
||||
<MESSAGE value="03/04/24 - 21h30" />
|
||||
<MESSAGE value="04/04/24 - 19h30" />
|
||||
|
@ -486,6 +492,7 @@
|
|||
<MESSAGE value="23/04/2024 - 14h06" />
|
||||
<MESSAGE value="25/04/2024 - 19h" />
|
||||
<MESSAGE value="27/04/2024 - 22h" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="27/04/2024 - 22h" />
|
||||
<MESSAGE value="28/04/2024 - 22h" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="28/04/2024 - 22h" />
|
||||
</component>
|
||||
</project>
|
10705
Log/log_file.log
10705
Log/log_file.log
File diff suppressed because one or more lines are too long
|
@ -629,7 +629,6 @@ def GetSessionFormation(diction):
|
|||
|
||||
#print(" ##### myquery GetSessionFormation = "+str(myquery))
|
||||
RetObject = []
|
||||
|
||||
nb_val = 0
|
||||
for retval in coll_session.aggregate(myquery):
|
||||
#print(" ##### retval = " + str(retval))
|
||||
|
@ -5523,8 +5522,14 @@ def Create_Convention_By_Stagiaire_PDF(diction):
|
|||
25/01/2024 : pour loger une action dans la collection ==> courrier_template_tracking_history
|
||||
"""
|
||||
|
||||
local_status, local_retval = module_editique.Editic_Log_History_Action(my_partner, template_courrier_data, str(diction['session_id']),
|
||||
'inscription', statgiaire_data['_id'])
|
||||
"""local_status, local_retval = module_editique.Editic_Log_History_Action(my_partner, template_courrier_data, str(diction['session_id']),
|
||||
'inscription', str(diction['inscription_id']) )"""
|
||||
|
||||
local_status, local_retval = module_editique.Editic_Log_History_Action_From_courrier_template_type_document_ref_interne(
|
||||
my_partner, "CONVENTION_STAGIAIRE_INDIVIDUELLE", str(diction['session_id']), 'inscription',
|
||||
str(diction['inscription_id']),
|
||||
str(str(template_courrier_data['_id'])))
|
||||
|
||||
return True, outputFilename
|
||||
|
||||
except Exception as e:
|
||||
|
@ -5816,9 +5821,16 @@ def Create_Convocation_By_Stagiaire_PDF(diction):
|
|||
"""
|
||||
25/01/2024 : pour loger une action dans la collection ==> courrier_template_tracking_history
|
||||
"""
|
||||
print(" str(diction['inscription_id']) == ", str(diction['inscription_id']))
|
||||
""" local_status, local_retval = module_editique.Editic_Log_History_Action(my_partner, template_courrier_data,
|
||||
str(diction['session_id']), 'inscription', str(diction['inscription_id']))
|
||||
"""
|
||||
|
||||
local_status, local_retval = module_editique.Editic_Log_History_Action_From_courrier_template_type_document_ref_interne(
|
||||
my_partner, "CONVOCATION_STAGIAIRE", str(diction['session_id']), 'inscription',
|
||||
str(diction['inscription_id']),
|
||||
str(str(template_courrier_data['_id'])))
|
||||
|
||||
local_status, local_retval = module_editique.Editic_Log_History_Action(my_partner, template_courrier_data,
|
||||
str(diction['session_id']), 'inscription', statgiaire_data['_id'])
|
||||
|
||||
|
||||
return True, outputFilename
|
||||
|
@ -5938,8 +5950,13 @@ def Prepare_and_Send_Convocation_From_Session_By_Email(tab_files, Folder, dictio
|
|||
"""
|
||||
25/01/2024 : pour loger une action dans la collection ==> courrier_template_tracking_history
|
||||
"""
|
||||
local_status, local_retval = module_editique.Editic_Log_History_Action(my_partner, courrier_template_data,
|
||||
str(diction['session_id']), "inscription", str(single_inscrit['_id']))
|
||||
"""local_status, local_retval = module_editique.Editic_Log_History_Action(my_partner, courrier_template_data,
|
||||
str(diction['session_id']), "inscription", str(single_inscrit['_id']))"""
|
||||
|
||||
local_status, local_retval = module_editique.Editic_Log_History_Action_From_courrier_template_type_document_ref_interne(
|
||||
my_partner, "CONVOCATION_STAGIAIRE", str(diction['session_id']), 'inscription',
|
||||
str(single_inscrit['_id']),
|
||||
str(str(courrier_template_data['_id'])))
|
||||
|
||||
|
||||
return True, " Les convocations ont été correctement envoyées par emails"
|
||||
|
@ -9071,7 +9088,7 @@ def Audit_Session_Action_Inscrit(diction):
|
|||
if( "email" in email):
|
||||
tab_email_inscrti_valide.append(email['email'])
|
||||
|
||||
print(" Liste des email inscrit en tout = ", tab_email_inscrti_valide)
|
||||
#print(" Liste des email inscrit en tout = ", tab_email_inscrti_valide)
|
||||
|
||||
"""
|
||||
Recuperer la liste des documents tracké pour cette session
|
||||
|
@ -9080,6 +9097,7 @@ def Audit_Session_Action_Inscrit(diction):
|
|||
diction_list_tracked_doc['token'] = str(diction['token'])
|
||||
diction_list_tracked_doc['related_collection'] = "session_formation"
|
||||
diction_list_tracked_doc['related_collection_recid'] = str(diction['session_id'])
|
||||
diction_list_tracked_doc['session_id'] = str(diction['session_id'])
|
||||
|
||||
local_status, local_retval = module_editique.Get_Editable_Document_By_Partner_By_Collection(diction_list_tracked_doc)
|
||||
if( local_status is False ):
|
||||
|
@ -9090,11 +9108,9 @@ def Audit_Session_Action_Inscrit(diction):
|
|||
|
||||
local_id = 0
|
||||
for tmp_val in local_retval :
|
||||
#print( tmp_val)
|
||||
|
||||
document_type = ast.literal_eval(tmp_val)
|
||||
|
||||
|
||||
|
||||
tab_inscrit_ok = []
|
||||
node = {}
|
||||
node['id'] = local_id
|
||||
|
@ -9108,6 +9124,7 @@ def Audit_Session_Action_Inscrit(diction):
|
|||
email_exist = 0
|
||||
sub_node = {}
|
||||
|
||||
|
||||
for val in document_type['list_document_history_event'] :
|
||||
if( val['local_target_collection_name'] == local_email ):
|
||||
|
||||
|
|
|
@ -813,7 +813,7 @@ def Get_Apprenant_List_Partner_with_filter(diction):
|
|||
query = [{'$match': {'$and': [filt_email, filt_nom, filt_prenom, {'partner_owner_recid': str(my_partner['recid'])}]}},
|
||||
{'$sort': {'_id': -1}},
|
||||
]
|
||||
print("#### Get_Apprenant_List_Partner_with_filter laa 01 : query = ", query)
|
||||
#print("#### Get_Apprenant_List_Partner_with_filter laa 01 : query = ", query)
|
||||
RetObject = []
|
||||
cpt = 1
|
||||
for retVal in MYSY_GV.dbname['apprenant'].aggregate(query):
|
||||
|
|
338
class_mgt.py
338
class_mgt.py
|
@ -57,7 +57,7 @@ def add_class(diction):
|
|||
'internal_url', 'zone_diffusion', 'metier', 'published', 'img_url', 'objectif',
|
||||
'programme', 'prerequis', 'note', 'cpf', 'certif', 'class_inscription_url', 'pourqui',
|
||||
'support', 'img_banner_detail_class', 'source', 'lms_class_code', 'formateur_id',
|
||||
'class_level', 'methode_pedagogique', 'condition_handicape', 'suivi_eval']
|
||||
'class_level', 'methode_pedagogique', 'condition_handicape', 'suivi_eval', 'class_id']
|
||||
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
|
@ -640,7 +640,7 @@ def add_class(diction):
|
|||
|
||||
'''
|
||||
cette fontion met à jour une formation
|
||||
la clé est : l'external code.
|
||||
la clé est : class_id et ou class_inscription_url
|
||||
|
||||
seules les formations "valide" et non "locked" sont modifiable
|
||||
'''
|
||||
|
@ -659,7 +659,7 @@ def update_class(diction):
|
|||
'published', 'img_url', 'objectif', 'programme', 'prerequis', 'note',
|
||||
'cpf', 'certif', 'class_inscription_url','pourqui', 'support', 'img_banner_detail_class',
|
||||
'duration_unit', 'source', 'lms_class_code', 'formateur_id', 'class_level','methode_pedagogique',
|
||||
'condition_handicape', 'suivi_eval']
|
||||
'condition_handicape', 'suivi_eval', 'class_id']
|
||||
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
|
@ -759,6 +759,7 @@ def update_class(diction):
|
|||
|
||||
if ("external_code" in diction.keys()):
|
||||
my_external_code = diction['external_code']
|
||||
mydata['external_code'] = diction['external_code']
|
||||
|
||||
if ("title" in diction.keys()):
|
||||
mydata['title'] = diction['title']
|
||||
|
@ -1030,6 +1031,8 @@ def update_class(diction):
|
|||
mydata['indexed_title'] = '0'
|
||||
mydata['indexed_desc'] = '0'
|
||||
mydata['indexed_obj'] = '0'
|
||||
mydata['date_update'] = str(datetime.now())
|
||||
mydata['update_by'] = str(my_partner['_id'])
|
||||
|
||||
""" Gestion des ajout pr les compte utilisateur de type demo """
|
||||
|
||||
|
@ -1071,8 +1074,10 @@ def update_class(diction):
|
|||
#print(" ### mydata = ", mydata)
|
||||
|
||||
# seules les formations avec locked = 0 et valide=1 sont modifiables
|
||||
ret_val = coll_name.find_one_and_update({'internal_url': str(my_internal_url), 'partner_owner_recid':partner_recid, 'locked': '0', 'valide': '1'},
|
||||
ret_val = coll_name.find_one_and_update({'internal_url': str(my_internal_url), 'partner_owner_recid':partner_recid, 'locked': '0', 'valide': '1',
|
||||
'_id':ObjectId(str(diction['class_id']))},
|
||||
{"$set": mydata},
|
||||
upsert=False,
|
||||
return_document=ReturnDocument.AFTER
|
||||
)
|
||||
|
||||
|
@ -5205,3 +5210,328 @@ def Export_Class_To_Excel_From_from_List_Id(diction):
|
|||
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - Line : " + str(exc_tb.tb_lineno))
|
||||
return False, " Impossible d'exporter les formations "
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Cette fontcion permet d'ajouter ou mettre à jour une unité d'enseignement (UE) à une formation.
|
||||
|
||||
A l'ajout d'une UE, les info necessaires sont :
|
||||
- Le crédit associé (numérique)
|
||||
- pres_dist_hyp : Présentiel/ distantiel/ hybride,
|
||||
- Est_note (oui / non) pour savoir cette unité doit être notée
|
||||
|
||||
/!\ :
|
||||
on gere en mode nesred field, c'est a dire que les compétence dont directement ajouté à la collection myclass comme suit:
|
||||
|
||||
myclass:
|
||||
{
|
||||
'_id':xxxxxx
|
||||
'title':yyyyy
|
||||
...........
|
||||
...........
|
||||
'list_unite_enseignement':[
|
||||
{ue1}
|
||||
{ue2}
|
||||
{ue3}
|
||||
....
|
||||
}
|
||||
}
|
||||
|
||||
"""
|
||||
def Add_Update_UE_To_Class(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', 'class_id', 'ue_id', 'credit', 'pres_dist_hyp', 'is_noted', ]
|
||||
|
||||
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', 'class_id', 'ue_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
|
||||
|
||||
mydata = {}
|
||||
|
||||
mydata = diction
|
||||
del mydata['token']
|
||||
|
||||
# Initialisation des champs non envoyés à vide
|
||||
for val in field_list:
|
||||
if val not in diction.keys():
|
||||
mydata[str(val)] = ""
|
||||
|
||||
|
||||
# Verifier que UE est valide
|
||||
is_ue_exist_count = MYSY_GV.dbname['unite_enseignement'].count_documents({'partner_owner_recid':my_partner['recid'],
|
||||
'valide':'1',
|
||||
'_id':ObjectId(str(diction['ue_id'])),
|
||||
'locked':'0'
|
||||
})
|
||||
if( is_ue_exist_count != 1 ):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " L'identifiant de l'UE est invalide ")
|
||||
return False, " L'identifiant de l'UE est invalide "
|
||||
|
||||
# Verifier que la formation est valide
|
||||
is_class_exist_count = MYSY_GV.dbname['myclass'].count_documents(
|
||||
{'partner_owner_recid': my_partner['recid'],
|
||||
'valide': '1',
|
||||
'locked': '0',
|
||||
'_id':ObjectId(str(diction['class_id']))})
|
||||
|
||||
if (is_class_exist_count != 1 ):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " L'identifiant de la formation est invalide ")
|
||||
return False, " L'identifiant de la formation est invalide "
|
||||
|
||||
|
||||
is_class_exist_data = MYSY_GV.dbname['myclass'].find_one(
|
||||
{'partner_owner_recid': my_partner['recid'],
|
||||
'valide': '1',
|
||||
'locked': '0',
|
||||
'_id': ObjectId(str(diction['class_id']))})
|
||||
|
||||
|
||||
local_status, local_retval = mycommon.IsFloat(str(diction['credit']))
|
||||
if( local_status is False ):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " La valeur 'crédit' est invalide ")
|
||||
return False, " La valeur 'crédit' est invalide "
|
||||
|
||||
|
||||
"""
|
||||
pres_dist_hyp prend les valeurs suivantes :
|
||||
- 0 : presntiel
|
||||
- 1 : distanciel
|
||||
- 2 : hybride
|
||||
"""
|
||||
|
||||
if( str(diction['pres_dist_hyp']) not in ['', '0', '1', '2']):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " La valeur 'type formation' est invalide ")
|
||||
return False, " La valeur 'type formation' est invalide "
|
||||
|
||||
if (str(diction['is_noted']) not in [ '0', '1']):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " La valeur 'est noté' est invalide ")
|
||||
return False, " La valeur 'est noté' est invalide "
|
||||
|
||||
|
||||
"""
|
||||
Verifier que le ue_id existe deja pour cette formation, au quel cas c'est un update qu'on fait
|
||||
si non c'est un create
|
||||
"""
|
||||
is_ue_id_existe_class = 0
|
||||
if( "list_unite_enseignement" in is_class_exist_data.keys()):
|
||||
is_ue_id_existe_class = MYSY_GV.dbname['myclass'].count_documents({'list_unite_enseignement._id':str(diction['ue_id'])})
|
||||
|
||||
|
||||
|
||||
if (is_ue_id_existe_class > 0):
|
||||
|
||||
# L'UE existe dans la formation, on autorise la mise à jour
|
||||
update = MYSY_GV.dbname['myclass'].update_one({'_id': ObjectId(str(diction['class_id'])),
|
||||
'partner_owner_recid': str(
|
||||
my_partner['recid']),
|
||||
'valide': '1',
|
||||
'locked': '0',
|
||||
'list_unite_enseignement._id': str(
|
||||
diction['ue_id'])},
|
||||
{'$set':
|
||||
{
|
||||
'list_unite_enseignement.$[xxx].credit': str(
|
||||
diction['credit']),
|
||||
'list_unite_enseignement.$[xxx].pres_dist_hyp': str(
|
||||
diction['pres_dist_hyp']),
|
||||
'list_unite_enseignement.$[xxx].is_noted': str(
|
||||
diction['is_noted']),
|
||||
'list_unite_enseignement.$[xxx].date_update': str(
|
||||
datetime.now()),
|
||||
'list_unite_enseignement.$[xxx].update_by': str(
|
||||
my_partner['_id']),
|
||||
}
|
||||
},
|
||||
upsert=False,
|
||||
array_filters=[
|
||||
{"xxx._id": str(diction['ue_id'])}
|
||||
]
|
||||
|
||||
)
|
||||
|
||||
return True, " La compétence a été mise à jour"
|
||||
|
||||
else:
|
||||
# l'UE n'existe pas pour cette formation, on fait une creation
|
||||
# Il s'agit de la creation d'une competence
|
||||
new_data = {}
|
||||
new_data['date_update'] = str(datetime.now())
|
||||
new_data['valide'] = "1"
|
||||
new_data['update_by'] = str(my_partner['_id'])
|
||||
new_data['locked'] = "0"
|
||||
|
||||
new_data['credit'] = str(diction['credit'])
|
||||
new_data['pres_dist_hyp'] = str(diction['pres_dist_hyp'])
|
||||
new_data['is_noted'] = str(diction['is_noted'])
|
||||
|
||||
new_data['_id'] = str(diction['ue_id'])
|
||||
|
||||
insert = MYSY_GV.dbname['myclass'].update_one({'_id': ObjectId(str(diction['class_id'])),
|
||||
'partner_owner_recid': str(
|
||||
my_partner['recid']),
|
||||
'valide': '1',
|
||||
'locked': '0',
|
||||
},
|
||||
|
||||
{
|
||||
'$push': {
|
||||
"list_unite_enseignement": {
|
||||
'$each': [new_data]
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
)
|
||||
|
||||
return True, " L'UE a été correctement ajoutée à la formation "
|
||||
|
||||
|
||||
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 d'ajouter L'UE à la formation "
|
||||
|
||||
|
||||
"""
|
||||
Cette fonction permet de supprimer une UE d'une formation.
|
||||
/!\ : Pour rappel, on est en mode nested json sur la collection myclass
|
||||
"""
|
||||
def Delete_UE_From_Class(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', 'class_id', 'ue_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', 'class_id', 'ue_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
|
||||
|
||||
mydata = {}
|
||||
|
||||
mydata = diction
|
||||
del mydata['token']
|
||||
|
||||
# Initialisation des champs non envoyés à vide
|
||||
for val in field_list:
|
||||
if val not in diction.keys():
|
||||
mydata[str(val)] = ""
|
||||
|
||||
|
||||
# Verifier que UE est valide
|
||||
is_ue_exist_count = MYSY_GV.dbname['unite_enseignement'].count_documents({'partner_owner_recid':my_partner['recid'],
|
||||
'valide':'1',
|
||||
'_id':ObjectId(str(diction['ue_id'])),
|
||||
'locked':'0'
|
||||
})
|
||||
if( is_ue_exist_count != 1 ):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " L'identifiant de l'UE est invalide ")
|
||||
return False, " L'identifiant de l'UE est invalide "
|
||||
|
||||
# Verifier que la formation est valide
|
||||
is_class_exist_count = MYSY_GV.dbname['myclass'].count_documents(
|
||||
{'partner_owner_recid': my_partner['recid'],
|
||||
'valide': '1',
|
||||
'locked': '0',
|
||||
'_id':ObjectId(str(diction['class_id']))})
|
||||
|
||||
if (is_class_exist_count != 1 ):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " L'identifiant de la formation est invalide ")
|
||||
return False, " L'identifiant de la formation est invalide "
|
||||
|
||||
|
||||
is_class_exist_data = MYSY_GV.dbname['myclass'].find_one(
|
||||
{'partner_owner_recid': my_partner['recid'],
|
||||
'valide': '1',
|
||||
'locked': '0',
|
||||
'_id': ObjectId(str(diction['class_id']))})
|
||||
|
||||
if ("list_unite_enseignement" in is_class_exist_data.keys()):
|
||||
delete = MYSY_GV.dbname['myclass'].update_one({'_id': ObjectId(str(diction['class_id'])),
|
||||
'partner_owner_recid': str(
|
||||
my_partner['recid']),
|
||||
'valide': '1',
|
||||
'locked': '0',
|
||||
'list_unite_enseignement._id': str(diction['ue_id'])},
|
||||
|
||||
{'$pull': {'list_unite_enseignement': {
|
||||
"_id": str(diction['ue_id'])}}}
|
||||
)
|
||||
|
||||
|
||||
|
||||
return True, " L'UE a été correctement suppimée de la formation "
|
||||
|
||||
|
||||
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 L'UE de la formation "
|
|
@ -1920,8 +1920,13 @@ def SendEmargementMail( diction):
|
|||
25/01/2024 : Apres l'envoi de la demande
|
||||
d'emargement, on log une action dans la collection ==> courrier_template_tracking_history
|
||||
"""
|
||||
|
||||
local_inscription_id = ""
|
||||
if( "inscription_id" in val_emarge.keys() ):
|
||||
local_inscription_id = str(val_emarge['inscription_id'])
|
||||
|
||||
local_status, local_retval = module_editique.Editic_Log_History_Action_From_courrier_template_type_document_ref_interne(
|
||||
my_partner, "EMARGEMENT_FORMATION", str(val_emarge['session_id']), "emargement", str(val_emarge['_id']), "" )
|
||||
my_partner, "EMARGEMENT_FORMATION", str(val_emarge['session_id']), "inscription", local_inscription_id, "" )
|
||||
|
||||
|
||||
"""
|
||||
|
|
|
@ -369,6 +369,7 @@ def CreateTableauEmargement_From_Sequence(diction):
|
|||
query_key['sequence_end'] = str(session_sequence['sequence_end'])
|
||||
|
||||
new_my_local_data = {}
|
||||
new_my_local_data['inscription_id'] = str(tmp_val['_id'])
|
||||
new_my_local_data['email'] = tmp_val['email']
|
||||
new_my_local_data['nom'] = tmp_val['nom']
|
||||
new_my_local_data['prenom'] = tmp_val['prenom']
|
||||
|
|
157
main.py
157
main.py
|
@ -81,6 +81,7 @@ import E_Sign_Document as E_Sign_Document
|
|||
import competence as competence
|
||||
import formulaire_mgt as formulaire_mgt
|
||||
import survey_mgt as survey_mgt
|
||||
import unite_enseignement_mgt as unite_enseignement_mgt
|
||||
|
||||
|
||||
app = Flask(__name__)
|
||||
|
@ -2988,16 +2989,12 @@ def mysylmsdb():
|
|||
"""
|
||||
API de test de fonctionnement du webservice
|
||||
"""
|
||||
@app.route('/myclass/api/test_web_service/<token>/<invoiceid>', methods=['POST','GET'])
|
||||
@app.route('/myclass/api/test_web_service/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def test_web_service(invoiceid, token):
|
||||
def test_web_service():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
payload = {}
|
||||
payload['token'] = str(token)
|
||||
payload['invoiceid'] = str(invoiceid)
|
||||
|
||||
print(" ### payload facture = ", str(invoiceid), " token = ",str(token))
|
||||
payload = mycommon.strip_dictionary(request.form.to_dict())
|
||||
print(" ### test_web_service : payload = ", payload)
|
||||
localStatus, message= tools_cherif.test_web_service(payload)
|
||||
return jsonify(status=localStatus, message=message )
|
||||
|
||||
|
@ -7931,6 +7928,33 @@ def Account_Migration_to_delete():
|
|||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
"""
|
||||
EDITIQUE : API qui permet de retourné le statuts des actions (documents),
|
||||
- non commencés
|
||||
- partiellement faits
|
||||
- terminés
|
||||
"""
|
||||
@app.route('/myclass/api/Get_Session_Action_Status_By_Document/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Get_Session_Action_Status_By_Document():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Get_Session_Action_Status_By_Document payload = ",payload)
|
||||
print(request.files)
|
||||
status, retval = module_editique.Get_Session_Action_Status_By_Document(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
@app.route('/myclass/api/Get_Given_Session_Action_Status_By_Document/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Get_Given_Session_Action_Status_By_Document():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Get_Given_Session_Action_Status_By_Document payload = ",payload)
|
||||
print(request.files)
|
||||
status, retval = module_editique.Get_Given_Session_Action_Status_By_Document(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
"""
|
||||
API pour ajouter un site de formation
|
||||
"""
|
||||
|
@ -8602,6 +8626,123 @@ def Compute_Invoice_Order_Data():
|
|||
status, retval = partner_invoice.Compute_Invoice_Order_Data(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
"""
|
||||
API pour ajouter / mettre à jour une unité d'enseignement (UE) à une formation
|
||||
"""
|
||||
@app.route('/myclass/api/Add_Update_UE_To_Class/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Add_Update_UE_To_Class():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Add_Update_UE_To_Class payload = ",payload)
|
||||
status, retval = cm.Add_Update_UE_To_Class(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
"""
|
||||
API pour supprimer une unité d'enseignement (UE) à une formation
|
||||
"""
|
||||
@app.route('/myclass/api/Delete_UE_From_Class/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Delete_UE_From_Class():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Delete_UE_From_Class payload = ",payload)
|
||||
status, retval = cm.Delete_UE_From_Class(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
"""
|
||||
API pour créer une unité d'enseignement (UE)
|
||||
"""
|
||||
@app.route('/myclass/api/Add_Unite_Enseignement/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Add_Unite_Enseignement():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Add_Unite_Enseignement payload = ",payload)
|
||||
status, retval = unite_enseignement_mgt.Add_Unite_Enseignement(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
"""
|
||||
API pour mettre à jour une unité d'enseignement (UE)
|
||||
"""
|
||||
@app.route('/myclass/api/Update_Unite_Enseignement/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Update_Unite_Enseignement():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Update_Unite_Enseignement payload = ",payload)
|
||||
status, retval = unite_enseignement_mgt.Update_Unite_Enseignement(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
"""
|
||||
API pour recuperer la liste des unités d'enseignement (UE) sans filtres
|
||||
"""
|
||||
@app.route('/myclass/api/Get_List_Unite_Enseignement_no_filter/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Get_List_Unite_Enseignement_no_filter():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Get_List_Unite_Enseignement_no_filter payload = ",payload)
|
||||
status, retval = unite_enseignement_mgt.Get_List_Unite_Enseignement_no_filter(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
"""
|
||||
API pour recuperer la liste des unités d'enseignement (UE) avec filtres
|
||||
"""
|
||||
@app.route('/myclass/api/Get_List_Unite_Enseignement_with_filter/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Get_List_Unite_Enseignement_with_filter():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Get_List_Unite_Enseignement_with_filter payload = ",payload)
|
||||
status, retval = unite_enseignement_mgt.Get_List_Unite_Enseignement_with_filter(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
"""
|
||||
API pour supprimer une unité d'enseignement (UE)
|
||||
"""
|
||||
@app.route('/myclass/api/Delete_Given_Unite_Enseignement/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Delete_Given_Unite_Enseignement():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Delete_Given_Unite_Enseignement payload = ",payload)
|
||||
status, retval = unite_enseignement_mgt.Delete_Given_Unite_Enseignement(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
"""
|
||||
API pour recuperer les données d'une unité d'enseignement (UE)
|
||||
"""
|
||||
@app.route('/myclass/api/Get_Given_Unite_Enseignement/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Get_Given_Unite_Enseignement():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Get_Given_Unite_Enseignement payload = ",payload)
|
||||
status, retval = unite_enseignement_mgt.Get_Given_Unite_Enseignement(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
"""
|
||||
API pour recuperer les données d'une unité d'enseignement (UE) d'une formation donnée
|
||||
"""
|
||||
@app.route('/myclass/api/Get_List_Unite_Enseignement_Of_Given_Class/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Get_List_Unite_Enseignement_Of_Given_Class():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Get_List_Unite_Enseignement_Of_Given_Class payload = ",payload)
|
||||
status, retval = unite_enseignement_mgt.Get_List_Unite_Enseignement_Of_Given_Class(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
@ -154,7 +154,7 @@ def Get_Editable_Document_By_Partner_By_Collection(diction):
|
|||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', 'related_collection', 'related_collection_recid']
|
||||
field_list = ['token', 'related_collection', 'related_collection_recid', 'session_id']
|
||||
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
|
@ -166,7 +166,7 @@ def Get_Editable_Document_By_Partner_By_Collection(diction):
|
|||
"""
|
||||
Verification des champs obligatoires
|
||||
"""
|
||||
field_list_obligatoire = ['token', 'related_collection']
|
||||
field_list_obligatoire = ['token', 'related_collection', 'session_id']
|
||||
|
||||
for val in field_list_obligatoire:
|
||||
if val not in diction:
|
||||
|
@ -272,10 +272,45 @@ def Get_Editable_Document_By_Partner_By_Collection(diction):
|
|||
if ('courrier_template_ref_interne' in New_retVal.keys()):
|
||||
user['courrier_template_ref_interne'] = str(New_retVal['courrier_template_ref_interne'])
|
||||
|
||||
docu_statut = "0" #
|
||||
user['courrier_template_ref_interne'] = ""
|
||||
if ('ref_interne' in New_retVal['collection_courrier_template'].keys()):
|
||||
user['courrier_template_ref_interne'] = str(New_retVal['collection_courrier_template']['ref_interne'])
|
||||
|
||||
# On va recuperer le statut de ce type de document pour savoir si toutes les actions ont été menée
|
||||
docu_statut = 0 #
|
||||
local_diction = {}
|
||||
local_diction['session_id'] = diction['session_id']
|
||||
local_diction['token'] = diction['token']
|
||||
local_diction['courrier_template_type_document_ref_interne'] = str(New_retVal['collection_courrier_template']['ref_interne'])
|
||||
|
||||
#print(" ### local_diction = ", local_diction )
|
||||
|
||||
local_doc_status, local_doc_retval = Get_Given_Session_Action_Status_By_Document(local_diction)
|
||||
if( local_doc_status is False ):
|
||||
docu_statut = "0" #
|
||||
|
||||
List_Document_a_Traquer = local_doc_retval
|
||||
|
||||
if (List_Document_a_Traquer[0]['global_status']):
|
||||
if( str(List_Document_a_Traquer[0]['global_status']) == "partiel"):
|
||||
docu_statut = "1"
|
||||
elif( str(List_Document_a_Traquer[0]['global_status']) == "complet"):
|
||||
docu_statut = "2"
|
||||
else:
|
||||
docu_statut = "0"
|
||||
|
||||
"""
|
||||
pour la completude d'un document :
|
||||
0 = Rien n'est fait
|
||||
1 = Partiel
|
||||
2 = Terminé
|
||||
"""
|
||||
user['statut_completude'] = str(docu_statut)
|
||||
|
||||
|
||||
|
||||
|
||||
user['courrier_template_nom'] = ""
|
||||
if ('nom' in New_retVal['collection_courrier_template'].keys()):
|
||||
user['courrier_template_nom'] = str(
|
||||
|
@ -388,11 +423,11 @@ def Get_Editable_Document_By_Partner_By_Collection(diction):
|
|||
user['has_history_event'] = has_history_event
|
||||
user['list_document_history_event'] = list_document_history_event
|
||||
|
||||
#print(" #### user['list_document_history_event'] = ", user['list_document_history_event'] )
|
||||
|
||||
val_tmp = val_tmp + 1
|
||||
RetObject.append(mycommon.JSONEncoder().encode(user))
|
||||
|
||||
#print(" #### RetObject = ", RetObject)
|
||||
|
||||
return True, RetObject
|
||||
|
||||
except Exception as e:
|
||||
|
@ -801,6 +836,9 @@ def Editic_Log_History_Action(my_partner, courrier_template_data, related_collec
|
|||
|
||||
print(" ### 0123 local_qry = ", local_qry)
|
||||
|
||||
#print(" ### 0123 target_collection = ", target_collection)
|
||||
#print(" ### 0123 target_collection_recid = ", target_collection_recid)
|
||||
|
||||
courrier_template_tracking_id = ""
|
||||
courrier_template_tracking_data = MYSY_GV.dbname['courrier_template_tracking'].find_one({'partner_owner_recid':str(my_partner['recid']),
|
||||
'valide':'1',
|
||||
|
@ -985,3 +1023,231 @@ def Account_Migration_to_delete(diction):
|
|||
return False, " Impossible de migrer le compte"
|
||||
|
||||
|
||||
"""
|
||||
Cette fonction permet de retourner sur une session les operation (documents)
|
||||
qui sont :
|
||||
- non commencés
|
||||
- partiellement faits
|
||||
- terminés
|
||||
"""
|
||||
|
||||
def Get_Session_Action_Status_By_Document(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', 'session_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', '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, " Les informations fournies sont incorrectes"
|
||||
|
||||
local_status, my_partner = mycommon.Check_Connexion_And_Return_Partner_Data(diction)
|
||||
if (local_status is not True):
|
||||
return local_status, my_partner
|
||||
|
||||
# 1 - Recuperer la liste des participants
|
||||
List_participant = []
|
||||
for tmp in MYSY_GV.dbname['inscription'].find({'session_id': diction['session_id'], 'status': '1'},
|
||||
{'_id': 1, 'email': 1}):
|
||||
node = {}
|
||||
node['_id'] = str(tmp['_id'])
|
||||
node['email'] = str(tmp['email'])
|
||||
List_participant.append(node)
|
||||
|
||||
# 2 - Liste des documents traqués
|
||||
List_Document_a_Traquer = []
|
||||
for tmp in MYSY_GV.dbname['courrier_template_tracking'].find({'partner_owner_recid': str(my_partner['recid']),
|
||||
'valide': '1', 'locked': '0'},
|
||||
{'_id': 1, 'courrier_template_type_document_id': 1,
|
||||
'courrier_template_type_document_ref_interne': 1,
|
||||
'rang': 1}).sort([("rang", pymongo.ASCENDING)]):
|
||||
node = {}
|
||||
node['_id'] = str(tmp['_id'])
|
||||
node['courrier_template_type_document_id'] = str(tmp['courrier_template_type_document_id'])
|
||||
node['courrier_template_type_document_ref_interne'] = str(
|
||||
tmp['courrier_template_type_document_ref_interne'])
|
||||
node['rang'] = str(tmp['rang'])
|
||||
List_Document_a_Traquer.append(node)
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Si pour chaque type de document a traquer, tous les partipants sont dans history, alors on mais ok
|
||||
si aucun, on met ko,
|
||||
si au moins 1, on met : partiel
|
||||
la clé est : courrier_template_tracking.courrier_template_type_document_ref_interne
|
||||
|
||||
-- clé de recherhce : document a traquer (courrier_template_tracking._id) et inscription_id
|
||||
"""
|
||||
|
||||
RetObject = []
|
||||
nb_val = 0
|
||||
|
||||
for doc_a_tracker in List_Document_a_Traquer:
|
||||
|
||||
local_nb_inscrit = 0
|
||||
local_nb_has_history_tracking = 0
|
||||
local_status = "aucun"
|
||||
|
||||
for val in List_participant:
|
||||
# print("Participant zzz: " + str(val))
|
||||
|
||||
local_nb_inscrit = local_nb_inscrit + 1
|
||||
local_qry = {'partner_owner_recid': str(my_partner['recid']),
|
||||
'valide': '1', 'locked': '0', 'target_collection_recid': str(val['_id']),
|
||||
'courrier_template_tracking_id': str(doc_a_tracker['_id'])}
|
||||
|
||||
is_tracking_history = MYSY_GV.dbname['courrier_template_tracking_history'].count_documents(local_qry)
|
||||
if (is_tracking_history > 0):
|
||||
local_nb_has_history_tracking = local_nb_has_history_tracking + 1
|
||||
|
||||
|
||||
if (local_nb_inscrit == local_nb_has_history_tracking and local_nb_has_history_tracking == 0):
|
||||
local_status = "aucun"
|
||||
|
||||
if (local_nb_inscrit == local_nb_has_history_tracking and local_nb_has_history_tracking != 0):
|
||||
local_status = "complet"
|
||||
|
||||
if (local_nb_inscrit > local_nb_has_history_tracking and local_nb_has_history_tracking > 0):
|
||||
local_status = "partiel"
|
||||
|
||||
doc_a_tracker['global_status'] = str(local_status)
|
||||
|
||||
|
||||
RetObject.append(mycommon.JSONEncoder().encode(List_Document_a_Traquer))
|
||||
|
||||
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écuperer les données de Get_Session_Action_Status_By_Document "
|
||||
|
||||
|
||||
def Get_Given_Session_Action_Status_By_Document(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', 'session_id', 'courrier_template_type_document_ref_interne']
|
||||
|
||||
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', 'session_id', 'courrier_template_type_document_ref_interne']
|
||||
|
||||
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"
|
||||
|
||||
local_status, my_partner = mycommon.Check_Connexion_And_Return_Partner_Data(diction)
|
||||
if (local_status is not True):
|
||||
return local_status, my_partner
|
||||
|
||||
# 1 - Recuperer la liste des participants
|
||||
List_participant = []
|
||||
for tmp in MYSY_GV.dbname['inscription'].find({'session_id': diction['session_id'], 'status': '1'},
|
||||
{'_id': 1, 'email': 1}):
|
||||
node = {}
|
||||
node['_id'] = str(tmp['_id'])
|
||||
node['email'] = str(tmp['email'])
|
||||
List_participant.append(node)
|
||||
|
||||
# 2 - Liste des documents traqués
|
||||
List_Document_a_Traquer = []
|
||||
for tmp in MYSY_GV.dbname['courrier_template_tracking'].find({'partner_owner_recid': str(my_partner['recid']),
|
||||
'valide': '1', 'locked': '0',
|
||||
'courrier_template_type_document_ref_interne':diction['courrier_template_type_document_ref_interne']},
|
||||
{'_id': 1, 'courrier_template_type_document_id': 1,
|
||||
'courrier_template_type_document_ref_interne': 1,
|
||||
'rang': 1}).sort([("rang", pymongo.ASCENDING)]):
|
||||
node = {}
|
||||
node['_id'] = str(tmp['_id'])
|
||||
node['courrier_template_type_document_id'] = str(tmp['courrier_template_type_document_id'])
|
||||
node['courrier_template_type_document_ref_interne'] = str(
|
||||
tmp['courrier_template_type_document_ref_interne'])
|
||||
node['rang'] = str(tmp['rang'])
|
||||
List_Document_a_Traquer.append(node)
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Si pour chaque type de document a traquer, tous les partipants sont dans history, alors on mais ok
|
||||
si aucun, on met ko,
|
||||
si au moins 1, on met : partiel
|
||||
la clé est : courrier_template_tracking.courrier_template_type_document_ref_interne
|
||||
|
||||
-- clé de recherhce : document a traquer (courrier_template_tracking._id) et inscription_id
|
||||
"""
|
||||
|
||||
RetObject = []
|
||||
nb_val = 0
|
||||
|
||||
for doc_a_tracker in List_Document_a_Traquer:
|
||||
|
||||
local_nb_inscrit = 0
|
||||
local_nb_has_history_tracking = 0
|
||||
local_status = "aucun"
|
||||
|
||||
for val in List_participant:
|
||||
# print("Participant zzz: " + str(val))
|
||||
|
||||
local_nb_inscrit = local_nb_inscrit + 1
|
||||
local_qry = {'partner_owner_recid': str(my_partner['recid']),
|
||||
'valide': '1', 'locked': '0', 'target_collection_recid': str(val['_id']),
|
||||
'courrier_template_tracking_id': str(doc_a_tracker['_id'])}
|
||||
|
||||
is_tracking_history = MYSY_GV.dbname['courrier_template_tracking_history'].count_documents(local_qry)
|
||||
if (is_tracking_history > 0):
|
||||
local_nb_has_history_tracking = local_nb_has_history_tracking + 1
|
||||
|
||||
|
||||
if (local_nb_inscrit == local_nb_has_history_tracking and local_nb_has_history_tracking == 0):
|
||||
local_status = "aucun"
|
||||
|
||||
if (local_nb_inscrit == local_nb_has_history_tracking and local_nb_has_history_tracking != 0):
|
||||
local_status = "complet"
|
||||
|
||||
if (local_nb_inscrit > local_nb_has_history_tracking and local_nb_has_history_tracking > 0):
|
||||
local_status = "partiel"
|
||||
|
||||
doc_a_tracker['global_status'] = str(local_status)
|
||||
|
||||
|
||||
|
||||
return True, List_Document_a_Traquer
|
||||
|
||||
|
||||
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écuperer les données de Get_Session_Action_Status_By_Document "
|
||||
|
|
20
partners.py
20
partners.py
|
@ -1151,6 +1151,26 @@ def get_partner_account(diction):
|
|||
user['mysy_lms_user_id'] = mysy_lms_user_id
|
||||
|
||||
|
||||
"""
|
||||
update du 01/05/2024
|
||||
Pour distinguer si le partenaire est a lié à une formation initiale ou continue
|
||||
on va aller recuperer les parametrage sur le compte admin du partenaire.
|
||||
|
||||
Volontairement, on ne descend pas ce paramettre sur les utilisateurs associée au partenaire
|
||||
"""
|
||||
|
||||
|
||||
|
||||
admin_partnair_account = MYSY_GV.dbname['partnair_account'].find_one({'recid':retVal['recid'],
|
||||
'active':'1',
|
||||
'locked':'0',
|
||||
'is_partner_admin_account':"1"})
|
||||
|
||||
formation_initiale = "0"
|
||||
if(admin_partnair_account and "formation_initiale" in admin_partnair_account.keys() ):
|
||||
formation_initiale = str(admin_partnair_account['formation_initiale'])
|
||||
|
||||
user['formation_initiale'] = formation_initiale
|
||||
|
||||
RetObject.append(JSONEncoder().encode(user))
|
||||
|
||||
|
|
|
@ -796,212 +796,117 @@ def mysylmsdb():
|
|||
|
||||
def test_web_service(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Algorithme :
|
||||
|
||||
1 - Pour chaque employé, aller chercher ses contrats valides de la periode. Completer ce tableaux avec les données du contrat
|
||||
mettre dans une tableau en local
|
||||
|
||||
2 - Pour chaque tache de l'employée, aller chercher le contrat qui correspond à la periode de la tache
|
||||
- Peupler ce tableau avec : tache (agenda), contrat (data), employé (data)
|
||||
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = [ 'token', 'session_id', ]
|
||||
|
||||
tab_lines_employe_by_contract = []
|
||||
|
||||
"""
|
||||
Etape 1: Récuperation des donnée employé avec les contrat associés
|
||||
"""
|
||||
qry_employe_contrat = ( [
|
||||
|
||||
{ '$match': {'_id':ObjectId('6509a1adaca6e5023d7af487')}},
|
||||
|
||||
|
||||
{'$lookup': {
|
||||
'from': 'ressource_humaine_contrat',
|
||||
'let': { 'rh_id': {'$toString': '$_id'} , 'rh_partner_owner_recid':'$partner_recid'},
|
||||
'pipeline': [
|
||||
{'$match':
|
||||
{'$expr':
|
||||
{'$and':
|
||||
[
|
||||
|
||||
{'$eq': ['$valide', '1']},
|
||||
{'$eq': ['$rh_id', '$$rh_id']},
|
||||
{'$eq': ['$partner_owner_recid', '$$rh_partner_owner_recid']}
|
||||
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{"$project": {"_id": 0,} }
|
||||
|
||||
|
||||
],
|
||||
|
||||
'as': 'collection_ressource_humaine_contrat'
|
||||
}
|
||||
},
|
||||
{
|
||||
'$unwind':'$collection_ressource_humaine_contrat'
|
||||
}
|
||||
|
||||
|
||||
])
|
||||
|
||||
cpt = 0
|
||||
for retval in MYSY_GV.dbname['ressource_humaine'].aggregate(qry_employe_contrat):
|
||||
#print(" ### retval = ", retval)
|
||||
|
||||
cpt = cpt + 1
|
||||
|
||||
rh_id_Object = ObjectId(str(retval['_id']))
|
||||
retval['_id'] = str(rh_id_Object)
|
||||
|
||||
"""
|
||||
Si le contrat est lié à un groupe de prix, alors aller chercher les elements du groupe de prix
|
||||
"""
|
||||
if( "groupe_prix_achat_id" in retval['collection_ressource_humaine_contrat'].keys() and retval['collection_ressource_humaine_contrat']['groupe_prix_achat_id'] ):
|
||||
price_grp_data = MYSY_GV.dbname['purchase_prices'].find_one({'_id':ObjectId(str(retval['collection_ressource_humaine_contrat']['groupe_prix_achat_id'] )),
|
||||
'valide':'1',
|
||||
'locked':'0',
|
||||
'partner_owner_recid':str(retval['collection_ressource_humaine_contrat']['partner_owner_recid']),
|
||||
})
|
||||
|
||||
if( price_grp_data and "prix" in price_grp_data.keys() and "periodicite" in price_grp_data.keys()):
|
||||
retval['collection_ressource_humaine_contrat']['groupe_prix_achat_cout'] = str(price_grp_data['prix'])
|
||||
retval['collection_ressource_humaine_contrat']['groupe_prix_achat_periodicite'] = str(price_grp_data['periodicite'])
|
||||
else:
|
||||
retval['collection_ressource_humaine_contrat']['groupe_prix_achat_cout'] = ""
|
||||
retval['collection_ressource_humaine_contrat']['groupe_prix_achat_periodicite'] = ""
|
||||
|
||||
else:
|
||||
retval['collection_ressource_humaine_contrat']['groupe_prix_achat_cout'] = ""
|
||||
retval['collection_ressource_humaine_contrat']['groupe_prix_achat_periodicite'] = ""
|
||||
|
||||
retval['Tab_agenda'] = []
|
||||
"""
|
||||
Aller chercher toutes taches valides entre les date du contrat
|
||||
"""
|
||||
date_debut_contrat = ""
|
||||
date_fin_contrat = ""
|
||||
if( "collection_ressource_humaine_contrat" in retval.keys() and "date_debut" in retval['collection_ressource_humaine_contrat'].keys() ):
|
||||
date_debut_contrat = retval['collection_ressource_humaine_contrat']['date_debut']
|
||||
|
||||
if ("collection_ressource_humaine_contrat" in retval.keys() and "date_fin" in retval[
|
||||
'collection_ressource_humaine_contrat'].keys()):
|
||||
date_fin_contrat = retval['collection_ressource_humaine_contrat']['date_fin']
|
||||
|
||||
print(" ### date_debut_contrat = ", date_debut_contrat)
|
||||
print(" ### date_fin_contrat = ", date_fin_contrat)
|
||||
|
||||
|
||||
if( mycommon.CheckisDate(date_debut_contrat) is False or mycommon.CheckisDate(date_fin_contrat) is False ) :
|
||||
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]) + " Les dates de debut et/ou fin de contrat de l'employé "+str(retval['nom']+" "+retval['prenom']) +" ne sont au format jj/mm/aaaa.")
|
||||
return False, " Les dates de debut et/ou fin de contrat de l'employé "+str(retval['nom']+" "+retval['prenom']) +" ne sont au format jj/mm/aaaa. "
|
||||
inspect.stack()[0][3]) + " Le champ '" + val + "' n'est pas autorisé")
|
||||
return False, " Les informations fournies sont incorrectes"
|
||||
|
||||
print(" ### Du " + str(date_debut_contrat) + " Au " + str(
|
||||
date_fin_contrat) + " les taches de type planning trouvées sont : ")
|
||||
"""
|
||||
Etape 2 :
|
||||
Aller recuperer les taches dans les agendas
|
||||
"""
|
||||
event_type_filter = {'$eq': ["$event_type", "planning"]}
|
||||
filt_session_start_date_ISODATE = datetime.strptime(str(date_debut_contrat), '%d/%m/%Y')
|
||||
filt_session_end_date_ISODATE = datetime.strptime(str(date_fin_contrat), '%d/%m/%Y')
|
||||
|
||||
local_qry_tache_agenda = ([
|
||||
{"$match": {'_id': rh_id_Object}},
|
||||
{'$lookup': {
|
||||
'from': 'agenda',
|
||||
"let": {"rh_id": {'$toString': "$_id"}, 'rh_partner_owner_recid': '$partner_recid'},
|
||||
'pipeline': [
|
||||
{'$match':
|
||||
{'$expr':
|
||||
{'$and':
|
||||
[
|
||||
|
||||
event_type_filter,
|
||||
{'$eq': ["$valide", "1"]},
|
||||
{'$eq': ["$related_collection_recid", '$$rh_id']},
|
||||
{'$eq': ["$partner_owner_recid", '$$rh_partner_owner_recid']},
|
||||
{'$gte': [{'$toDate': "$event_start"}, filt_session_start_date_ISODATE]},
|
||||
{'$lte': [{'$toDate': "$event_start"}, filt_session_end_date_ISODATE]}
|
||||
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
],
|
||||
'as': 'collection_agenda'
|
||||
}
|
||||
},
|
||||
{
|
||||
'$unwind': '$collection_agenda'
|
||||
}
|
||||
])
|
||||
|
||||
print(" ### local_qry_tache_agenda ici pipe_qry = ", local_qry_tache_agenda)
|
||||
for retval_agenda in MYSY_GV.dbname['ressource_humaine'].aggregate(local_qry_tache_agenda):
|
||||
#print(" ### retval_agenda Trouvé = ", retval_agenda)
|
||||
agenda_id_Object = ObjectId(str(retval_agenda['_id']))
|
||||
|
||||
retval_agenda['_id'] = str(agenda_id_Object)
|
||||
retval_agenda['collection_agenda']['_id'] = str(retval_agenda['collection_agenda']['_id'])
|
||||
|
||||
if ("event_start" in retval_agenda['collection_agenda'].keys()):
|
||||
retval_agenda['collection_agenda']['agenda_date_jour'] = str(datetime.strptime(str(retval_agenda['collection_agenda']['event_end'])[0:16], '%Y-%m-%dT%H:%M').strftime("%d/%m/%Y"))
|
||||
|
||||
else:
|
||||
retval_agenda['collection_agenda']['agenda_date_jour'] = ""
|
||||
|
||||
event_duration_second = datetime.strptime(str(retval_agenda['collection_agenda']['event_end'])[0:16],'%Y-%m-%dT%H:%M') - datetime.strptime(str(retval_agenda['collection_agenda']['event_start'])[0:16], '%Y-%m-%dT%H:%M')
|
||||
event_duration_second = event_duration_second.total_seconds()
|
||||
|
||||
event_duration_hour = round(divmod(event_duration_second, 3600)[0] + divmod(event_duration_second, 3600)[1] / 3600, 2)
|
||||
|
||||
retval_agenda['collection_agenda']['event_duration_second'] = str(event_duration_second)
|
||||
retval_agenda['collection_agenda']['event_duration_hour'] = str(event_duration_hour)
|
||||
|
||||
|
||||
json_agenda_formatted_str = json.dumps(retval_agenda, indent=2)
|
||||
|
||||
if( "collection_agenda" in retval_agenda.keys() and "partner_owner_recid" in retval_agenda['collection_agenda'].keys()):
|
||||
new_node = retval_agenda['collection_agenda']
|
||||
retval['Tab_agenda'].append(new_node)
|
||||
#print(" ### NODE ADDED = ", new_node)
|
||||
|
||||
|
||||
print(" ### retval_agenda = ", json_agenda_formatted_str)
|
||||
|
||||
json_formatted_str = json.dumps(retval, indent=2)
|
||||
print(" ### Final Line : ", json_formatted_str)
|
||||
tab_lines_employe_by_contract.append(retval)
|
||||
|
||||
|
||||
local_status, local_retval = format_emplee_contrat_agenda_events(tab_lines_employe_by_contract)
|
||||
if( local_status is False):
|
||||
return local_status, local_retval
|
||||
|
||||
print(" #### local_retval = ", local_retval)
|
||||
cpt = 0
|
||||
print(" =================== ")
|
||||
for val in local_retval :
|
||||
tab_lines_employe_by_contract_json_formatted_str = json.dumps(val, indent=2)
|
||||
print(" ### Final Line "+str(cpt)+" : ", tab_lines_employe_by_contract_json_formatted_str)
|
||||
cpt = cpt + 1
|
||||
|
||||
print(' on a ' + str(cpt) + ' lignes ')
|
||||
|
||||
"""tab_lines_employe_by_contract_json_formatted_str = json.dumps(tab_lines_employe_by_contract, indent=2)
|
||||
|
||||
print(" ### Final Line : ", tab_lines_employe_by_contract_json_formatted_str)
|
||||
print(' on a ' + str(cpt) + ' lignes ')
|
||||
"""
|
||||
Verification des champs obligatoires
|
||||
"""
|
||||
field_list_obligatoire = ['token', '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, " Les informations fournies sont incorrectes"
|
||||
|
||||
local_status, my_partner = mycommon.Check_Connexion_And_Return_Partner_Data(diction)
|
||||
if (local_status is not True):
|
||||
return local_status, my_partner
|
||||
|
||||
|
||||
# 1 - Recuperer la liste des participants
|
||||
List_participant = []
|
||||
for tmp in MYSY_GV.dbname['inscription'].find({'session_id':diction['session_id'], 'status':'1'},{'_id':1, 'email':1}):
|
||||
node = {}
|
||||
node['_id'] = str(tmp['_id'])
|
||||
node['email'] = str(tmp['email'])
|
||||
List_participant.append(node)
|
||||
|
||||
|
||||
|
||||
# 2 - Liste des documents traqués
|
||||
List_Document_a_Traquer = []
|
||||
for tmp in MYSY_GV.dbname['courrier_template_tracking'].find({'partner_owner_recid':str(my_partner['recid']),
|
||||
'valide':'1', 'locked':'0'},
|
||||
{'_id':1, 'courrier_template_type_document_id':1,
|
||||
'courrier_template_type_document_ref_interne':1, 'rang':1}).sort([("rang", pymongo.ASCENDING)]):
|
||||
node = {}
|
||||
node['_id'] = str(tmp['_id'])
|
||||
node['courrier_template_type_document_id'] = str(tmp['courrier_template_type_document_id'])
|
||||
node['courrier_template_type_document_ref_interne'] = str(tmp['courrier_template_type_document_ref_interne'])
|
||||
node['rang'] = str(tmp['rang'])
|
||||
List_Document_a_Traquer.append(node)
|
||||
|
||||
print(" LISTE des PARTIPANTS")
|
||||
for val in List_participant:
|
||||
print("Participant : "+str(val))
|
||||
|
||||
print(" LISTE des DOCUMENT A TRAQUER")
|
||||
for val in List_Document_a_Traquer:
|
||||
print("Document a traquer "+str(val))
|
||||
|
||||
"""
|
||||
Si pour chaque type de document a traquer, tous les partipants sont dans history, alors on mais ok
|
||||
si aucun, on met ko,
|
||||
si au moins 1, on met : partiel
|
||||
la clé est : courrier_template_tracking.courrier_template_type_document_ref_interne
|
||||
|
||||
-- clé de recherhce : document a traquer (courrier_template_tracking._id) et inscription_id
|
||||
"""
|
||||
|
||||
|
||||
|
||||
for doc_a_tracker in List_Document_a_Traquer:
|
||||
print("TRAITEMENT DU DOCUMENT " + str(doc_a_tracker['courrier_template_type_document_ref_interne'])+" - _id = "+ str(doc_a_tracker['_id']))
|
||||
local_nb_inscrit = 0
|
||||
local_nb_has_history_tracking = 0
|
||||
local_status = "Aucun"
|
||||
|
||||
for val in List_participant:
|
||||
#print("Participant zzz: " + str(val))
|
||||
print(" cle de recherche : courrier_template_tracking_id = ",str(doc_a_tracker['_id']), " / target_collection_recid = "+str(val['_id']) )
|
||||
local_nb_inscrit = local_nb_inscrit + 1
|
||||
local_qry = {'partner_owner_recid':str(my_partner['recid']),
|
||||
'valide':'1', 'locked':'0', 'target_collection_recid':str(val['_id']),
|
||||
'courrier_template_tracking_id':str(doc_a_tracker['_id'])}
|
||||
|
||||
is_tracking_history = MYSY_GV.dbname['courrier_template_tracking_history'].count_documents(local_qry)
|
||||
if( is_tracking_history > 0 ):
|
||||
local_nb_has_history_tracking = local_nb_has_history_tracking + 1
|
||||
|
||||
print("local_qry : " + str(local_qry))
|
||||
print(" Pour le document a traquer : ", doc_a_tracker['courrier_template_type_document_ref_interne'])
|
||||
print("local_nb_inscrit VS local_nb_has_history_tracking: " + str(local_nb_inscrit)+" VS "+str(local_nb_has_history_tracking))
|
||||
if( local_nb_inscrit == local_nb_has_history_tracking and local_nb_has_history_tracking == 0 ):
|
||||
local_status = "Aucun"
|
||||
|
||||
if( local_nb_inscrit == local_nb_has_history_tracking and local_nb_has_history_tracking != 0 ):
|
||||
local_status = "Complet"
|
||||
|
||||
if (local_nb_inscrit > local_nb_has_history_tracking and local_nb_has_history_tracking > 0):
|
||||
local_status = "Partiel"
|
||||
|
||||
doc_a_tracker['global_status'] = str(local_status)
|
||||
|
||||
print(" Statut : ", local_status)
|
||||
|
||||
print(" END LISTE des DOCUMENT A TRAQUER WITH STATUS ")
|
||||
for val in List_Document_a_Traquer:
|
||||
print("Document a traquer " + str(val['courrier_template_type_document_ref_interne'])+" STATUS = "+ str(val['global_status']) )
|
||||
|
||||
return True, "Test WebService OK Diction "
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,684 @@
|
|||
"""
|
||||
Ce fichier permet de gerer les unités d'enseignement (UE)
|
||||
Une unité d'enseignement est definit par :
|
||||
- Code (valeur unique & clé)
|
||||
- Titre
|
||||
- Description
|
||||
- prerequis
|
||||
- Objectif
|
||||
- Programme
|
||||
- Méthode pédagogique
|
||||
- Méthode d'évaluation
|
||||
- Support
|
||||
- Durée (heures, jours, semaines, mois)
|
||||
|
||||
Rattachement Unité d’enseignement (UE) & formation :
|
||||
Lors du rattachement d’une UE à une formation, il faudra définir :
|
||||
- Le crédit associé (numérique)
|
||||
- Présentiel/ distantiel/ hybride,
|
||||
- Est_note (oui / non) pour savoir cette unité doit être notée
|
||||
- Groupe_evaluation : Dans une formation, on peut rassembler plusieurs UE dans un groupe d’UE
|
||||
|
||||
"""
|
||||
|
||||
import bson
|
||||
import pymongo
|
||||
from pymongo import MongoClient
|
||||
import json
|
||||
from bson import ObjectId
|
||||
import re
|
||||
from datetime import datetime
|
||||
import prj_common as mycommon
|
||||
import secrets
|
||||
import inspect
|
||||
import sys, os
|
||||
import csv
|
||||
import pandas as pd
|
||||
from pymongo import ReturnDocument
|
||||
import GlobalVariable as MYSY_GV
|
||||
from math import isnan
|
||||
import GlobalVariable as MYSY_GV
|
||||
import ela_index_bdd_classes as eibdd
|
||||
import email_mgt as email
|
||||
import jinja2
|
||||
from flask import send_file
|
||||
from xhtml2pdf import pisa
|
||||
from email.message import EmailMessage
|
||||
from email.mime.text import MIMEText
|
||||
from email import encoders
|
||||
import smtplib
|
||||
from email.mime.multipart import MIMEMultipart
|
||||
from email.mime.text import MIMEText
|
||||
from email.mime.base import MIMEBase
|
||||
from email import encoders
|
||||
|
||||
"""
|
||||
Ajout d'une unité d'enseignement (UE)
|
||||
"""
|
||||
def Add_Unite_Enseignement(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', 'code', 'titre', 'description', 'objectif', 'prerequis', 'programme', 'methode_pedagogique', 'methode_evaluation',
|
||||
'support', 'duration', 'duration_unite' ]
|
||||
|
||||
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', 'code', 'titre',]
|
||||
|
||||
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
|
||||
|
||||
mydata = {}
|
||||
|
||||
mydata = diction
|
||||
del mydata['token']
|
||||
|
||||
# Initialisation des champs non envoyés à vide
|
||||
for val in field_list:
|
||||
if val not in diction.keys():
|
||||
mydata[str(val)] = ""
|
||||
|
||||
|
||||
# Verifier qu'une UE avec le meme code n'existe pas déjà pour ce partenaire
|
||||
is_ue_exist_count = MYSY_GV.dbname['unite_enseignement'].count_documents({'partner_owner_recid':my_partner['recid'],
|
||||
'valide':'1',
|
||||
'code':diction['code']})
|
||||
if( is_ue_exist_count > 0 ):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " Il existe déjà une UE avec le même code ")
|
||||
return False, " Il existe déjà une UE avec le même code "
|
||||
|
||||
"""
|
||||
Verifier que l'unite de durée est valide
|
||||
"""
|
||||
if( "duration_unite" in diction.keys() and diction['duration_unite']):
|
||||
if( diction['duration_unite'] not in MYSY_GV.CLASS_DURATION_UNIT):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " L'unité de durée est invalide ")
|
||||
return False, " L'unité de durée est invalide "
|
||||
|
||||
"""
|
||||
Verifier que la durée est bien un float
|
||||
"""
|
||||
if ("duration" in diction.keys() and diction['duration']):
|
||||
local_status, local_retval = mycommon.IsFloat(str(diction['duration']))
|
||||
if( local_status is False ):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " La durée est invalide ")
|
||||
return False, " La durée est invalide "
|
||||
|
||||
|
||||
|
||||
|
||||
mydata['date_update'] = str(datetime.now())
|
||||
mydata['update_by'] = str(my_partner['_id'])
|
||||
mydata['partner_owner_recid'] = str(my_partner['recid'])
|
||||
mydata['valide'] = "1"
|
||||
mydata['locked'] = "0"
|
||||
|
||||
del mydata['token']
|
||||
|
||||
|
||||
|
||||
inserted_id = MYSY_GV.dbname['unite_enseignement'].insert_one(mydata).inserted_id
|
||||
|
||||
if (not inserted_id):
|
||||
mycommon.myprint(" Impossible de créer l'unité d'enseignement (2) ")
|
||||
return False, " Impossible de créer l'unité d'enseignement (2) "
|
||||
|
||||
return True, " L'unité d'enseignement a été correctement ajouté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 créer l'UE "
|
||||
|
||||
|
||||
"""
|
||||
Mise à jour d'une unité d'enseignement
|
||||
"""
|
||||
def Update_Unite_Enseignement(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
|
||||
field_list = ['token', '_id', 'code', 'titre', 'description', 'objectif', 'prerequis', 'programme',
|
||||
'methode_pedagogique', 'methode_evaluation', 'support', 'duration', 'duration_unite']
|
||||
|
||||
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']
|
||||
|
||||
ue_id = ""
|
||||
if ("_id" in diction.keys()):
|
||||
if diction['_id']:
|
||||
ue_id = diction['_id']
|
||||
|
||||
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'UE existe et est valide
|
||||
is_valide_opport = MYSY_GV.dbname['unite_enseignement'].count_documents({'_id':ObjectId(str(ue_id)),
|
||||
'valide':'1',
|
||||
'locked':'0',
|
||||
'partner_owner_recid':str(my_partner['recid'])})
|
||||
|
||||
|
||||
if( is_valide_opport != 1):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " L'identifiant de l'UE est invalide ")
|
||||
return False, " L'identifiant de l'UE est invalide "
|
||||
|
||||
|
||||
"""
|
||||
Si on veut modidier le code, verifier que le nouveau code n'est pas deja prix
|
||||
"""
|
||||
if( "code" in diction.keys() ):
|
||||
is_new_code_exist_with_orther_id = MYSY_GV.dbname['unite_enseignement'].find_one({'code':str(diction['code']),
|
||||
'valide':'1',
|
||||
'locked':'0',
|
||||
'partner_owner_recid':str(my_partner['recid'])})
|
||||
|
||||
if( is_new_code_exist_with_orther_id and str(is_new_code_exist_with_orther_id['_id']) != ue_id ):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " Le code de l'UE '"+str(diction['code'])+" est déjà utilisé ")
|
||||
return False, " Le code de l'UE '"+str(diction['code'])+" est déjà utilisé "
|
||||
|
||||
|
||||
|
||||
mydata = {}
|
||||
mydata = diction
|
||||
del mydata['token']
|
||||
del mydata['_id']
|
||||
|
||||
|
||||
mydata['date_update'] = str(datetime.now())
|
||||
mydata['update_by'] = str(my_partner['_id'])
|
||||
|
||||
result = MYSY_GV.dbname['unite_enseignement'].find_one_and_update(
|
||||
{'_id':ObjectId(str(ue_id)),
|
||||
'partner_owner_recid':str(my_partner['recid'])},
|
||||
{"$set": mydata},
|
||||
upsert=False,
|
||||
return_document=ReturnDocument.AFTER
|
||||
)
|
||||
if ("_id" not in result.keys()):
|
||||
mycommon.myprint(
|
||||
" Impossible de mettre à jour l'UE (2) ")
|
||||
return False, " Impossible de mettre à jour l'UE (2) "
|
||||
|
||||
|
||||
|
||||
return True, " L'UE a été correctement mise à jour "
|
||||
|
||||
|
||||
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 mettre à jour l'UE "
|
||||
|
||||
|
||||
"""
|
||||
Recuperer la liste des UE, sans filtres
|
||||
"""
|
||||
def Get_List_Unite_Enseignement_no_filter(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
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'est pas autorisé")
|
||||
return False, " Les informations fournies sont incorrectes"
|
||||
|
||||
"""
|
||||
Verification 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, " 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
|
||||
|
||||
|
||||
RetObject = []
|
||||
val_tmp = 0
|
||||
|
||||
qry = {"partner_owner_recid":str(my_partner['recid']), 'valide':'1', 'locked':'0'}
|
||||
|
||||
for New_retVal in MYSY_GV.dbname['unite_enseignement'].find(qry).sort([("_id", pymongo.DESCENDING), ]):
|
||||
user = New_retVal
|
||||
user['id'] = str(val_tmp)
|
||||
val_tmp = val_tmp + 1
|
||||
|
||||
if (str(New_retVal['duration_unite']) == "heure"):
|
||||
user['duration_concat'] = str(New_retVal['duration']) + " h"
|
||||
elif (str(New_retVal['duration_unite']) == "jour"):
|
||||
user['duration_concat'] = str(New_retVal['duration']) + " j"
|
||||
elif (str(New_retVal['duration_unite']) == "semaine"):
|
||||
user['duration_concat'] = str(New_retVal['duration']) + " s"
|
||||
elif (str(New_retVal['duration_unite']) == "mois"):
|
||||
user['duration_concat'] = str(New_retVal['duration']) + " m"
|
||||
elif (str(New_retVal['duration_unite']) == "annee"):
|
||||
user['duration_concat'] = str(New_retVal['duration']) + " a"
|
||||
else:
|
||||
user['duration_concat'] = str(New_retVal['duration']) + " ?"
|
||||
|
||||
RetObject.append(mycommon.JSONEncoder().encode(user))
|
||||
|
||||
|
||||
#print(" #### RetObject = ", RetObject)
|
||||
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 la liste des unites d'enseignement "
|
||||
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Recuperer la liste des UE, avec filtres
|
||||
"""
|
||||
def Get_List_Unite_Enseignement_with_filter(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token' 'code', 'titre']
|
||||
|
||||
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',]
|
||||
|
||||
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
|
||||
|
||||
filt_code = {}
|
||||
if ("code" in diction.keys()):
|
||||
filt_code = {'code': {'$regex': str(diction['code']), "$options": "i"}}
|
||||
|
||||
filt_titre = {}
|
||||
if ("titre" in diction.keys()):
|
||||
filt_titre = {'titre': {'$regex': str(diction['nom']), "$options": "i"}}
|
||||
|
||||
query = [{'$match': {
|
||||
'$and': [filt_code, filt_titre, {"partner_owner_recid":str(my_partner['recid']), 'valide':'1', 'locked':'0'} ]}},
|
||||
{'$sort': {'_id': -1}},
|
||||
]
|
||||
|
||||
RetObject = []
|
||||
val_tmp = 0
|
||||
|
||||
|
||||
for New_retVal in MYSY_GV.dbname['unite_enseignement'].find(query).sort([("_id", pymongo.DESCENDING), ]):
|
||||
user = New_retVal
|
||||
user['id'] = str(val_tmp)
|
||||
val_tmp = val_tmp + 1
|
||||
|
||||
if (str(New_retVal['duration_unite']) == "heure"):
|
||||
user['duration_concat'] = str(New_retVal['duration']) + " h"
|
||||
elif (str(New_retVal['duration_unite']) == "jour"):
|
||||
user['duration_concat'] = str(New_retVal['duration']) + " j"
|
||||
elif (str(New_retVal['duration_unite']) == "semaine"):
|
||||
user['duration_concat'] = str(New_retVal['duration']) + " s"
|
||||
elif (str(New_retVal['duration_unite']) == "mois"):
|
||||
user['duration_concat'] = str(New_retVal['duration']) + " m"
|
||||
elif (str(New_retVal['duration_unite']) == "annee"):
|
||||
user['duration_concat'] = str(New_retVal['duration']) + " a"
|
||||
else:
|
||||
user['duration_concat'] = str(New_retVal['duration']) + " ?"
|
||||
|
||||
|
||||
RetObject.append(mycommon.JSONEncoder().encode(user))
|
||||
|
||||
|
||||
#print(" #### RetObject = ", RetObject)
|
||||
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 la liste des unites d'enseignement "
|
||||
|
||||
|
||||
"""
|
||||
Suppression d'une UE
|
||||
Si elle n'est pas utilisée
|
||||
/!\ : le controle d'utilisation ou non de l'UE n'est pas fait encore
|
||||
"""
|
||||
def Delete_Given_Unite_Enseignement(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 l'existance de l'opportunité
|
||||
is_ue_valide = MYSY_GV.dbname['unite_enseignement'].count_documents({'_id':ObjectId(str(diction['_id'])),
|
||||
'partner_owner_recid':str(my_partner['recid'])})
|
||||
|
||||
if (is_ue_valide != 1):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " L'identifiant de l'UE est invalide ")
|
||||
return False, " L'identifiant de l'UE est invalide "
|
||||
|
||||
qry = {'_id':ObjectId(str(diction['_id'])), 'partner_owner_recid':str(my_partner['recid'])}
|
||||
|
||||
ret_del_competence = MYSY_GV.dbname['unite_enseignement'].delete_many(qry)
|
||||
|
||||
return True, "L'UE a été correctement 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 l'UE "
|
||||
|
||||
|
||||
"""
|
||||
Recuperer une UE données
|
||||
"""
|
||||
"""
|
||||
Recuperer la liste des UE, sans filtres
|
||||
"""
|
||||
def Get_Given_Unite_Enseignement(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
|
||||
|
||||
|
||||
RetObject = []
|
||||
val_tmp = 0
|
||||
|
||||
qry = {"partner_owner_recid":str(my_partner['recid']), 'valide':'1', 'locked':'0', '_id':ObjectId(str(diction['_id']))}
|
||||
|
||||
for New_retVal in MYSY_GV.dbname['unite_enseignement'].find(qry).sort([("_id", pymongo.DESCENDING), ]):
|
||||
user = New_retVal
|
||||
user['id'] = str(val_tmp)
|
||||
val_tmp = val_tmp + 1
|
||||
|
||||
RetObject.append(mycommon.JSONEncoder().encode(user))
|
||||
|
||||
|
||||
#print(" #### RetObject = ", RetObject)
|
||||
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 données de l'unite d'enseignement "
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Recuperer la liste des UE d'une formation donnée
|
||||
"""
|
||||
def Get_List_Unite_Enseignement_Of_Given_Class(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', 'class_id', 'class_internal_url']
|
||||
|
||||
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',]
|
||||
|
||||
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
|
||||
|
||||
|
||||
RetObject = []
|
||||
val_tmp = 0
|
||||
|
||||
if( "class_id" in diction.keys() and diction['class_id']):
|
||||
qry = {"partner_owner_recid":str(my_partner['recid']), 'valide':'1', 'locked':'0', '_id':ObjectId(str(diction['class_id']))}
|
||||
elif ( "class_internal_url" in diction.keys() and diction['class_internal_url'] ):
|
||||
qry = {"partner_owner_recid": str(my_partner['recid']), 'valide': '1', 'locked': '0',
|
||||
'internal_url': str(diction['class_internal_url'])}
|
||||
|
||||
|
||||
for New_retVal in MYSY_GV.dbname['myclass'].find(qry).sort([("_id", pymongo.DESCENDING), ]):
|
||||
if( "list_unite_enseignement" in New_retVal.keys() ):
|
||||
for local_val in New_retVal['list_unite_enseignement'] :
|
||||
|
||||
user = local_val
|
||||
user['id'] = str(val_tmp)
|
||||
val_tmp = val_tmp + 1
|
||||
|
||||
"""
|
||||
Recuperation des données associées à cette UE
|
||||
"""
|
||||
ue_data = MYSY_GV.dbname['unite_enseignement'].find_one({'partner_owner_recid':str(my_partner['recid']), 'valide':'1', 'locked':'0',
|
||||
'_id':ObjectId(str(local_val['_id']))})
|
||||
|
||||
if( ue_data ):
|
||||
for val in ue_data.keys() :
|
||||
user[str(val)] = ue_data[str(val)]
|
||||
|
||||
if (str(ue_data['duration_unite']) == "heure"):
|
||||
user['duration_concat'] = str(ue_data['duration']) + " h"
|
||||
elif (str(ue_data['duration_unite']) == "jour"):
|
||||
user['duration_concat'] = str(ue_data['duration']) + " j"
|
||||
elif (str(ue_data['duration_unite']) == "semaine"):
|
||||
user['duration_concat'] = str(ue_data['duration']) + " s"
|
||||
elif (str(ue_data['duration_unite']) == "mois"):
|
||||
user['duration_concat'] = str(ue_data['duration']) + " m"
|
||||
elif (str(ue_data['duration_unite']) == "annee"):
|
||||
user['duration_concat'] = str(ue_data['duration']) + " a"
|
||||
else:
|
||||
user['duration_concat'] = str(ue_data['duration']) + " ?"
|
||||
|
||||
|
||||
|
||||
RetObject.append(mycommon.JSONEncoder().encode(user))
|
||||
|
||||
|
||||
#print(" #### RetObject = ", RetObject)
|
||||
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 la liste des unites d'enseignement de la formation "
|
||||
|
Loading…
Reference in New Issue