26/02/26 - 19h30

Signed-off-by: Cherif <cbalde@mysy-training.com>
master_Elyos_FI
Cherif 2026-02-26 19:00:28 +01:00
parent 33c25f47eb
commit f0f3759f78
13 changed files with 2985 additions and 72662 deletions

View File

@ -4,12 +4,20 @@
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="24/02/26 - 19h30">
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="25/02/26 - 19h30">
<change afterPath="$PROJECT_DIR$/domaine_competence_pedagogique.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Inscription_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/Inscription_mgt.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Log/log_file.log" beforeDir="false" afterPath="$PROJECT_DIR$/Log/log_file.log" afterDir="false" />
<change beforePath="$PROJECT_DIR$/partner_invoice.py" beforeDir="false" afterPath="$PROJECT_DIR$/partner_invoice.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/partner_order.py" beforeDir="false" afterPath="$PROJECT_DIR$/partner_order.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Session_Formation.py" beforeDir="false" afterPath="$PROJECT_DIR$/Session_Formation.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/bloc_competence.py" beforeDir="false" afterPath="$PROJECT_DIR$/bloc_competence.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/domaine_formation_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/domaine_formation_mgt.py" 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$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/note_evaluation_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/note_evaluation_mgt.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/survey_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/survey_mgt.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/tools_cherif/tools_cherif.py" beforeDir="false" afterPath="$PROJECT_DIR$/tools_cherif/tools_cherif.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/unite_enseignement_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/unite_enseignement_mgt.py" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -453,7 +461,7 @@
<option name="project" value="LOCAL" />
<updated>1747251650255</updated>
</task>
<option name="localTasksCounter" value="539" />
<option name="localTasksCounter" value="540" />
<servers />
</component>
<component name="Vcs.Log.Tabs.Properties">
@ -495,7 +503,6 @@
</option>
</component>
<component name="VcsManagerConfiguration">
<MESSAGE value="15/11/2025 - 22h30" />
<MESSAGE value="16/11/25 - 16h30" />
<MESSAGE value="23/11/25 - 21h30" />
<MESSAGE value="23/11/25 - 21h30dd" />
@ -520,6 +527,7 @@
<MESSAGE value="21/02/26 - 20h" />
<MESSAGE value="22/02/26 - 20h" />
<MESSAGE value="24/02/26 - 19h30" />
<option name="LAST_COMMIT_MESSAGE" value="24/02/26 - 19h30" />
<MESSAGE value="25/02/26 - 19h30" />
<option name="LAST_COMMIT_MESSAGE" value="25/02/26 - 19h30" />
</component>
</project>

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -1493,14 +1493,12 @@ def Get_Partner_Session_Ftion_Reduice_Fields(diction):
RetObject = []
val_tmp = 0
print("## qrty = ", { "$and" : [ {'partner_owner_recid':str(my_partner['recid']),
'valide':'1',},filt_scope_class_id, filt_scope_session_id, filt_archive, filt_type_session, filt_class_id]})
for retval in MYSY_GV.dbname['session_formation'].find({ "$and" : [ {'partner_owner_recid':str(my_partner['recid']),
'valide':'1',},filt_scope_class_id, filt_scope_session_id, filt_archive, filt_type_session, filt_class_id]},
{'_id':1, 'code_session':1, 'titre':1,
'class_internal_url':1, 'date_debut':1, 'class_id':1,
'date_fin':1}):
'date_fin':1}).sort([("_id", pymongo.ASCENDING), ]):
user = retval
user['id'] = str(val_tmp)
@ -15937,7 +15935,7 @@ def Send_Email_request_presinscription_data_validation(diction):
class_internal_url = ""
for session_id_data in MYSY_GV.dbname['session_formation'].find(
{'_id': ObjectId(str(diction['session_id'])), 'partner_owner_recid': str(diction['partner_recid']),
'valide': '1', }):
'valide': '1', }).sort([("_id", pymongo.ASCENDING), ]):
if (session_id_data is None):
mycommon.myprint(

View File

@ -5,6 +5,7 @@ Ce document permet de gerer les blocs de compétence
- description
- commentaire
- Liste des Poles d'activité
- Liste des domaines de compétence
- Liste UE :
==> A chaque UE on associe la compétence validé
@ -121,7 +122,9 @@ def Add_bloc_competence(diction):
mydata['valide'] = "1"
mydata['locked'] = "0"
mydata['tab_pole_activite'] = []
mydata['tab_domaine_competence'] = []
mydata['tab_ue'] = []
mydata['tab_ue_domaine_competence'] = []
inserted_id = MYSY_GV.dbname['bloc_competence'].insert_one(mydata).inserted_id
@ -391,14 +394,42 @@ def Get_Given_bloc_competence(diction):
tab_pole_activite_with_code.append(tache_pedago_data)
ss = sorted(tab_pole_activite_with_code, key=itemgetter('rang'))
user['tab_pole_activite_with_code'] = tab_pole_activite_with_code
tab_domaine_competence_with_code = []
if ("tab_domaine_competence" in New_retVal.keys()):
for domaine_compet in New_retVal['tab_domaine_competence']:
domaine_compet_data = MYSY_GV.dbname['domaine_competence_pedagogique'].find_one(
{'_id': ObjectId(str(domaine_compet['_id'])), 'valide': '1'},
{'_id': 1, 'code': 1, 'description': 1, })
if ("rang" in domaine_compet.keys()):
domaine_compet_data['rang'] = str(domaine_compet['rang'])
else:
domaine_compet_data['rang'] = "99"
if ("obligatoire" in domaine_compet.keys()):
domaine_compet_data['obligatoire'] = str(domaine_compet['obligatoire'])
else:
domaine_compet_data['obligatoire'] = "0"
tab_domaine_competence_with_code.append(domaine_compet_data)
ss = sorted(tab_domaine_competence_with_code, key=itemgetter('rang'))
user['tab_domaine_competence_with_code'] = tab_domaine_competence_with_code
tab_ue_competence_with_code = []
cpt_local_tab_ue_competence = 0
if ("tab_ue" in New_retVal.keys()):
for ue_competence in New_retVal['tab_ue']:
if ("competence_id" in ue_competence.keys() and
# Gestion d'une simple compétence
if( "type_association" in ue_competence.keys() and ue_competence['type_association'] == "0" and "competence_id" in ue_competence.keys() and
ue_competence['competence_id'] and
"ue_id" in ue_competence.keys() and
"mysy_single_field" in ue_competence.keys()):
@ -423,6 +454,49 @@ def Get_Given_bloc_competence(diction):
local_node['competence_code'] = str(local_competence_data['code'])
local_node['competence_description'] = str(local_competence_data['description'])
local_node['domaine_competence_id'] = ""
local_node['domaine_competence_code'] = ""
local_node['domaine_competence_description'] = ""
local_node['type_association'] = str(ue_competence['type_association'])
local_node['creation_date'] = str(ue_competence['creation_date'])
tab_ue_competence_with_code.append(local_node)
# Gestion d'un domaine de compétence
if ("type_association" in ue_competence.keys() and ue_competence[
'type_association'] == "1" and "domaine_competence_id" in ue_competence.keys() and ue_competence['domaine_competence_id'] and
"ue_id" in ue_competence.keys() and
"mysy_single_field" in ue_competence.keys()):
local_domaine_competence_data = MYSY_GV.dbname['domaine_competence_pedagogique'].find_one(
{'_id': ObjectId(str(ue_competence['domaine_competence_id'])),
'partner_owner_recid': str(my_partner['recid'])})
local_ue_data = MYSY_GV.dbname['unite_enseignement'].find_one(
{'_id': ObjectId(str(ue_competence['ue_id'])),
'partner_owner_recid': str(my_partner['recid'])})
local_node = {}
local_node['id'] = str(cpt_local_tab_ue_competence)
cpt_local_tab_ue_competence = cpt_local_tab_ue_competence + 1
local_node['mysy_single_field'] = str(ue_competence['mysy_single_field'])
local_node['ue_id'] = str(local_ue_data['_id'])
local_node['ue_code'] = str(local_ue_data['code'])
local_node['ue_titre'] = str(local_ue_data['titre'])
local_node['competence_id'] = ""
local_node['competence_code'] = ""
local_node['competence_description'] = ""
local_node['domaine_competence_id'] = str(local_domaine_competence_data['_id'])
local_node['domaine_competence_code'] = str(local_domaine_competence_data['code'])
local_node['domaine_competence_description'] = str(local_domaine_competence_data['description'])
local_node['type_association'] = str(ue_competence['type_association'])
local_node['creation_date'] = str(ue_competence['creation_date'])
tab_ue_competence_with_code.append(local_node)
@ -432,7 +506,7 @@ def Get_Given_bloc_competence(diction):
user['id'] = str(val_tmp)
val_tmp = val_tmp + 1
print("user = ", user)
#print("user = ", user)
RetObject.append(mycommon.JSONEncoder().encode(user))
@ -788,7 +862,12 @@ def Add_Update_tab_UE_And_Competence_To_Bloc_Competence(diction):
"""
Verification des input acceptés
"""
field_list = ['token', 'bloc_competence_id', 'ue_id', 'competence_id',]
field_list = ['token', 'bloc_competence_id', 'ue_id', 'competence_id', 'domaine_competence_id', 'type_association']
"""
type_association = "1" => association avec un domaine de compétence
type_association = "0" => association avec une compétence
"""
incom_keys = diction.keys()
for val in incom_keys:
@ -800,7 +879,7 @@ def Add_Update_tab_UE_And_Competence_To_Bloc_Competence(diction):
"""
Verification des champs obligatoires
"""
field_list_obligatoire = ['token', 'bloc_competence_id', 'ue_id', 'competence_id', ]
field_list_obligatoire = ['token', 'bloc_competence_id', 'ue_id', 'competence_id', 'domaine_competence_id', 'type_association' ]
for val in field_list_obligatoire:
if val not in diction:
@ -822,122 +901,248 @@ def Add_Update_tab_UE_And_Competence_To_Bloc_Competence(diction):
return local_status, my_partner
"""
Verifier la validité de bloc_competence_id
Traitement d'un association avec compétence
"""
is_valide_activite = MYSY_GV.dbname['bloc_competence'].count_documents({'_id':ObjectId(diction['bloc_competence_id']),
'valide':'1',
'locked':'0',
'partner_owner_recid':str(my_partner['recid'])})
if( diction['type_association'] == "0"):
if( is_valide_activite != 1):
mycommon.myprint(
str(inspect.stack()[0][
3]) + " L'identifiant du bloc de compétence est invalide ")
return False, " L'identifiant du bloc de compétence est invalide "
"""
Verifier la validité d'ue
"""
is_valide_ue = MYSY_GV.dbname['unite_enseignement'].count_documents({'_id':ObjectId(str(diction['ue_id'])),
'valide':'1',
'locked':'0',
'partner_owner_recid':str(my_partner['recid'])})
if( is_valide_ue != 1):
mycommon.myprint(
str(inspect.stack()[0][
3]) + " L'identifiant de l'unité d'enseignement "+str(diction['ue_id'])+" est invalide ")
return False, " L'identifiant de l'unité d'enseignement "+str(diction['ue_id'])+" est invalide "
"""
Verifier la validité de la compétence
"""
is_valide_competence = MYSY_GV.dbname['competence_pedagogique'].count_documents({'_id': ObjectId(str(diction['competence_id'])),
'valide': '1',
'locked': '0',
'partner_owner_recid': str(
my_partner['recid'])})
if (is_valide_competence != 1):
mycommon.myprint(
str(inspect.stack()[0][
3]) + " L'identifiant de la compétence pédagogique " + str(diction['competence_id']) + " est invalide ")
return False, " L'identifiant de la compétence pédagogique " + str(diction['competence_id']) + " est invalide "
tab_ue = []
tab_ue.append(str(diction['ue_id']))
for local_eu_id in tab_ue:
local_mysy_single_field = str(diction['competence_id']) + "_" + str(local_eu_id)
Verifier la validité de bloc_competence_id
"""
Si local_mysy_single_field existe dans le bloc de compétence alors on fait un update,
si non on fait une insertion
is_valide_activite = MYSY_GV.dbname['bloc_competence'].count_documents({'_id':ObjectId(diction['bloc_competence_id']),
'valide':'1',
'locked':'0',
'partner_owner_recid':str(my_partner['recid'])})
if( is_valide_activite != 1):
mycommon.myprint(
str(inspect.stack()[0][
3]) + " L'identifiant du bloc de compétence est invalide ")
return False, " L'identifiant du bloc de compétence est invalide "
"""
is_mysy_single_field_existe_in_bloc_competence = MYSY_GV.dbname['bloc_competence'].count_documents({'_id': ObjectId(str(diction['bloc_competence_id'])),
'valide': '1',
'partner_owner_recid': str(my_partner['recid']),
'tab_ue.mysy_single_field': str(local_mysy_single_field)
})
Verifier la validité d'ue
"""
is_valide_ue = MYSY_GV.dbname['unite_enseignement'].count_documents({'_id':ObjectId(str(diction['ue_id'])),
'valide':'1',
'locked':'0',
'partner_owner_recid':str(my_partner['recid'])})
if( is_mysy_single_field_existe_in_bloc_competence == 1):
print(" OUII existe, donc update")
update = MYSY_GV.dbname['bloc_competence'].update_one({'_id': ObjectId(str(diction['bloc_competence_id'])),
'valide': '1',
'partner_owner_recid': str(my_partner['recid']),
'tab_ue.mysy_single_field': str(local_mysy_single_field)
},
{'$set':
{
'tab_ue.$[xxx].update_date': str( datetime.now()),
'tab_ue.$[xxx].update_by': str(my_partner['_id']),
}
},
upsert=False,
array_filters=[
{"xxx.mysy_single_field": str(local_mysy_single_field)},
]
)
if( is_valide_ue != 1):
mycommon.myprint(
str(inspect.stack()[0][
3]) + " L'identifiant de l'unité d'enseignement "+str(diction['ue_id'])+" est invalide ")
return False, " L'identifiant de l'unité d'enseignement "+str(diction['ue_id'])+" est invalide "
elif( is_mysy_single_field_existe_in_bloc_competence == 0):
print(" NOOO existe, donc insert")
new_data = {}
"""
Verifier la validité de la compétence
"""
is_valide_competence = MYSY_GV.dbname['competence_pedagogique'].count_documents({'_id': ObjectId(str(diction['competence_id'])),
'valide': '1',
'locked': '0',
'partner_owner_recid': str(
my_partner['recid'])})
new_data['ue_id'] = str(diction['ue_id'])
new_data['competence_id'] = str(diction['competence_id'])
new_data['valide'] = "1"
new_data['creation_by'] = str(my_partner['_id'])
new_data['creation_date'] = str(datetime.now())
new_data['locked'] = "0"
new_data['mysy_single_field'] = str(local_mysy_single_field)
if (is_valide_competence != 1):
mycommon.myprint(
str(inspect.stack()[0][
3]) + " L'identifiant de la compétence pédagogique " + str(diction['competence_id']) + " est invalide ")
return False, " L'identifiant de la compétence pédagogique " + str(diction['competence_id']) + " est invalide "
tab_ue = []
tab_ue.append(str(diction['ue_id']))
insert = MYSY_GV.dbname['bloc_competence'].update_one({'_id': ObjectId(str(diction['bloc_competence_id'])),
'valide': '1',
'partner_owner_recid': str(my_partner['recid']),
},
for local_eu_id in tab_ue:
{
'$push': {
"tab_ue": {
'$each': [new_data]
local_mysy_single_field = str(diction['competence_id']) + "_" + str(local_eu_id)
"""
Si local_mysy_single_field existe dans le bloc de compétence alors on fait un update,
si non on fait une insertion
"""
is_mysy_single_field_existe_in_bloc_competence = MYSY_GV.dbname['bloc_competence'].count_documents({'_id': ObjectId(str(diction['bloc_competence_id'])),
'valide': '1',
'partner_owner_recid': str(my_partner['recid']),
'tab_ue.mysy_single_field': str(local_mysy_single_field)
})
if( is_mysy_single_field_existe_in_bloc_competence == 1):
print(" OUII existe, donc update")
update = MYSY_GV.dbname['bloc_competence'].update_one({'_id': ObjectId(str(diction['bloc_competence_id'])),
'valide': '1',
'partner_owner_recid': str(my_partner['recid']),
'tab_ue.mysy_single_field': str(local_mysy_single_field)
},
{'$set':
{
'tab_ue.$[xxx].update_date': str( datetime.now()),
'tab_ue.$[xxx].update_by': str(my_partner['_id']),
}
}
},
},
upsert=False,
array_filters=[
{"xxx.mysy_single_field": str(local_mysy_single_field)},
]
)
)
elif( is_mysy_single_field_existe_in_bloc_competence == 0):
print(" NOOO existe, donc insert")
new_data = {}
new_data['ue_id'] = str(diction['ue_id'])
new_data['competence_id'] = str(diction['competence_id'])
new_data['domaine_competence_id'] = ""
new_data['type_association'] = str(diction['type_association'])
new_data['valide'] = "1"
new_data['creation_by'] = str(my_partner['_id'])
new_data['creation_date'] = str(datetime.now())
new_data['locked'] = "0"
new_data['mysy_single_field'] = str(local_mysy_single_field)
insert = MYSY_GV.dbname['bloc_competence'].update_one({'_id': ObjectId(str(diction['bloc_competence_id'])),
'valide': '1',
'partner_owner_recid': str(my_partner['recid']),
},
{
'$push': {
"tab_ue": {
'$each': [new_data]
}
}
},
)
elif (diction['type_association'] == "1"):
"""
Traitement d'un association avec un domaine de compétence
"""
"""
Verifier la validité de bloc_competence_id
"""
is_valide_activite = MYSY_GV.dbname['bloc_competence'].count_documents(
{'_id': ObjectId(diction['bloc_competence_id']),
'valide': '1',
'locked': '0',
'partner_owner_recid': str(my_partner['recid'])})
if (is_valide_activite != 1):
mycommon.myprint(
str(inspect.stack()[0][
3]) + " L'identifiant du bloc de compétence est invalide ")
return False, " L'identifiant du bloc de compétence est invalide "
"""
Verifier la validité d'ue
"""
is_valide_ue = MYSY_GV.dbname['unite_enseignement'].count_documents({'_id': ObjectId(str(diction['ue_id'])),
'valide': '1',
'locked': '0',
'partner_owner_recid': str(
my_partner['recid'])})
if (is_valide_ue != 1):
mycommon.myprint(
str(inspect.stack()[0][
3]) + " L'identifiant de l'unité d'enseignement " + str(
diction['ue_id']) + " est invalide ")
return False, " L'identifiant de l'unité d'enseignement " + str(diction['ue_id']) + " est invalide "
"""
Verifier la validité de du domaine de compétence
"""
is_valide_competence = MYSY_GV.dbname['domaine_competence_pedagogique'].count_documents(
{'_id': ObjectId(str(diction['domaine_competence_id'])),
'valide': '1',
'locked': '0',
'partner_owner_recid': str(
my_partner['recid'])})
if (is_valide_competence != 1):
mycommon.myprint(
str(inspect.stack()[0][
3]) + " L'identifiant du domaine de compétence pédagogique " + str(
diction['domaine_competence_id']) + " est invalide ")
return False, " L'identifiant du domaine de compétence pédagogique " + str(
diction['domaine_competence_id']) + " est invalide "
tab_ue = []
tab_ue.append(str(diction['ue_id']))
for local_eu_id in tab_ue:
local_mysy_single_field = str(diction['domaine_competence_id']) + "_" + str(local_eu_id)
"""
Si local_mysy_single_field existe dans le bloc de compétence alors on fait un update,
si non on fait une insertion
"""
is_mysy_single_field_existe_in_bloc_competence = MYSY_GV.dbname['bloc_competence'].count_documents(
{'_id': ObjectId(str(diction['bloc_competence_id'])),
'valide': '1',
'partner_owner_recid': str(my_partner['recid']),
'tab_ue.mysy_single_field': str(local_mysy_single_field)
})
if (is_mysy_single_field_existe_in_bloc_competence == 1):
print(" OUII existe, donc update")
update = MYSY_GV.dbname['bloc_competence'].update_one(
{'_id': ObjectId(str(diction['bloc_competence_id'])),
'valide': '1',
'partner_owner_recid': str(my_partner['recid']),
'tab_ue.mysy_single_field': str(local_mysy_single_field)
},
{'$set':
{
'tab_ue.$[xxx].update_date': str(datetime.now()),
'tab_ue.$[xxx].update_by': str(my_partner['_id']),
}
},
upsert=False,
array_filters=[
{"xxx.mysy_single_field": str(local_mysy_single_field)},
]
)
elif (is_mysy_single_field_existe_in_bloc_competence == 0):
print(" NOOO existe, donc insert")
new_data = {}
new_data['ue_id'] = str(diction['ue_id'])
new_data['type_association'] = str(diction['type_association'])
new_data['competence_id'] = ""
new_data['domaine_competence_id'] = str(diction['domaine_competence_id'])
new_data['valide'] = "1"
new_data['creation_by'] = str(my_partner['_id'])
new_data['creation_date'] = str(datetime.now())
new_data['locked'] = "0"
new_data['mysy_single_field'] = str(local_mysy_single_field)
insert = MYSY_GV.dbname['bloc_competence'].update_one(
{'_id': ObjectId(str(diction['bloc_competence_id'])),
'valide': '1',
'partner_owner_recid': str(my_partner['recid']),
},
{
'$push': {
"tab_ue": {
'$each': [new_data]
}
}
},
)
return True, " La mise à jour a été correctement faite "
@ -1047,3 +1252,282 @@ def Delete_UE_From_Bloc_Competence(diction):
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'unité d'enseignement "
## ---
"""
Ajouter un domaine de compétence pédagogique à un bloc de compétence
"""
def Add_Update_tab_Domaine_Competence_To_Bloc_Competence(diction):
try:
diction = mycommon.strip_dictionary(diction)
"""
Verification des input acceptés
"""
field_list = ['token', 'bloc_competence_id', 'domaine_competence_id', 'rang', ]
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', 'bloc_competence_id', 'domaine_competence_id', 'rang', ]
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 la liste des arguments ")
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
if ("rang" in diction.keys()):
local_status, local_note_max = mycommon.IsInt(str(diction['rang']).strip())
if (local_status is False):
mycommon.myprint(
" Le rang doit être un nombre entier ")
return False, " Le rang doit être un nombre entier"
"""
Verifier la validité de domaine_competence_id
"""
is_valide_dom_comp = MYSY_GV.dbname['domaine_competence_pedagogique'].count_documents({'_id':ObjectId(diction['domaine_competence_id']),
'valide':'1',
'locked':'0',
'partner_owner_recid':str(my_partner['recid'])})
if( is_valide_dom_comp != 1):
mycommon.myprint(
str(inspect.stack()[0][
3]) + " L'identifiant du domaine de compétence est invalide ")
return False, " L'identifiant du domaine de compétence est invalide "
"""
Verifier la validité de bloc_competence_id
"""
is_valide_bloc_compet = MYSY_GV.dbname['bloc_competence'].count_documents({'_id':ObjectId(str(diction['bloc_competence_id'])),
'valide':'1',
'locked':'0',
'partner_owner_recid':str(my_partner['recid'])})
if( is_valide_bloc_compet != 1):
mycommon.myprint(
str(inspect.stack()[0][
3]) + " L'identifiant du bloc de compétence "+str(diction['bloc_competence_id'])+" est invalide ")
return False, " L'identifiant du bloc de compétence "+str(diction['bloc_competence_id'])+" est invalide "
tab_domaine_competence = []
tab_domaine_competence.append(str(diction['domaine_competence_id']))
for dom_comp_id in tab_domaine_competence:
"""
Si le pole existe dans le bloc de compétence alors on fait un update,
si non on fait une insertion
"""
is_dom_comp_id_existe_in_bloc_competence = MYSY_GV.dbname['bloc_competence'].count_documents({'_id': ObjectId(str(diction['bloc_competence_id'])),
'valide': '1',
'partner_owner_recid': str(my_partner['recid']),
'tab_domaine_competence._id': ObjectId(str(diction['domaine_competence_id']))
})
if( is_dom_comp_id_existe_in_bloc_competence == 1):
print(" OUII existe, donc update")
update = MYSY_GV.dbname['bloc_competence'].update_one({'_id': ObjectId(str(diction['bloc_competence_id'])),
'valide': '1',
'partner_owner_recid': str(my_partner['recid']),
'tab_domaine_competence._id': ObjectId(str(diction['domaine_competence_id']))
},
{'$set':
{
'tab_domaine_competence.$[xxx].rang': str( diction['rang']),
'tab_domaine_competence.$[xxx].update_date': str( datetime.now()),
'tab_domaine_competence.$[xxx].update_by': str(my_partner['_id']),
}
},
upsert=False,
array_filters=[
{"xxx._id": ObjectId(str(dom_comp_id))},
]
)
elif( is_dom_comp_id_existe_in_bloc_competence == 0):
print(" NOOO existe, donc insert")
new_data = {}
new_data['_id'] = ObjectId(str(dom_comp_id))
new_data['rang'] = str(diction['rang'])
new_data['valide'] = "1"
new_data['creation_by'] = str(my_partner['_id'])
new_data['creation_date'] = str(datetime.now())
new_data['locked'] = "0"
insert = MYSY_GV.dbname['bloc_competence'].update_one({'_id': ObjectId(str(diction['bloc_competence_id'])),
'valide': '1',
'partner_owner_recid': str(my_partner['recid']),
},
{
'$push': {
"tab_domaine_competence": {
'$each': [new_data]
}
}
},
)
return True, " La mise à jour a été correctement faite "
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 faire la mise à jour "
"""
Supprimer un domaine de compétence pédagogique d'un bloc de compétence
"""
def Delete_Domaine_Competence_From_Bloc_Competence(diction):
try:
diction = mycommon.strip_dictionary(diction)
"""
Verification des input acceptés
"""
field_list = ['token', 'bloc_competence_id', 'domaine_competence_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', 'bloc_competence_id', 'domaine_competence_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 la liste des arguments ")
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 la validité du bloc de compétence
"""
is_valide_bloc_compet = MYSY_GV.dbname['bloc_competence'].count_documents({'_id':ObjectId(diction['bloc_competence_id']),
'valide':'1',
'locked':'0',
'partner_owner_recid':str(my_partner['recid'])})
if( is_valide_bloc_compet != 1):
mycommon.myprint(
str(inspect.stack()[0][
3]) + " L'identifiant du bloc de compétence est invalide ")
return False, " L'identifiant du bloc de compétence est invalide "
"""
Verifier la validité de domaine_competence_id
"""
is_valide_dom_comp = MYSY_GV.dbname['domaine_competence_pedagogique'].count_documents({'_id':ObjectId(str(diction['domaine_competence_id'])),
'valide':'1',
'locked':'0',
'partner_owner_recid':str(my_partner['recid'])})
if( is_valide_dom_comp != 1):
mycommon.myprint(
str(inspect.stack()[0][
3]) + " L'identifiant du domaine de compétence "+str(diction['domaine_competence_id'])+" est invalide ")
return False, " L'identifiant du domaine de compétence "+str(diction['domaine_competence_id'])+" est invalide "
tab_domaine_competence = []
tab_domaine_competence.append(str(diction['domaine_competence_id']))
for dom_comp_id in tab_domaine_competence:
"""
Si la tache existe dans tab_pole_activite, alors on fait un update,
si non on fait une insertion
"""
is_dom_comp_activite_existe_in_compet = MYSY_GV.dbname['bloc_competence'].count_documents({'_id': ObjectId(str(diction['bloc_competence_id'])),
'valide': '1',
'partner_owner_recid': str(my_partner['recid']),
'tab_domaine_competence._id': ObjectId(str(dom_comp_id))
})
if( is_dom_comp_activite_existe_in_compet == 1):
print(" OUII existe, donc update")
update = MYSY_GV.dbname['bloc_competence'].update_one({'_id': ObjectId(str(diction['bloc_competence_id'])),
'valide': '1',
'partner_owner_recid': str(my_partner['recid']),
'tab_domaine_competence._id': ObjectId(str(dom_comp_id))
},
{'$pull': {"tab_domaine_competence": {"_id": ObjectId(str(dom_comp_id)) }}},
)
return True, " Le domaine de compétence a été correctement supprimé "
except Exception as e:
exc_type, exc_obj, exc_tb = sys.exc_info()
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - Line : " + str(exc_tb.tb_lineno))
return False, " Impossible de supprimer le domaine de compétence "

View File

@ -0,0 +1,713 @@
"""
Ce fichier permet de gerer les domaines de compétence pédagogique.
Par définition :
Le domaine de compétences est un regroupement cohérent de plusieurs compétences qui servent un même objectif professionnel.
Ainsi un domaine de compétence est defini par :
- code
- description
- commentaire
- tab_competence_pedagogique
"""
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
"""
Fonction d'ajout d'un domaine de compétence pedagogique
"""
def Add_domaine_competence_pedagogique(diction):
try:
diction = mycommon.strip_dictionary(diction)
"""
Verification des input acceptés
"""
field_list = ['token', 'description', 'commentaire', 'code',
]
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' ]
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 la liste des arguments ")
return False, " Les informations fournies sont incorrectes"
"""
Verification de l'identité et autorisation de l'entité qui
appelle cette API
"""
token = ""
if ("token" in diction.keys()):
if diction['token']:
token = diction['token']
local_status, my_partner = mycommon.Check_Connexion_And_Return_Partner_Data(diction)
if (local_status is not True):
return local_status, my_partner
"""
Verifier que ce code de l'activité n'est pas déjà utilisé
"""
is_competence_pedagogique_code_used = MYSY_GV.dbname['domaine_competence_pedagogique'].count_documents({'code':str(diction['code']),
'valide':'1',
'partner_owner_recid':str(my_partner['recid'])})
if( is_competence_pedagogique_code_used != 0 ):
mycommon.myprint(
str(inspect.stack()[0][
3]) + " Le code "+str(diction['code'])+" est déjà utilisé ")
return False, " Le code "+str(diction['code'])+" est déjà utilisé "
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)] = ""
mydata['creation_date'] = str(datetime.now())
mydata['creation_by'] = str(my_partner['_id'])
mydata['partner_owner_recid'] = str(my_partner['recid'])
mydata['valide'] = "1"
mydata['locked'] = "0"
mydata['tab_competence_pedagogique'] = []
inserted_id = MYSY_GV.dbname['domaine_competence_pedagogique'].insert_one(mydata).inserted_id
if (not inserted_id):
mycommon.myprint(" Impossible de créer le domaine de compétence pédagogique (2) ")
return False, " Impossible de créer le domaine de compétence pédagogique (2) "
return True, " Le domaine de compétence pédagogique a été correctement ajouté "
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 le domaine compétence pédagogique "
"""
Fonction de mise à jour d'un domaine compétence pédagogique
"""
def Update_domaine_competence_pedagogique(diction):
try:
diction = mycommon.strip_dictionary(diction)
"""
Verification des input acceptés
"""
field_list = ['token', 'description', 'domaine_competence_pedagogique_id', 'commentaire', 'code',
]
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', 'domaine_competence_pedagogique_id', 'code']
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 la liste des arguments ")
return False, " Les informations fournies sont incorrectes"
"""
Verification de l'identité et autorisation de l'entité qui
appelle cette API
"""
token = ""
if ("token" in diction.keys()):
if diction['token']:
token = diction['token']
local_status, my_partner = mycommon.Check_Connexion_And_Return_Partner_Data(diction)
if (local_status is not True):
return local_status, my_partner
"""
Verifier que le code de compétence n'est pas utilisé par une autre compétence autre que celle ci
"""
is_competence_code_used = MYSY_GV.dbname['domaine_competence_pedagogique'].count_documents({'code': str(diction['code']),
'valide': '1',
'_id':{'$ne':ObjectId(str(diction['domaine_competence_pedagogique_id']))},
'partner_owner_recid': str(
my_partner['recid'])})
if (is_competence_code_used != 0):
mycommon.myprint(
str(inspect.stack()[0][
3]) + " Le code " + str(diction['code']) + " est déjà utilisé ")
return False, " Le code " + str(diction['code']) + " est déjà utilisé "
# Verifier que la compétence existe et est valide
is_valide_competence_pedagogique_id = MYSY_GV.dbname['domaine_competence_pedagogique'].count_documents({'_id':ObjectId(str(diction['domaine_competence_pedagogique_id'])),
'valide':'1',
'locked':'0',
'partner_owner_recid':str(my_partner['recid'])})
if( is_valide_competence_pedagogique_id != 1):
mycommon.myprint(
str(inspect.stack()[0][3]) + " L'identifiant du domaine de compétence est invalide ")
return False, " L'identifiant du domaine de compétence est invalide "
mydata = {}
mydata = diction
del mydata['token']
mydata['update_date'] = str(datetime.now())
mydata['update_by'] = str(my_partner['_id'])
result = MYSY_GV.dbname['domaine_competence_pedagogique'].find_one_and_update(
{'_id':ObjectId(str(diction['domaine_competence_pedagogique_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 le domaine de compétence pédagogique (2) ")
return False, " Impossible de mettre à jour le domaine de compétence pédagogique (2) "
return True, " Le domaine de compétence pédagogique a été correctement mis à 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 le domaine de compétence pédagogique "
"""
Recuperer la liste des domaines de compétence pedagogique d'un partenaire, sans filtres
"""
def Get_domaine_competence_pedagogique_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 la liste des arguments ")
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['domaine_competence_pedagogique'].find(qry).sort([("_id", pymongo.DESCENDING), ]):
user = New_retVal
if( "code" not in user.keys() ):
user["code"] = "--"
user['id'] = str(val_tmp)
val_tmp = val_tmp + 1
RetObject.append(mycommon.JSONEncoder().encode(user))
return True, RetObject
except Exception as e:
exc_type, exc_obj, exc_tb = sys.exc_info()
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - Line : " + str(exc_tb.tb_lineno))
return False, " Impossible de récupérer la liste des domaines de compétence pédagogique "
"""
Recuperer les données d'un domaine compétence pedagogique donnée
"""
def Get_Given_domaine_competence_pedagogique(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',]
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 la liste des arguments ")
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['domaine_competence_pedagogique'].find(qry):
user = New_retVal
if( "code" not in user.keys() ):
user["code"] = "--"
tab_competence_pedagogique_with_code = []
if ("tab_competence_pedagogique" in New_retVal.keys()):
for tab_competence_pedagogique_data in New_retVal['tab_competence_pedagogique']:
competence_pedago_data = MYSY_GV.dbname['competence_pedagogique'].find_one(
{'_id': ObjectId(str(tab_competence_pedagogique_data['_id'])), 'valide': '1'},
{'_id': 1, 'code': 1, 'description': 1,})
competence_pedago_data['rang'] = tab_competence_pedagogique_data['rang']
tab_competence_pedagogique_with_code.append(competence_pedago_data)
print("tab_competence_pedagogique_with_code = ", tab_competence_pedagogique_with_code)
user['tab_competence_pedagogique_with_code'] = tab_competence_pedagogique_with_code
user['id'] = str(val_tmp)
val_tmp = val_tmp + 1
RetObject.append(mycommon.JSONEncoder().encode(user))
return True, RetObject
except Exception as e:
exc_type, exc_obj, exc_tb = sys.exc_info()
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - Line : " + str(exc_tb.tb_lineno))
return False, " Impossible de récupérer la liste des domaines de compétences pédagogiques "
"""
Suppression d'un domaine de compétence pedagogique
"""
def Delete_Given_domaine_competence_pedagogique(diction):
try:
diction = mycommon.strip_dictionary(diction)
"""
Verification des input acceptés
"""
field_list = ['token', 'domaine_competence_pedagogique_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', 'domaine_competence_pedagogique_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 la liste des arguments ")
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
qry = {'_id':ObjectId(str(diction['domaine_competence_pedagogique_id'])), 'partner_owner_recid':str(my_partner['recid'])}
ret_del_competence = MYSY_GV.dbname['domaine_competence_pedagogique'].delete_many(qry)
return True, "la compétence pédagogique 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 le domaine de compétence pédagogique "
"""
Ajouter une competence pédagogique à un domaine de compétence
"""
def Add_Update_tab_competence_pedago_With_competence_pedago(diction):
try:
diction = mycommon.strip_dictionary(diction)
"""
Verification des input acceptés
"""
field_list = ['token', 'competence_id', 'domaine_competence_id', 'rang', ]
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', 'competence_id', 'domaine_competence_id', 'rang',]
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 la liste des arguments ")
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
if ("rang" in diction.keys()):
local_status, local_note_max = mycommon.IsInt(str(diction['rang']).strip())
if (local_status is False):
mycommon.myprint(
" Le rang doit être un nombre entier ")
return False, " Le rang doit être un nombre entier"
"""
Verifier la validité du domaine de compétence
"""
is_valide_domaine_compet = MYSY_GV.dbname['domaine_competence_pedagogique'].count_documents({'_id':ObjectId(diction['domaine_competence_id']),
'valide':'1',
'locked':'0',
'partner_owner_recid':str(my_partner['recid'])})
if( is_valide_domaine_compet != 1):
mycommon.myprint(
str(inspect.stack()[0][
3]) + " L'identifiant du domaine de compétence est invalide ")
return False, " L'identifiant du domaine de compétence est invalide "
tab_competence_pedagogique = []
tab_competence_pedagogique.append(str(diction['competence_id']))
for competence_id in tab_competence_pedagogique:
"""
Si la competence_id existe dans tab_competence_pedagogique, alors on fait un update,
si non on fait une insertion
"""
is_compet_existe_in_tab_compte = MYSY_GV.dbname['domaine_competence_pedagogique'].count_documents({'_id': ObjectId(str(diction['domaine_competence_id'])),
'valide': '1',
'partner_owner_recid': str(my_partner['recid']),
'tab_competence_pedagogique._id': ObjectId(str(competence_id))
})
if( is_compet_existe_in_tab_compte == 1):
print(" OUII existe, donc update")
update = MYSY_GV.dbname['domaine_competence_pedagogique'].update_one({'_id': ObjectId(str(diction['domaine_competence_id'])),
'valide': '1',
'locked':'0',
'partner_owner_recid': str(my_partner['recid']),
'tab_competence_pedagogique._id': ObjectId(str(competence_id))
},
{'$set':
{
'tab_competence_pedagogique.$[xxx].rang': str( diction['rang']),
'tab_competence_pedagogique.$[xxx].update_date': str( datetime.now()),
'tab_competence_pedagogique.$[xxx].update_by': str(my_partner['_id']),
}
},
upsert=False,
array_filters=[
{"xxx._id": ObjectId(str(competence_id))},
]
)
elif( is_compet_existe_in_tab_compte == 0):
print(" NOOO existe, donc insert")
new_data = {}
new_data['_id'] = ObjectId(str(competence_id))
new_data['rang'] = str(diction['rang'])
new_data['valide'] = "1"
new_data['creation_by'] = str(my_partner['_id'])
new_data['creation_date'] = str(datetime.now())
new_data['locked'] = "0"
insert = MYSY_GV.dbname['domaine_competence_pedagogique'].update_one({'_id': ObjectId(str(diction['domaine_competence_id'])),
'valide': '1',
'locked': '0',
'partner_owner_recid': str(my_partner['recid']),
},
{
'$push': {
"tab_competence_pedagogique": {
'$each': [new_data]
}
}
},
)
return True, " La mise à jour a été correctement faite "
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 faire la mise à jour "
"""
Supprimer une competence pédagogique d'un à un domaine de compétence
"""
def Delete_competence_From_domaine_competence_pedagogique(diction):
try:
diction = mycommon.strip_dictionary(diction)
"""
Verification des input acceptés
"""
field_list = ['token', 'competence_id', 'domaine_competence_pedagogique_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', 'competence_id', 'domaine_competence_pedagogique_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 la liste des arguments ")
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 la validité du domaine de compétence
"""
is_valide_domaine_compet = MYSY_GV.dbname['domaine_competence_pedagogique'].count_documents({'_id':ObjectId(diction['domaine_competence_pedagogique_id']),
'valide':'1',
'locked':'0',
'partner_owner_recid':str(my_partner['recid'])})
if( is_valide_domaine_compet != 1):
mycommon.myprint(
str(inspect.stack()[0][
3]) + " L'identifiant du domaine de compétence est invalide ")
return False, " L'identifiant du domaine de compétence est invalide "
is_valide_competence = MYSY_GV.dbname['competence_pedagogique'].count_documents({'_id':ObjectId(str(diction['competence_id'])),
'valide':'1',
'locked':'0',
'partner_owner_recid':str(my_partner['recid'])})
if( is_valide_competence != 1):
mycommon.myprint(
str(inspect.stack()[0][
3]) + " L'identifiant de la compétence "+str(diction['competence_id'])+" est invalide ")
return False, " L'identifiant de la compétence "+str(diction['competence_id'])+" est invalide "
tab_competence_pedagogique = []
tab_competence_pedagogique.append(str(diction['competence_id']))
for competence_id in tab_competence_pedagogique:
is_competence_existe_in_domaine_compet = MYSY_GV.dbname['domaine_competence_pedagogique'].count_documents({'_id': ObjectId(str(diction['domaine_competence_pedagogique_id'])),
'valide': '1',
'partner_owner_recid': str(my_partner['recid']),
'tab_competence_pedagogique._id': ObjectId(str(competence_id ))
})
if( is_competence_existe_in_domaine_compet == 1):
print(" OUII existe, donc update")
update = MYSY_GV.dbname['domaine_competence_pedagogique'].update_one({'_id': ObjectId(str(diction['domaine_competence_pedagogique_id'])),
'valide': '1',
'partner_owner_recid': str(my_partner['recid']),
'tab_competence_pedagogique._id': ObjectId(str(competence_id))
},
{'$pull': {"tab_competence_pedagogique": {"_id": ObjectId(str(competence_id)) }}},
)
return True, " La compétence 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 la compétence "

View File

@ -10,6 +10,7 @@ et est defini par :
la clé fonctionnelle est le code
"""
import bson
import pymongo
from pymongo import MongoClient

View File

@ -699,7 +699,7 @@ Envoie de l'email d'information sur l'annulation de l'inscription
def incription_training_cancelled_mail(diction):
try:
print(" ### incription_training_cancelled_mail = "+str(diction))
#print(" ### incription_training_cancelled_mail = "+str(diction))
"""
Verification de la liste des champs obligatoires
"""
@ -779,7 +779,7 @@ def incription_training_cancelled_mail(diction):
'valide': '1', 'locked': '0',
'ref_interne': 'ANNULE_INSCRIPTION'}
print(" ### partner_document_PRE_INSCRIPTION_data_qry (cancellation) = ", partner_document_ANNULE_INSCRIPTION_data_qry)
#print(" ### partner_document_PRE_INSCRIPTION_data_qry (cancellation) = ", partner_document_ANNULE_INSCRIPTION_data_qry)
partner_document_ANNULE_INSCRIPTION_data = MYSY_GV.dbname['courrier_template'].find_one(
{'partner_owner_recid': str(diction['partner_owner_recid']),
'valide': '1', 'locked': '0', 'ref_interne': 'ANNULE_INSCRIPTION'})

139
main.py
View File

@ -112,6 +112,7 @@ import tache_pedagogique as tache_pedagogique
import pole_activite_pedagogique as pole_activite_pedagogique
import competence_pedagogique as competence_pedagogique
import bloc_competence as bloc_competence
import domaine_competence_pedagogique as domaine_competence_pedagogique
import base_document_automatic_setup as base_document_automatic_setup
@ -11077,6 +11078,21 @@ def Get_List_Unite_Enseignement_Of_Given_Class_From_Session_Id():
return jsonify(status=status, message=retval)
"""
API pour Recuperer la liste des UE d'une SESSION, donc pas toutes les ue de la formation
mais juste celles de l'UE
"""
@app.route('/myclass/api/Get_List_Unite_Enseignement_Of_Given_Session_Id/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_List_Unite_Enseignement_Of_Given_Session_Id():
# On recupere le corps (payload) de la requete
payload = mycommon.strip_dictionary (request.form.to_dict())
print(" ### Get_List_Unite_Enseignement_Of_Given_Session_Id payload = ",payload)
status, retval = unite_enseignement_mgt.Get_List_Unite_Enseignement_Of_Given_Session_Id(payload)
return jsonify(status=status, message=retval)
"""
@ -16694,6 +16710,129 @@ def Delete_UE_From_Bloc_Competence():
"""
Cette API pour Ajouter un domaine de compétence pédagogique à un bloc de compétence
"""
@app.route('/myclass/api/Add_Update_tab_Domaine_Competence_To_Bloc_Competence/', methods=['POST','GET'])
@crossdomain(origin='*')
def Add_Update_tab_Domaine_Competence_To_Bloc_Competence():
# On recupere le corps (payload) de la requete
payload = mycommon.strip_dictionary (request.form.to_dict())
print(" ### Add_Update_tab_Domaine_Competence_To_Bloc_Competence payload = ",payload)
status, retval = bloc_competence.Add_Update_tab_Domaine_Competence_To_Bloc_Competence(payload)
return jsonify(status=status, message=retval)
"""
Cette API pour Supprimer un domaine de compétence pédagogique d'un bloc de compétence
"""
@app.route('/myclass/api/Delete_Domaine_Competence_From_Bloc_Competence/', methods=['POST','GET'])
@crossdomain(origin='*')
def Delete_Domaine_Competence_From_Bloc_Competence():
# On recupere le corps (payload) de la requete
payload = mycommon.strip_dictionary (request.form.to_dict())
print(" ### Delete_Domaine_Competence_From_Bloc_Competence payload = ",payload)
status, retval = bloc_competence.Delete_Domaine_Competence_From_Bloc_Competence(payload)
return jsonify(status=status, message=retval)
"""
Cette API pour ajouter un domaine de compétence
"""
@app.route('/myclass/api/Add_domaine_competence_pedagogique/', methods=['POST','GET'])
@crossdomain(origin='*')
def Add_domaine_competence_pedagogique():
# On recupere le corps (payload) de la requete
payload = mycommon.strip_dictionary (request.form.to_dict())
print(" ### Add_domaine_competence_pedagogique payload = ",payload)
status, retval = domaine_competence_pedagogique.Add_domaine_competence_pedagogique(payload)
return jsonify(status=status, message=retval)
"""
Cette API pour mettre à jour un domaine de compétence
"""
@app.route('/myclass/api/Update_domaine_competence_pedagogique/', methods=['POST','GET'])
@crossdomain(origin='*')
def Update_domaine_competence_pedagogique():
# On recupere le corps (payload) de la requete
payload = mycommon.strip_dictionary (request.form.to_dict())
print(" ### Update_domaine_competence_pedagogique payload = ",payload)
status, retval = domaine_competence_pedagogique.Update_domaine_competence_pedagogique(payload)
return jsonify(status=status, message=retval)
"""
Cette API pour Recuperer la liste des domaines de compétence pedagogique d'un partenaire, sans filtres
"""
@app.route('/myclass/api/Get_domaine_competence_pedagogique_no_filter/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_domaine_competence_pedagogique_no_filter():
# On recupere le corps (payload) de la requete
payload = mycommon.strip_dictionary (request.form.to_dict())
print(" ### Get_domaine_competence_pedagogique_no_filter payload = ",payload)
status, retval = domaine_competence_pedagogique.Get_domaine_competence_pedagogique_no_filter(payload)
return jsonify(status=status, message=retval)
"""
Cette API pour Recuperer les données d'un domaine compétence pedagogique donnée
"""
@app.route('/myclass/api/Get_Given_domaine_competence_pedagogique/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_Given_domaine_competence_pedagogique():
# On recupere le corps (payload) de la requete
payload = mycommon.strip_dictionary (request.form.to_dict())
print(" ### Get_Given_domaine_competence_pedagogique payload = ",payload)
status, retval = domaine_competence_pedagogique.Get_Given_domaine_competence_pedagogique(payload)
return jsonify(status=status, message=retval)
"""
Cette API pour Suppression d'un domaine de compétence pedagogique
"""
@app.route('/myclass/api/Delete_Given_domaine_competence_pedagogique/', methods=['POST','GET'])
@crossdomain(origin='*')
def Delete_Given_domaine_competence_pedagogique():
# On recupere le corps (payload) de la requete
payload = mycommon.strip_dictionary (request.form.to_dict())
print(" ### Delete_Given_domaine_competence_pedagogique payload = ",payload)
status, retval = domaine_competence_pedagogique.Delete_Given_domaine_competence_pedagogique(payload)
return jsonify(status=status, message=retval)
"""
Cette API pour Ajouter une competence pédagogique à un domaine de compétence
"""
@app.route('/myclass/api/Add_Update_tab_competence_pedago_With_competence_pedago/', methods=['POST','GET'])
@crossdomain(origin='*')
def Add_Update_tab_competence_pedago_With_competence_pedago():
# On recupere le corps (payload) de la requete
payload = mycommon.strip_dictionary (request.form.to_dict())
print(" ### Add_Update_tab_competence_pedago_With_competence_pedago payload = ",payload)
status, retval = domaine_competence_pedagogique.Add_Update_tab_competence_pedago_With_competence_pedago(payload)
return jsonify(status=status, message=retval)
"""
Cette API pour Supprimer une competence pédagogique d'un à un domaine de compétence
"""
@app.route('/myclass/api/Delete_competence_From_domaine_competence_pedagogique/', methods=['POST','GET'])
@crossdomain(origin='*')
def Delete_competence_From_domaine_competence_pedagogique():
# On recupere le corps (payload) de la requete
payload = mycommon.strip_dictionary (request.form.to_dict())
print(" ### Delete_competence_From_domaine_competence_pedagogique payload = ",payload)
status, retval = domaine_competence_pedagogique.Delete_competence_From_domaine_competence_pedagogique(payload)
return jsonify(status=status, message=retval)
if __name__ == '__main__':

View File

@ -4010,159 +4010,170 @@ def Import_Evaluation_Notes_mass(file=None, Folder=None, diction=None):
x = range(0, total_rows)
tab_participant_note = []
nb_valide_line = 0
for n in x:
mydata = {}
mydata['evaluation_code'] = str(df['evaluation_code'].values[n]).strip()
mydata['classe'] = str(df['classe'].values[n]).strip()
mydata['nom_apprenant'] = str(df['nom_apprenant'].values[n]).strip().lower()
mydata['email_apprenant'] = str(df['email_apprenant'].values[n]).strip().lower()
mydata['evaluation_note'] = str(df['evaluation_note'].values[n]).strip()
if (str(df['evaluation_code'].values[n]) and str(df['classe'].values[n]) and str(
df['nom_apprenant'].values[n]) and str(df['evaluation_note'].values[n])):
tmp_publie = str(df['publie'].values[n]).strip()
if (mydata['evaluation_code'] and mydata['classe'] and mydata['email_apprenant']):
if (tmp_publie not in ['0', '1', '']):
if (str(df['evaluation_code'].values[n]) != evaluation_data['code']):
mycommon.myprint(
str(inspect.stack()[0][3]) + "Ligne : " + str(
n + 2) + ": La valeur 'publié' est invalide ")
n + 2) + ": Le code de l'évaluation ne corresponds pas l'évaluation selectionnée ")
return False, "Ligne : " + str(
n + 2) + ": La valeur 'publié' est invalide. Valeurs acceptées : '0', '1', '' "
n + 2) + ": Le code de l'évaluation ne corresponds pas l'évaluation selectionnée "
mydata = {}
mydata['evaluation_code'] = str(df['evaluation_code'].values[n]).strip()
mydata['classe'] = str(df['classe'].values[n]).strip()
mydata['nom_apprenant'] = str(df['nom_apprenant'].values[n]).strip().lower()
mydata['email_apprenant'] = str(df['email_apprenant'].values[n]).strip().lower()
mydata['evaluation_note'] = str(df['evaluation_note'].values[n]).strip()
if (tmp_publie == "1"):
mydata['publie'] = "true"
else:
mydata['publie'] = "false"
tmp_publie = str(df['publie'].values[n]).strip()
mydata['email'] = str(df['email_apprenant'].values[n]).strip().lower()
if (mydata['evaluation_code'] and mydata['classe'] and mydata['email_apprenant']):
regex = r'\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,7}\b'
if (not re.fullmatch(regex, str(mydata['email_apprenant']))):
mycommon.myprint(
str(inspect.stack()[0][3]) + " Ligne : " + str(n + 2) + " : L'adresse email " + str(
mydata['email']) + " est invalide")
return False, " Ligne : " + str(n + 2) + " : L'adresse email -" + str(
mydata['email_apprenant']) + "- est invalide"
if (tmp_publie not in ['0', '1', '']):
mycommon.myprint(
str(inspect.stack()[0][3]) + "Ligne : " + str(
n + 2) + ": La valeur 'publié' est invalide ")
return False, "Ligne : " + str(
n + 2) + ": La valeur 'publié' est invalide. Valeurs acceptées : '0', '1', '' "
mydata['token'] = str(my_token)
if (tmp_publie == "1"):
mydata['publie'] = "true"
else:
mydata['publie'] = "false"
"""
Verifier la validité de evaluation_code
"""
mydata['email'] = str(df['email_apprenant'].values[n]).strip().lower()
is_valide_evaluation_code = MYSY_GV.dbname['note_evaluation'].count_documents(
{'code': {'$regex': '^' + mycommon.regex_replace_cartere(str(mydata['evaluation_code'])) + '$',
"$options": "i"},
'valide': '1',
'locked': '0',
'partner_owner_recid': str(my_partner['recid'])})
regex = r'\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,7}\b'
if (not re.fullmatch(regex, str(mydata['email_apprenant']))):
mycommon.myprint(
str(inspect.stack()[0][3]) + " Ligne : " + str(n + 2) + " : L'adresse email " + str(
mydata['email']) + " est invalide")
return False, " Ligne : " + str(n + 2) + " : L'adresse email -" + str(
mydata['email_apprenant']) + "- est invalide"
if (is_valide_evaluation_code != 1):
mycommon.myprint(
str(inspect.stack()[0][3]) + "Ligne : " + str(
n + 2) + ": Le code de l'évaluation est invalide ")
return False, "Ligne : " + str(n + 2) + ": Le code de l'évaluation est invalide ."
mydata['token'] = str(my_token)
evaluation_data = MYSY_GV.dbname['note_evaluation'].find_one(
{'code': {'$regex': '^' + mycommon.regex_replace_cartere(str(mydata['evaluation_code'])) + '$',
"$options": "i"},
'valide': '1',
'locked': '0',
'partner_owner_recid': str(my_partner['recid'])})
"""
Verifier la validité de evaluation_code
"""
"""
Verifier la validité de promotion_code
"""
is_valide_evaluation_code = MYSY_GV.dbname['note_evaluation'].count_documents(
{'code': {'$regex': '^' + mycommon.regex_replace_cartere(str(mydata['evaluation_code'])) + '$',
"$options": "i"},
'valide': '1',
'locked': '0',
'partner_owner_recid': str(my_partner['recid'])})
is_valide_promotion_code = MYSY_GV.dbname['session_formation'].count_documents(
{'code_session': {
'$regex': '^' + mycommon.regex_replace_cartere(str(mydata['classe'])) + '$',
"$options": "i"},
'valide': '1',
'partner_owner_recid': str(my_partner['recid'])})
if (is_valide_evaluation_code != 1):
mycommon.myprint(
str(inspect.stack()[0][3]) + "Ligne : " + str(
n + 2) + ": Le code de l'évaluation est invalide ")
return False, "Ligne : " + str(n + 2) + ": Le code de l'évaluation est invalide ."
if (is_valide_promotion_code != 1):
mycommon.myprint(
str(inspect.stack()[0][3]) + "Ligne : " + str(
n + 2) + ": Le code de la promotion est invalide ")
return False, "Ligne : " + str(n + 2) + ": Le code de la promotion est invalide ."
evaluation_data = MYSY_GV.dbname['note_evaluation'].find_one(
{'code': {'$regex': '^' + mycommon.regex_replace_cartere(str(mydata['evaluation_code'])) + '$',
"$options": "i"},
'valide': '1',
'locked': '0',
'partner_owner_recid': str(my_partner['recid'])})
promotion_data = MYSY_GV.dbname['session_formation'].find_one(
{'code_session': {
'$regex': '^' + mycommon.regex_replace_cartere(str(mydata['classe'])) + '$',
"$options": "i"},
'valide': '1',
'partner_owner_recid': str(my_partner['recid'])})
"""
Verifier la validité de promotion_code
"""
"""
Verifier la validité de l'inscrit
"""
is_valide_inscrit = MYSY_GV.dbname['inscription'].count_documents(
{'email': {'$regex': '^' + mycommon.regex_replace_cartere(str(mydata['email_apprenant'])) + '$',
"$options": "i"},
'session_id': str(promotion_data['_id']),
'valide': '1',
'locked': '0',
'partner_owner_recid': str(my_partner['recid'])})
is_valide_promotion_code = MYSY_GV.dbname['session_formation'].count_documents(
{'code_session': {
'$regex': '^' + mycommon.regex_replace_cartere(str(mydata['classe'])) + '$',
"$options": "i"},
'valide': '1',
'partner_owner_recid': str(my_partner['recid'])})
if (is_valide_inscrit != 1):
mycommon.myprint(
str(inspect.stack()[0][3]) + "Ligne : " + str(
n + 2) + ": L'email, le nom et le code promotion ne correspondent pas à un inscrit valide.")
return False, "Ligne : " + str(
n + 2) + ": L'email, le nom et le code promotion ne correspondent pas à un inscrit valide."
if (is_valide_promotion_code != 1):
mycommon.myprint(
str(inspect.stack()[0][3]) + "Ligne : " + str(
n + 2) + ": Le code de la promotion est invalide ")
return False, "Ligne : " + str(n + 2) + ": Le code de la promotion est invalide ."
inscrit_data = MYSY_GV.dbname['inscription'].find_one(
{'email': {'$regex': '^' + mycommon.regex_replace_cartere(str(mydata['email'])) + '$',
"$options": "i"},
promotion_data = MYSY_GV.dbname['session_formation'].find_one(
{'code_session': {
'$regex': '^' + mycommon.regex_replace_cartere(str(mydata['classe'])) + '$',
"$options": "i"},
'valide': '1',
'partner_owner_recid': str(my_partner['recid'])})
'session_id': str(promotion_data['_id']),
'valide': '1',
'locked': '0',
'partner_owner_recid': str(my_partner['recid'])})
"""
Verifier la validité de l'inscrit
"""
is_valide_inscrit = MYSY_GV.dbname['inscription'].count_documents(
{'email': {'$regex': '^' + mycommon.regex_replace_cartere(str(mydata['email_apprenant'])) + '$',
"$options": "i"},
'session_id': str(promotion_data['_id']),
'valide': '1',
'locked': '0',
'partner_owner_recid': str(my_partner['recid'])})
"""
Recuperer la ligne de 'note_evaluation_participant' associé à cet inscrit
"""
note_evaluation_participant_data = MYSY_GV.dbname['note_evaluation_participant'].find_one(
{'evaluation_id': str(evaluation_data['_id']),
'inscription_id': str(inscrit_data['_id']),
'valide': '1',
'locked': '0',
'partner_owner_recid': str(my_partner['recid'])})
if (is_valide_inscrit != 1):
mycommon.myprint(
str(inspect.stack()[0][3]) + "Ligne : " + str(
n + 2) + ": L'email, le nom et le code promotion ne correspondent pas à un inscrit valide.")
return False, "Ligne : " + str(
n + 2) + ": L'email, le nom et le code promotion ne correspondent pas à un inscrit valide."
if (note_evaluation_participant_data is None or '_id' not in note_evaluation_participant_data.keys()):
mycommon.myprint(
str(inspect.stack()[0][3]) + "Ligne : " + str(
n + 2) + ": Aucune évaluation valide pour cette ligne")
return False, "Ligne : " + str(
n + 2) + ": Aucune évaluation valide pour cette ligne"
inscrit_data = MYSY_GV.dbname['inscription'].find_one(
{'email': {'$regex': '^' + mycommon.regex_replace_cartere(str(mydata['email'])) + '$',
"$options": "i"},
'session_id': str(promotion_data['_id']),
'valide': '1',
'locked': '0',
'partner_owner_recid': str(my_partner['recid'])})
"""
Recuperer la ligne de 'note_evaluation_participant' associé à cet inscrit
"""
note_evaluation_participant_data = MYSY_GV.dbname['note_evaluation_participant'].find_one(
{'evaluation_id': str(evaluation_data['_id']),
'inscription_id': str(inscrit_data['_id']),
'valide': '1',
'locked': '0',
'partner_owner_recid': str(my_partner['recid'])})
if (note_evaluation_participant_data is None or '_id' not in note_evaluation_participant_data.keys()):
mycommon.myprint(
str(inspect.stack()[0][3]) + "Ligne : " + str(
n + 2) + ": Aucune évaluation valide pour cette ligne")
return False, "Ligne : " + str(
n + 2) + ": Aucune évaluation valide pour cette ligne"
clean_dict = {k: mydata[k] for k in mydata if (str(mydata[k]) != "nan")}
clean_dict = {k: mydata[k] for k in mydata if (str(mydata[k]) != "nan")}
local_node_note = {}
local_node_note['_id'] = str(note_evaluation_participant_data['_id'])
local_node_note['note'] = str(mydata['evaluation_note'])
local_node_note['publish'] = str(mydata['publie'])
tab_participant_note.append(local_node_note)
local_node_note = {}
local_node_note['_id'] = str(note_evaluation_participant_data['_id'])
local_node_note['note'] = str(mydata['evaluation_note'])
local_node_note['publish'] = str(mydata['publie'])
tab_participant_note.append(local_node_note)
nb_valide_line = nb_valide_line + 1
local_diction = {}
local_diction['token'] = str(diction['token'])
local_diction['evaluation_id'] = str(diction['evaluation_id'])
local_diction['tab_participant_note'] = str(tab_participant_note)
print("#### diction to import notes ", local_diction)
status, retval = Update_Participant_Evaluation_Note(local_diction)
if (status is False):
return status, retval
print(str(total_rows) + " participants ont été inserés")
print(str(nb_valide_line) + " participants ont été inserés")
return True, str(total_rows) + " ligne(s) de note mises à jour"
return True, str(nb_valide_line) + " ligne(s) de note mises à jour"
except Exception as e:
exc_type, exc_obj, exc_tb = sys.exc_info()
@ -4213,6 +4224,13 @@ def Controle_Import_Evaluation_Notes_mass(saved_file=None, Folder=None, diction=
partner_recid = str(my_partner['recid'])
evaluation_data = MYSY_GV.dbname['note_evaluation'].find_one(
{"_id": ObjectId(str(diction['evaluation_id'])),
'valide': '1',
'locked': '0',
'partner_owner_recid': str(my_partner['recid'])})
df = pd.read_csv(saved_file, encoding='utf8', on_bad_lines='skip', sep=';', encoding_errors='ignore',
skipinitialspace=True)
df = df.fillna('')
@ -4256,148 +4274,160 @@ def Controle_Import_Evaluation_Notes_mass(saved_file=None, Folder=None, diction=
x = range(0, total_rows)
nb_valide_line = 0
for n in x:
mydata = {}
mydata['evaluation_code'] = str(df['evaluation_code'].values[n]).strip()
mydata['classe'] = str(df['classe'].values[n]).strip()
mydata['nom_apprenant'] = str(df['nom_apprenant'].values[n]).strip().lower()
mydata['email_apprenant'] = str(df['email_apprenant'].values[n]).strip().lower()
mydata['evaluation_note'] = str(df['evaluation_note'].values[n]).strip()
if(str(df['evaluation_code'].values[n]) and str(df['classe'].values[n]) and str(df['nom_apprenant'].values[n]) and str(df['evaluation_note'].values[n])):
if( diction['type_notation'] == "num"):
local_price_status, local_status_retval = mycommon.IsFloat(str(mydata['evaluation_note']))
if (local_price_status is False):
if( str(df['evaluation_code'].values[n]) != evaluation_data['code'] ):
mycommon.myprint(
str(inspect.stack()[0][3]) + "Ligne : " + str(
n + 2) + ": La note doit être une valeur numérique ")
n + 2) + ": Le code de l'évaluation ne corresponds pas l'évaluation selectionnée ")
return False, "Ligne : " + str(
n + 2) + ": La note doit être une valeur numérique "
n + 2) + ": Le code de l'évaluation ne corresponds pas l'évaluation selectionnée "
if( float(str(local_status_retval)) > float( diction['max_note'])):
mycommon.myprint(
str(inspect.stack()[0][3]) + " Ligne : " + str(
n + 2) + ": La note "+str(mydata['evaluation_note'])+" ne doit pas dépasser la valeur de "+str(diction['max_note']))
return False, " Ligne : " + str(
n + 2) + " : La note "+str(mydata['evaluation_note'])+" ne doit pas dépasser la valeur de "+str(diction['max_note'])
mydata = {}
mydata['evaluation_code'] = str(df['evaluation_code'].values[n]).strip()
mydata['classe'] = str(df['classe'].values[n]).strip()
mydata['nom_apprenant'] = str(df['nom_apprenant'].values[n]).strip().lower()
mydata['email_apprenant'] = str(df['email_apprenant'].values[n]).strip().lower()
mydata['evaluation_note'] = str(df['evaluation_note'].values[n]).strip()
tmp_publie = str(df['publie'].values[n]).strip()
if( diction['type_notation'] == "num"):
local_price_status, local_status_retval = mycommon.IsFloat(str(mydata['evaluation_note']))
if (local_price_status is False):
mycommon.myprint(
str(inspect.stack()[0][3]) + "Ligne : " + str(
n + 2) + ": La note doit être une valeur numérique ")
return False, "Ligne : " + str(
n + 2) + ": La note doit être une valeur numérique "
if( float(str(local_status_retval)) > float( diction['max_note'])):
mycommon.myprint(
str(inspect.stack()[0][3]) + " Ligne : " + str(
n + 2) + ": La note "+str(mydata['evaluation_note'])+" ne doit pas dépasser la valeur de "+str(diction['max_note']))
return False, " Ligne : " + str(
n + 2) + " : La note "+str(mydata['evaluation_note'])+" ne doit pas dépasser la valeur de "+str(diction['max_note'])
tmp_publie = str(df['publie'].values[n]).strip()
if( mydata['evaluation_code'] and mydata['classe'] and mydata['email_apprenant'] ):
if( mydata['evaluation_code'] and mydata['classe'] and mydata['email_apprenant'] ):
if (tmp_publie not in ['0', '1', '']):
mycommon.myprint(
str(inspect.stack()[0][3]) + "Ligne : " + str(
n + 2) + ": La valeur 'publié' est invalide ")
return False, "Ligne : " + str(
n + 2) + ": La valeur 'publié' est invalide. Valeurs acceptées : '0', '1', '' "
if (tmp_publie not in ['0', '1', '']):
mycommon.myprint(
str(inspect.stack()[0][3]) + "Ligne : " + str(
n + 2) + ": La valeur 'publié' est invalide ")
return False, "Ligne : " + str(
n + 2) + ": La valeur 'publié' est invalide. Valeurs acceptées : '0', '1', '' "
if (tmp_publie == "1"):
mydata['publie'] = "true"
else:
mydata['publie'] = "false"
if (tmp_publie == "1"):
mydata['publie'] = "true"
else:
mydata['publie'] = "false"
mydata['email'] = str(df['email_apprenant'].values[n]).strip().lower()
mydata['email'] = str(df['email_apprenant'].values[n]).strip().lower()
regex = r'\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,7}\b'
if (not re.fullmatch(regex, str(mydata['email_apprenant']))):
mycommon.myprint(
str(inspect.stack()[0][3]) + " Ligne : " + str(n + 2) + " : L'adresse email " + str(
mydata['email']) + " est invalide")
return False, " Ligne : " + str(n + 2) + " : L'adresse email -" + str(
mydata['email_apprenant']) + "- est invalide"
regex = r'\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,7}\b'
if (not re.fullmatch(regex, str(mydata['email_apprenant']))):
mycommon.myprint(
str(inspect.stack()[0][3]) + " Ligne : " + str(n + 2) + " : L'adresse email " + str(
mydata['email']) + " est invalide")
return False, " Ligne : " + str(n + 2) + " : L'adresse email -" + str(
mydata['email_apprenant']) + "- est invalide"
mydata['token'] = str(my_token)
mydata['token'] = str(my_token)
"""
Verifier la validité de evaluation_code
"""
"""
Verifier la validité de evaluation_code
"""
is_valide_evaluation_code = MYSY_GV.dbname['note_evaluation'].count_documents(
{'code': {'$regex': '^'+mycommon.regex_replace_cartere(str(mydata['evaluation_code']))+'$', "$options": "i"},
'valide': '1',
'locked': '0',
'partner_owner_recid': str(my_partner['recid'])})
is_valide_evaluation_code = MYSY_GV.dbname['note_evaluation'].count_documents(
{'code': {'$regex': '^'+mycommon.regex_replace_cartere(str(mydata['evaluation_code']))+'$', "$options": "i"},
'valide': '1',
'locked': '0',
'partner_owner_recid': str(my_partner['recid'])})
if (is_valide_evaluation_code != 1):
mycommon.myprint(
str(inspect.stack()[0][3]) + "Ligne : " + str(
n + 2) + ": Le code de l'évaluation est invalide ")
return False, "Ligne : " + str(n + 2) + ": Le code de l'évaluation est invalide ."
if (is_valide_evaluation_code != 1):
mycommon.myprint(
str(inspect.stack()[0][3]) + "Ligne : " + str(
n + 2) + ": Le code de l'évaluation est invalide ")
return False, "Ligne : " + str(n + 2) + ": Le code de l'évaluation est invalide ."
evaluation_data = MYSY_GV.dbname['note_evaluation'].find_one(
{'code': {'$regex': '^'+mycommon.regex_replace_cartere(str(mydata['evaluation_code']))+'$', "$options": "i"},
'valide': '1',
'locked': '0',
'partner_owner_recid': str(my_partner['recid'])})
evaluation_data = MYSY_GV.dbname['note_evaluation'].find_one(
{'code': {'$regex': '^'+mycommon.regex_replace_cartere(str(mydata['evaluation_code']))+'$', "$options": "i"},
'valide': '1',
'locked': '0',
'partner_owner_recid': str(my_partner['recid'])})
"""
Verifier la validité de promotion_code
"""
"""
Verifier la validité de promotion_code
"""
is_valide_promotion_code = MYSY_GV.dbname['session_formation'].count_documents(
{'code_session': {'$regex': '^'+mycommon.regex_replace_cartere(str(mydata['classe']))+'$', "$options": "i"},
'valide': '1',
'partner_owner_recid': str(my_partner['recid'])})
is_valide_promotion_code = MYSY_GV.dbname['session_formation'].count_documents(
{'code_session': {'$regex': '^'+mycommon.regex_replace_cartere(str(mydata['classe']))+'$', "$options": "i"},
'valide': '1',
'partner_owner_recid': str(my_partner['recid'])})
if (is_valide_promotion_code != 1):
mycommon.myprint(
str(inspect.stack()[0][3]) + "Ligne : " + str(
n + 2) + ": Le code de la promotion est invalide ")
return False, "Ligne : " + str(n + 2) + ": Le code de la promotion est invalide ."
if (is_valide_promotion_code != 1):
mycommon.myprint(
str(inspect.stack()[0][3]) + "Ligne : " + str(
n + 2) + ": Le code de la promotion est invalide ")
return False, "Ligne : " + str(n + 2) + ": Le code de la promotion est invalide ."
promotion_data = MYSY_GV.dbname['session_formation'].find_one(
{'code_session': {'$regex': '^'+mycommon.regex_replace_cartere(str(mydata['classe']))+'$', "$options": "i"},
'valide': '1',
'partner_owner_recid': str(my_partner['recid'])})
promotion_data = MYSY_GV.dbname['session_formation'].find_one(
{'code_session': {'$regex': '^'+mycommon.regex_replace_cartere(str(mydata['classe']))+'$', "$options": "i"},
'valide': '1',
'partner_owner_recid': str(my_partner['recid'])})
"""
Verifier la validité de l'inscrit
"""
is_valide_inscrit = MYSY_GV.dbname['inscription'].count_documents(
{'email': {'$regex': '^'+mycommon.regex_replace_cartere(str(mydata['email_apprenant']))+'$', "$options": "i"},
'session_id': str(promotion_data['_id']),
'valide': '1',
'locked': '0',
'partner_owner_recid': str(my_partner['recid'])})
"""
Verifier la validité de l'inscrit
"""
is_valide_inscrit = MYSY_GV.dbname['inscription'].count_documents(
{'email': {'$regex': '^'+mycommon.regex_replace_cartere(str(mydata['email_apprenant']))+'$', "$options": "i"},
'session_id': str(promotion_data['_id']),
'valide': '1',
'locked': '0',
'partner_owner_recid': str(my_partner['recid'])})
if (is_valide_inscrit != 1):
mycommon.myprint(
str(inspect.stack()[0][3]) + "Ligne : " + str(
n + 2) + ": L'email, le nom et le code promotion ne correspondent pas à un inscrit valide.")
return False, "Ligne : " + str(
n + 2) + ": L'email, le nom et le code promotion ne correspondent pas à un inscrit valide."
if (is_valide_inscrit != 1):
mycommon.myprint(
str(inspect.stack()[0][3]) + "Ligne : " + str(
n + 2) + ": L'email, le nom et le code promotion ne correspondent pas à un inscrit valide.")
return False, "Ligne : " + str(
n + 2) + ": L'email, le nom et le code promotion ne correspondent pas à un inscrit valide."
inscrit_data = MYSY_GV.dbname['inscription'].find_one(
{'email': {'$regex': '^' + mycommon.regex_replace_cartere(str(mydata['email'])) + '$', "$options": "i"},
inscrit_data = MYSY_GV.dbname['inscription'].find_one(
{'email': {'$regex': '^' + mycommon.regex_replace_cartere(str(mydata['email'])) + '$', "$options": "i"},
'session_id': str(promotion_data['_id']),
'valide': '1',
'locked': '0',
'partner_owner_recid': str(my_partner['recid'])})
'session_id': str(promotion_data['_id']),
'valide': '1',
'locked': '0',
'partner_owner_recid': str(my_partner['recid'])})
"""
Recuperer la ligne de 'note_evaluation_participant' associé à cet inscrit
"""
note_evaluation_participant_data = MYSY_GV.dbname['note_evaluation_participant'].find_one(
{'evaluation_id': str(evaluation_data['_id']),
'inscription_id': str(inscrit_data['_id']),
'valide': '1',
'locked': '0',
'partner_owner_recid': str(my_partner['recid'])})
"""
Recuperer la ligne de 'note_evaluation_participant' associé à cet inscrit
"""
note_evaluation_participant_data = MYSY_GV.dbname['note_evaluation_participant'].find_one(
{'evaluation_id': str(evaluation_data['_id']),
'inscription_id': str(inscrit_data['_id']),
'valide': '1',
'locked': '0',
'partner_owner_recid': str(my_partner['recid'])})
if (note_evaluation_participant_data is None or '_id' not in note_evaluation_participant_data.keys()):
mycommon.myprint(
str(inspect.stack()[0][3]) + "Ligne : " + str(
n + 2) + ": Aucune évaluation valide pour cette ligne")
return False, "Ligne : " + str(
n + 2) + ": Aucune évaluation valide pour cette ligne"
if (note_evaluation_participant_data is None or '_id' not in note_evaluation_participant_data.keys()):
mycommon.myprint(
str(inspect.stack()[0][3]) + "Ligne : " + str(
n + 2) + ": Aucune évaluation valide pour cette ligne")
return False, "Ligne : " + str(
n + 2) + ": Aucune évaluation valide pour cette ligne"
nb_valide_line = nb_valide_line + 1
return True, str(total_rows) + " lignes de notes dans le fichier"
return True, str(nb_valide_line) + " lignes de notes dans le fichier"
except Exception as e:
exc_type, exc_obj, exc_tb = sys.exc_info()

View File

@ -2848,7 +2848,7 @@ def Send_Survey_TabIds(diction):
le principe est de prendre le module du partenaire. si pas de modele du partenaire on
prend le modele par default
"""
print(" ### courrier_template courrier_ref_interne = ", courrier_ref_interne)
#print(" ### courrier_template courrier_ref_interne = ", courrier_ref_interne)
courrier_template_model = MYSY_GV.dbname['courrier_template'].count_documents(
{'ref_interne': str(courrier_ref_interne),
'valide': '1',

View File

@ -2417,7 +2417,8 @@ def JMJ_Repise_Factures_Update_Inscription_Status(diction):
"""
Cette fonction permet de desactiver les traitements automatique sur
les sessions de formation.
les sessions de formation ainsi que les survey à relancer
Si un partner_owner_recid = "all", alors il fait pour tout le monde
si non pour le partner_owner_recid concerné
@ -2462,9 +2463,29 @@ def Disable_Session_Formation_Automation(diction):
)
for survey_data in MYSY_GV.dbname['survey'].find(qry_session):
result = MYSY_GV.dbname['survey'].update_many(
{'_id': ObjectId(str(survey_data['_id'])),
'partner_owner_recid': str(survey_data['partner_owner_recid'])}
,
{"$set":
{
'automatique_traitement_done': "1",
'statut': "2",
'comment': "Desactivation admin",
}
},
)
print(" result = ", result.modified_count)
return True, "Mise à jour OK "
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 faire la mise à jour"

View File

@ -1033,6 +1033,89 @@ def Get_List_Unite_Enseignement_Of_Given_Class_From_Session_Id(diction):
"""
Recuperer la liste des UE d'une SESSION, donc pas toutes les ue de la formation
mais juste celles de l'UE
"""
def Get_List_Unite_Enseignement_Of_Given_Session_Id(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 la liste des arguments ")
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
#print(" #### Get_List_Unite_Enseignement_Of_Given_Class qry = ", qry)
for New_retVal in MYSY_GV.dbname['session_formation'].find({'_id':ObjectId(str(diction['session_id'])),
'valide':'1',
"partner_owner_recid": str(my_partner['recid'])}).sort([("_id", pymongo.DESCENDING), ]):
if( "list_unite_enseignement" in New_retVal.keys() ):
for local_val in New_retVal['list_unite_enseignement'] :
"""
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']))}, {'_id':1, 'code':1, 'titre':1, })
if( ue_data ):
user = ue_data
user['class_id'] = New_retVal['class_id']
user['internal_url'] = New_retVal['class_internal_url']
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 la liste des unites d'enseignement de la promotion "
"""