parent
18f751e1ab
commit
c5ae3c2231
|
@ -4,17 +4,14 @@
|
|||
<option name="autoReloadType" value="SELECTIVE" />
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="09/06/2025 - 21h30">
|
||||
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="11/06/2025 - 16h30">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" 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$/base_class_calcul_note.py" beforeDir="false" afterPath="$PROJECT_DIR$/base_class_calcul_note.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/class_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/class_mgt.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/jury_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/jury_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$/prj_common.py" beforeDir="false" afterPath="$PROJECT_DIR$/prj_common.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/survey_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/survey_mgt.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/unite_enseignement_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/unite_enseignement_mgt.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/user_access_right.py" beforeDir="false" afterPath="$PROJECT_DIR$/user_access_right.py" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
|
@ -456,7 +453,7 @@
|
|||
<option name="project" value="LOCAL" />
|
||||
<updated>1747251650255</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="474" />
|
||||
<option name="localTasksCounter" value="475" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="Vcs.Log.Tabs.Properties">
|
||||
|
@ -498,7 +495,6 @@
|
|||
</option>
|
||||
</component>
|
||||
<component name="VcsManagerConfiguration">
|
||||
<MESSAGE value="29/03/2025 - 21h" />
|
||||
<MESSAGE value="25/04/2025 - 15h" />
|
||||
<MESSAGE value="30/04/2025 - 15h" />
|
||||
<MESSAGE value="02/05/2025 - 20h" />
|
||||
|
@ -523,6 +519,7 @@
|
|||
<MESSAGE value="07/06/2025 - 21h30" />
|
||||
<MESSAGE value="08/06/2025 - 16h30" />
|
||||
<MESSAGE value="09/06/2025 - 21h30" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="09/06/2025 - 21h30" />
|
||||
<MESSAGE value="11/06/2025 - 16h30" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="11/06/2025 - 16h30" />
|
||||
</component>
|
||||
</project>
|
2895
Log/log_file.log
2895
Log/log_file.log
File diff suppressed because it is too large
Load Diff
|
@ -1574,9 +1574,10 @@ def GetAllValideSessionFormation_List(diction):
|
|||
|
||||
|
||||
"""
|
||||
Cette fonction recupere toutes les sessions de formation d'un partenaire
|
||||
Cette fonction recupere toutes les sessions de formation d'un partenaire.
|
||||
Cette fonction est utilisé pour definir le scope d'un user (il faut d'abord voir tout pour fixer un scope)
|
||||
"""
|
||||
def GetAllValideSessionPartner_List(diction):
|
||||
def GetAllValideSessionPartner_List_Without_Scope_Action(diction):
|
||||
try:
|
||||
|
||||
field_list = ['token', 'archive']
|
||||
|
@ -1617,19 +1618,13 @@ def GetAllValideSessionPartner_List(diction):
|
|||
filt_archive = {'archive': '1'}
|
||||
|
||||
|
||||
"""
|
||||
Filtre uniquement pour la Formation Initiale
|
||||
"""
|
||||
filt_scope_class_id = {}
|
||||
if ("scope" in my_partner.keys() and "class_id" in my_partner['scope'].keys() and len(
|
||||
my_partner['scope']['class_id']) > 0):
|
||||
filt_scope_class_id['class_id'] = {'$in': my_partner['scope']['class_id']}
|
||||
|
||||
|
||||
coll_session = MYSY_GV.dbname['session_formation']
|
||||
|
||||
filt_class_partner_recid = {'partner_owner_recid': str(my_partner['recid'])}
|
||||
|
||||
query = [{'$match':{ "$and" : [{'partner_owner_recid':str(my_partner['recid'])},filt_scope_class_id, filt_archive]} },
|
||||
query = [{'$match':{ "$and" : [{'partner_owner_recid':str(my_partner['recid'])}, filt_archive]} },
|
||||
{ '$sort': {'_id': -1}},
|
||||
{'$lookup':
|
||||
{
|
||||
|
@ -1645,7 +1640,7 @@ def GetAllValideSessionPartner_List(diction):
|
|||
}
|
||||
}
|
||||
]
|
||||
print("#### GetAllValideSessionPartner_List query = ", query)
|
||||
print("#### GetAllValideSessionPartner_List_Without_Scope_Action query = ", query)
|
||||
|
||||
RetObject = []
|
||||
cpt = 0
|
||||
|
@ -1696,7 +1691,6 @@ def GetAllValideSessionPartner_List(diction):
|
|||
val['session_status'] = "0"
|
||||
|
||||
|
||||
|
||||
val['date_debut'] = retVal['date_debut'][0:10]
|
||||
val['date_fin'] = retVal['date_fin'][0:10]
|
||||
val['date_debut_inscription'] = retVal['date_debut_inscription'][0:10]
|
||||
|
@ -1709,6 +1703,156 @@ def GetAllValideSessionPartner_List(diction):
|
|||
val['mode_animation'] = "0"
|
||||
|
||||
|
||||
RetObject.append(mycommon.JSONEncoder().encode(val))
|
||||
|
||||
|
||||
return True, RetObject
|
||||
|
||||
|
||||
except Exception as e:
|
||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
|
||||
return False, "Impossible de récupérer la liste des sessions de formation valides et actives."
|
||||
|
||||
|
||||
"""
|
||||
Cette fonction recupere toutes les sessions de formation d'un partenaire
|
||||
"""
|
||||
|
||||
def GetAllValideSessionPartner_List(diction):
|
||||
try:
|
||||
|
||||
field_list = ['token', 'archive']
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
if val not in field_list and val.startswith('my_') is False:
|
||||
mycommon.myprint(str(inspect.stack()[0][
|
||||
3]) + " - Le champ '" + val + "' n'est pas autorisé, Creation partenaire annulée")
|
||||
return False, " Impossible de récupérer la liste des session de formation"
|
||||
|
||||
"""
|
||||
Verification de la liste des champs obligatoires
|
||||
"""
|
||||
field_list_obligatoire = ['token', ]
|
||||
for val in field_list_obligatoire:
|
||||
if val not in diction:
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " - : La valeur '" + val + "' n'est pas presente dans la liste des arguments ")
|
||||
return False, "Impossible de récupérer la liste des session de formation"
|
||||
|
||||
# Recuperation du recid du partner
|
||||
mydata = {}
|
||||
|
||||
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_archive = {}
|
||||
if ("archive" in diction.keys() and (diction["archive"] == "0" or diction["archive"] == "")):
|
||||
filt_archive = {'archive': {'$ne': '1'}}
|
||||
|
||||
elif ("archive" in diction.keys() and diction["archive"] == "1"):
|
||||
filt_archive = {'archive': '1'}
|
||||
|
||||
"""
|
||||
Filtre uniquement pour la Formation Initiale
|
||||
"""
|
||||
filt_scope_class_id = {}
|
||||
if ("scope" in my_partner.keys() and "class_id" in my_partner['scope'].keys() and len(
|
||||
my_partner['scope']['class_id']) > 0):
|
||||
filt_scope_class_id['class_id'] = {'$in': my_partner['scope']['class_id']}
|
||||
|
||||
coll_session = MYSY_GV.dbname['session_formation']
|
||||
|
||||
filt_class_partner_recid = {'partner_owner_recid': str(my_partner['recid'])}
|
||||
|
||||
query = [{'$match': {
|
||||
"$and": [{'partner_owner_recid': str(my_partner['recid'])}, filt_scope_class_id, filt_archive]}},
|
||||
{'$sort': {'_id': -1}},
|
||||
{'$lookup':
|
||||
{
|
||||
'from': 'myclass',
|
||||
'localField': 'class_internal_url',
|
||||
'foreignField': 'internal_url',
|
||||
'pipeline': [{'$match': filt_class_partner_recid}, {'$project': {'title': 1, 'domaine': 1,
|
||||
'duration': 1,
|
||||
'duration_unit': 1,
|
||||
'external_code': 1,
|
||||
'published': 1,
|
||||
'recyclage_delai': 1,
|
||||
'recyclage_periodicite': 1,
|
||||
'lms_class_code': 1,
|
||||
'_id': 1}}],
|
||||
'as': 'myclass_collection'
|
||||
}
|
||||
}
|
||||
]
|
||||
print("#### GetAllValideSessionPartner_List query = ", query)
|
||||
|
||||
RetObject = []
|
||||
cpt = 0
|
||||
for retVal in MYSY_GV.dbname['session_formation'].aggregate(query):
|
||||
if ('myclass_collection' in retVal.keys() and len(retVal['myclass_collection']) > 0):
|
||||
val = {}
|
||||
val['id'] = str(cpt)
|
||||
cpt = cpt + 1
|
||||
val['class_internal_url'] = retVal['class_internal_url']
|
||||
val['class_id'] = retVal['myclass_collection'][0]['_id']
|
||||
val['_id'] = retVal['_id']
|
||||
val['code_session'] = retVal['code_session']
|
||||
|
||||
if ("session_etape" in retVal.keys()):
|
||||
val['session_etape'] = retVal['session_etape']
|
||||
else:
|
||||
val['session_etape'] = ""
|
||||
|
||||
if ("invoiced_statut" in retVal.keys()):
|
||||
val['invoiced_statut'] = retVal['invoiced_statut']
|
||||
else:
|
||||
val['invoiced_statut'] = "0"
|
||||
|
||||
if ("titre" in retVal.keys()):
|
||||
val['titre'] = retVal['titre']
|
||||
else:
|
||||
val['titre'] = ""
|
||||
|
||||
if ("location_type" in retVal.keys()):
|
||||
val['location_type'] = retVal['location_type']
|
||||
else:
|
||||
val['location_type'] = ""
|
||||
|
||||
if ("is_bpf" in retVal.keys()):
|
||||
val['is_bpf'] = retVal['is_bpf']
|
||||
else:
|
||||
val['is_bpf'] = ""
|
||||
|
||||
if ("archive" in retVal.keys()):
|
||||
val['archive'] = retVal['archive']
|
||||
else:
|
||||
val['archive'] = ""
|
||||
|
||||
if ("session_status" in retVal.keys()):
|
||||
val['session_status'] = retVal['session_status']
|
||||
else:
|
||||
val['session_status'] = "0"
|
||||
|
||||
val['date_debut'] = retVal['date_debut'][0:10]
|
||||
val['date_fin'] = retVal['date_fin'][0:10]
|
||||
val['date_debut_inscription'] = retVal['date_debut_inscription'][0:10]
|
||||
val['date_fin_inscription'] = retVal['date_fin_inscription'][0:10]
|
||||
|
||||
val['distantiel'] = retVal['distantiel']
|
||||
if ("mode_animation" in retVal.keys()):
|
||||
val['mode_animation'] = retVal['mode_animation']
|
||||
else:
|
||||
val['mode_animation'] = "0"
|
||||
|
||||
site_formation_id = ""
|
||||
site_formation_code = ""
|
||||
if ("site_formation_id" in retVal.keys() and retVal['site_formation_id']):
|
||||
|
@ -1725,10 +1869,9 @@ def GetAllValideSessionPartner_List(diction):
|
|||
val['site_formation_id'] = site_formation_id
|
||||
val['site_formation_code'] = site_formation_code
|
||||
|
||||
if ("formateur_id" in retVal.keys() and retVal['formateur_id']):
|
||||
if ("formateur_id" in retVal.keys() and retVal['formateur_id']):
|
||||
val['formateur_id'] = retVal['formateur_id']
|
||||
|
||||
|
||||
# On va aller chercher le nom et prenom du formateur
|
||||
fomateur_data = MYSY_GV.dbname['ressource_humaine'].find_one(
|
||||
{'_id': ObjectId(str(retVal['formateur_id'])),
|
||||
|
@ -1749,14 +1892,12 @@ def GetAllValideSessionPartner_List(diction):
|
|||
else:
|
||||
val['formateur_id'] = ""
|
||||
|
||||
|
||||
nb_participant = "1"
|
||||
if( "nb_participant" in retVal.keys()):
|
||||
if ("nb_participant" in retVal.keys()):
|
||||
nb_participant = retVal['nb_participant']
|
||||
|
||||
val['nb_participant'] = nb_participant
|
||||
|
||||
|
||||
val['presentiel'] = retVal['presentiel']
|
||||
val['prix_session'] = retVal['prix_session']
|
||||
|
||||
|
@ -1777,8 +1918,8 @@ def GetAllValideSessionPartner_List(diction):
|
|||
|
||||
val['class_external_code'] = retVal['myclass_collection'][0]['external_code']
|
||||
|
||||
if( str(retVal['myclass_collection'][0]['duration_unit']) == "heure"):
|
||||
val['duration_concat'] = str(retVal['myclass_collection'][0]['duration'])+" h"
|
||||
if (str(retVal['myclass_collection'][0]['duration_unit']) == "heure"):
|
||||
val['duration_concat'] = str(retVal['myclass_collection'][0]['duration']) + " h"
|
||||
|
||||
elif (str(retVal['myclass_collection'][0]['duration_unit']) == "jour"):
|
||||
val['duration_concat'] = str(retVal['myclass_collection'][0]['duration']) + " j"
|
||||
|
@ -1795,10 +1936,10 @@ def GetAllValideSessionPartner_List(diction):
|
|||
elif (str(retVal['myclass_collection'][0]['duration_unit']) == "user_rythme"):
|
||||
val['duration_concat'] = str(retVal['myclass_collection'][0]['duration']) + " u"
|
||||
|
||||
else :
|
||||
else:
|
||||
val['duration_concat'] = str(retVal['myclass_collection'][0]['duration']) + " ?"
|
||||
|
||||
if( "duration" in retVal['myclass_collection'][0].keys()):
|
||||
if ("duration" in retVal['myclass_collection'][0].keys()):
|
||||
val['duration'] = str(retVal['myclass_collection'][0]['duration'])
|
||||
else:
|
||||
val['duration'] = "1"
|
||||
|
@ -1809,12 +1950,13 @@ def GetAllValideSessionPartner_List(diction):
|
|||
val['duration_unit'] = "jour"
|
||||
|
||||
## Recuperation du nombre d'inscrits
|
||||
Count_Inscrit = MYSY_GV.dbname['inscription'].count_documents({'session_id':str(retVal['_id']), 'class_internal_url':str(retVal['class_internal_url']),
|
||||
'status':"1", 'partner_owner_recid':str(my_partner['recid'])})
|
||||
|
||||
qry_nb_inscrit = {'session_id':str(retVal['_id']), 'class_internal_url':str(retVal['class_internal_url']),
|
||||
'status':"1", 'partner_owner_recid':str(my_partner['recid'])}
|
||||
Count_Inscrit = MYSY_GV.dbname['inscription'].count_documents(
|
||||
{'session_id': str(retVal['_id']), 'class_internal_url': str(retVal['class_internal_url']),
|
||||
'status': "1", 'partner_owner_recid': str(my_partner['recid'])})
|
||||
|
||||
qry_nb_inscrit = {'session_id': str(retVal['_id']),
|
||||
'class_internal_url': str(retVal['class_internal_url']),
|
||||
'status': "1", 'partner_owner_recid': str(my_partner['recid'])}
|
||||
|
||||
val['nb_inscrit'] = str(Count_Inscrit)
|
||||
|
||||
|
@ -1822,68 +1964,72 @@ def GetAllValideSessionPartner_List(diction):
|
|||
Count_Preinscrit = MYSY_GV.dbname['inscription'].count_documents(
|
||||
{'session_id': str(retVal['_id']), 'class_internal_url': str(retVal['class_internal_url']),
|
||||
'status': "0",
|
||||
'partner_owner_recid':str(my_partner['recid'])})
|
||||
'partner_owner_recid': str(my_partner['recid'])})
|
||||
|
||||
val['nb_preinscrit'] = str(Count_Preinscrit)
|
||||
|
||||
taux_remplissage = "0"
|
||||
if( str(nb_participant) != "0" and str(nb_participant).strip() != ""):
|
||||
taux_remplissage = round(int(mycommon.tryInt(Count_Inscrit)) / int(mycommon.tryInt(nb_participant)), 2)
|
||||
if (str(nb_participant) != "0" and str(nb_participant).strip() != ""):
|
||||
taux_remplissage = round(int(mycommon.tryInt(Count_Inscrit)) / int(mycommon.tryInt(nb_participant)),
|
||||
2)
|
||||
|
||||
val['taux_remplissage'] = str(taux_remplissage)
|
||||
|
||||
"""
|
||||
29/05/2024 : On va aller recuperer le nombre de personnes inscrites sur des devis non envoyés et non validés.
|
||||
Ceci permet de connaitre le nombre potentiel d'inscription en attentes.
|
||||
|
||||
|
||||
Regles : Cela concerne uniquement les devis envoyés aux clients et prospects mais non validé
|
||||
|
||||
|
||||
"""
|
||||
|
||||
locl_find_qry = {
|
||||
'$and': [{'partner_owner_recid': str(my_partner['recid']), 'valide': '1', 'locked': '0',
|
||||
'order_header_type':'devis', 'is_validated':'0', 'date_envoi_quotation': { "$exists": True } }, {}, ]}
|
||||
|
||||
'order_header_type': 'devis', 'is_validated': '0',
|
||||
'date_envoi_quotation': {"$exists": True}}, {}, ]}
|
||||
|
||||
local_new_myquery_find_order = [{'$match': locl_find_qry},
|
||||
{'$sort': {'_id': -1}},
|
||||
{"$addFields": {"partner_order_header_Id": {"$toString": "$_id"}}},
|
||||
{'$lookup':
|
||||
{
|
||||
'from': 'partner_order_line',
|
||||
'localField': "partner_order_header_Id",
|
||||
'foreignField': 'order_header_id',
|
||||
'pipeline': [
|
||||
{'$match':
|
||||
{'$and':
|
||||
[
|
||||
{'order_line_formation':str(retVal['class_internal_url'])},
|
||||
{'partner_owner_recid': str(my_partner['recid']),
|
||||
'order_line_session_id':str(retVal['_id'])},
|
||||
{'valide': '1'}]}}, ],
|
||||
'as': 'partner_order_line_collection'
|
||||
}
|
||||
},
|
||||
{'$sort': {'_id': -1}},
|
||||
{"$addFields": {"partner_order_header_Id": {"$toString": "$_id"}}},
|
||||
{'$lookup':
|
||||
{
|
||||
'from': 'partner_order_line',
|
||||
'localField': "partner_order_header_Id",
|
||||
'foreignField': 'order_header_id',
|
||||
'pipeline': [
|
||||
{'$match':
|
||||
{'$and':
|
||||
[
|
||||
{'order_line_formation': str(
|
||||
retVal['class_internal_url'])},
|
||||
{'partner_owner_recid': str(
|
||||
my_partner['recid']),
|
||||
'order_line_session_id': str(retVal['_id'])},
|
||||
{'valide': '1'}]}}, ],
|
||||
'as': 'partner_order_line_collection'
|
||||
}
|
||||
},
|
||||
{
|
||||
'$unwind': '$partner_order_line_collection'
|
||||
}
|
||||
]
|
||||
]
|
||||
total_qty = 0
|
||||
tab_quotation_ref = []
|
||||
|
||||
for local_New_retVal in MYSY_GV.dbname['partner_order_header'].aggregate(local_new_myquery_find_order):
|
||||
#print(" ### local_New_retVal = ", local_New_retVal)
|
||||
if( "partner_order_line_collection" in local_New_retVal.keys() ):
|
||||
if( "order_line_qty" in local_New_retVal['partner_order_line_collection'].keys() and
|
||||
len(str(local_New_retVal['date_envoi_quotation'])) > 5 ):
|
||||
total_qty = total_qty + mycommon.tryFloat(local_New_retVal['partner_order_line_collection']['order_line_qty'])
|
||||
# print(" ### local_New_retVal = ", local_New_retVal)
|
||||
if ("partner_order_line_collection" in local_New_retVal.keys()):
|
||||
if ("order_line_qty" in local_New_retVal['partner_order_line_collection'].keys() and
|
||||
len(str(local_New_retVal['date_envoi_quotation'])) > 5):
|
||||
total_qty = total_qty + mycommon.tryFloat(
|
||||
local_New_retVal['partner_order_line_collection']['order_line_qty'])
|
||||
tab_quotation_ref.append(str(local_New_retVal['order_header_ref_interne']))
|
||||
|
||||
#print(" ### total_qty = ", total_qty)
|
||||
#print(" ### tab_quotation_ref = ", tab_quotation_ref)
|
||||
# print(" ### total_qty = ", total_qty)
|
||||
# print(" ### tab_quotation_ref = ", tab_quotation_ref)
|
||||
|
||||
val['qty_in_quotation'] = str(total_qty)
|
||||
val['qty_in_quotation_list_quotation'] = ', '.join(tab_quotation_ref)
|
||||
val['qty_in_quotation_list_quotation'] = ', '.join(tab_quotation_ref)
|
||||
|
||||
"""
|
||||
Pour chaque session recuperer le statut de controle d'alert
|
||||
|
@ -1895,23 +2041,18 @@ def GetAllValideSessionPartner_List(diction):
|
|||
local_diction['token'] = str(diction['token'])
|
||||
local_diction['session_id'] = str(retVal['_id'])
|
||||
|
||||
local_check_session_alert_status, local_check_session_alert_retval, local_check_session_alert_is_warning = mycommon.Check_Partner_Session_Alert(
|
||||
local_diction)
|
||||
|
||||
local_check_session_alert_status, local_check_session_alert_retval, local_check_session_alert_is_warning = mycommon.Check_Partner_Session_Alert(local_diction)
|
||||
|
||||
|
||||
if( local_check_session_alert_status ):
|
||||
if (local_check_session_alert_status):
|
||||
is_session_alert = local_check_session_alert_is_warning
|
||||
session_alert_message = local_check_session_alert_retval
|
||||
|
||||
|
||||
val['is_session_alert'] = is_session_alert
|
||||
val['session_alert_message'] = session_alert_message
|
||||
|
||||
|
||||
|
||||
RetObject.append(mycommon.JSONEncoder().encode(val))
|
||||
|
||||
|
||||
return True, RetObject
|
||||
|
||||
|
||||
|
@ -1921,6 +2062,7 @@ def GetAllValideSessionPartner_List(diction):
|
|||
return False, "Impossible de récupérer la liste des sessions de formation valides et actives."
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Recuperation de la liste avec des filter du type like
|
||||
"""
|
||||
|
|
301
class_mgt.py
301
class_mgt.py
|
@ -3647,6 +3647,307 @@ def get_partner_class(diction):
|
|||
return False, " Impossible de récupérer la formation"
|
||||
|
||||
|
||||
"""
|
||||
Cette fonction retourne toutes les formations d'un partnaire sans tenir compte de la notion de scope
|
||||
Cette fonction est utilisé pour definir le scope d'un user (il faut d'abord voir tout pour fixer un scope)
|
||||
"""
|
||||
|
||||
def get_partner_class_Without_Scope_Action(diction):
|
||||
try:
|
||||
'''
|
||||
# Verification que les champs reçus dans l'API sont bien dans la liste des champs autorisés
|
||||
# Cela evite le cas ou une entité tierce ajouter les valeurs inconnu dans l'API
|
||||
# Ici on doit mettre tous les champs possible (obligatoire ou non) de la BDD dans la liste
|
||||
# field_list.
|
||||
'''
|
||||
field_list = ['internal_url', 'token', 'title', 'valide', 'locked', 'external_code', 'archive']
|
||||
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]) + " - get_partner_class : Le champ '" + val + "' n'existe pas, Creation formation annulée")
|
||||
return False, " Impossible de récupérer la formation"
|
||||
|
||||
'''
|
||||
Une fois qu'on a controlé que toutes les clés mise dans l'API sont correcte. etape precedente,
|
||||
On controle que les champs obligatoires sont presents dans la liste
|
||||
'''
|
||||
field_list_obligatoire = ['token']
|
||||
|
||||
for val in field_list_obligatoire:
|
||||
if val not in diction:
|
||||
mycommon.myprint(str(inspect.stack()[0][
|
||||
3]) + " - La valeur '" + val + "' n'est pas presente dans la liste des arguments ")
|
||||
return False, " Impossible de récupérer la formation"
|
||||
|
||||
# recuperation des paramettre
|
||||
mydata = {}
|
||||
my_external_code = ""
|
||||
my_token = ""
|
||||
my_internal_url = ""
|
||||
|
||||
if ("internal_url" in diction.keys()):
|
||||
if diction['internal_url']:
|
||||
my_internal_url = diction['internal_url']
|
||||
|
||||
if ("external_code" in diction.keys()):
|
||||
if diction['external_code']:
|
||||
my_external_code = diction['external_code']
|
||||
|
||||
if ("token" in diction.keys()):
|
||||
if diction['token']:
|
||||
my_token = diction['token']
|
||||
|
||||
# Verifier la validité du token
|
||||
|
||||
retval = mycommon.check_partner_token_validity("", my_token)
|
||||
if retval is False:
|
||||
return "Err_Connexion", " La session de connexion n'est pas valide"
|
||||
|
||||
local_status, my_partner = mycommon.Check_Connexion_And_Return_Partner_Data({'token': str(diction['token'])})
|
||||
if (local_status is not True):
|
||||
return local_status, my_partner
|
||||
|
||||
user_recid = str(my_partner['recid'])
|
||||
'''
|
||||
Gestion des filters.
|
||||
'''
|
||||
|
||||
internal_url_crit = {}
|
||||
if ("internal_url" in diction.keys()):
|
||||
if diction['internal_url']:
|
||||
internal_url_crit['internal_url'] = diction['internal_url']
|
||||
|
||||
external_code_crit = {}
|
||||
if ("external_code" in diction.keys()):
|
||||
if diction['external_code']:
|
||||
external_code_crit['external_code'] = diction['external_code']
|
||||
|
||||
title_crit = {}
|
||||
if ("title" in diction.keys()):
|
||||
if diction['title']:
|
||||
title_crit['title'] = diction['title']
|
||||
|
||||
coll_name = MYSY_GV.dbname['myclass']
|
||||
|
||||
# verifier que le token et l'email sont ok
|
||||
coll_token = MYSY_GV.dbname['user_token']
|
||||
|
||||
# Verification de la validité du token dans le cas des user en mode connecté
|
||||
'''
|
||||
/!\ Important : le token ne doit jamais etre vide car cette fonction a pour objectif
|
||||
de retourner les formations edité par un partenaire.
|
||||
|
||||
Il dont obligatoirement est en mode connecté
|
||||
'''
|
||||
|
||||
user_recid = "None"
|
||||
# Verification de la validité du token/mail dans le cas des user en mode connecté
|
||||
if (len(str(my_token)) > 0):
|
||||
retval = mycommon.check_partner_token_validity("", my_token)
|
||||
|
||||
if retval is False:
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - La session de connexion n'est pas valide")
|
||||
return False, " Impossible de récupérer la formation"
|
||||
|
||||
# Recuperation du recid de l'utilisateur
|
||||
user_recid = mycommon.get_parnter_recid_from_token(my_token)
|
||||
if user_recid is False:
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - Impossible de récupérer le token de l'utilisateur")
|
||||
return False, " Impossible de récupérer la formation"
|
||||
|
||||
if (len(str(my_token)) <= 0):
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - Le token est vide")
|
||||
return False, " Impossible de récupérer la formation"
|
||||
|
||||
RetObject = []
|
||||
filt_external_code = {}
|
||||
if ("external_code" in diction.keys()):
|
||||
filt_external_code = {'external_code': str(diction['external_code'])}
|
||||
|
||||
# print(" GRRRRRRRRRRRRR "+str(filt_external_code))
|
||||
|
||||
filt_title = {}
|
||||
if ("title" in diction.keys()):
|
||||
filt_title = {'title': str(diction['title'])}
|
||||
|
||||
filt_internal_url = {}
|
||||
if ("internal_url" in diction.keys()):
|
||||
filt_internal_url = {'internal_url': str(diction['internal_url'])}
|
||||
|
||||
filt_archive = {}
|
||||
if ("archive" in diction.keys() and (diction["archive"] == "0" or diction["archive"] == "")):
|
||||
filt_archive = {'archive': {'$ne': '1'}}
|
||||
|
||||
elif ("archive" in diction.keys() and diction["archive"] == "1"):
|
||||
filt_archive = {'archive': '1'}
|
||||
|
||||
"""
|
||||
print(" ATTTTENNTION : GESTION DU CAS OU LA PERSONNE QUI CHERCHE LE COURS EST UN UTILISATEUR : PB avec : partner_owner_recid ")
|
||||
print(" #### avant requete get partner_owner_recid ="+str(user_recid)+
|
||||
" filt_external_code = "+str(filt_external_code)+
|
||||
" filt_internal_url = " + str(filt_internal_url) +
|
||||
" filt_title = "+str(filt_title))
|
||||
"""
|
||||
|
||||
val_tmp = 1
|
||||
nb_hour_per_day = mycommon.Get_Partner_Hour_Per_Day(str(my_partner['recid']))
|
||||
if (nb_hour_per_day is False):
|
||||
nb_hour_per_day = "7"
|
||||
|
||||
currency = mycommon.Get_Partner_Currency(str(my_partner['recid']))
|
||||
if (currency is False):
|
||||
currency = ""
|
||||
|
||||
|
||||
|
||||
for retVal in coll_name.find({"$and": [{'valide': '1'}, {'locked': '0'},
|
||||
{'partner_owner_recid': user_recid},
|
||||
filt_external_code, filt_title, filt_internal_url,
|
||||
filt_archive]},
|
||||
{'indexed': 0, 'indexed_desc': 0,
|
||||
'indexed_obj': 0, 'indexed_title': 0, }
|
||||
).sort([("_id", pymongo.DESCENDING), ]):
|
||||
|
||||
# print(" #### retVal = ", retVal)
|
||||
if ("title" not in retVal.keys()):
|
||||
retVal['title'] = ""
|
||||
|
||||
if ("referentiel_padagogique_id" not in retVal.keys()):
|
||||
retVal['referentiel_padagogique_id'] = ""
|
||||
|
||||
if ("domain" not in retVal.keys()):
|
||||
retVal['domain'] = ""
|
||||
|
||||
if ("metier" not in retVal.keys()):
|
||||
retVal['metier'] = ""
|
||||
|
||||
if ("version" not in retVal.keys()):
|
||||
retVal['version'] = ""
|
||||
|
||||
if ("categorie" not in retVal.keys()):
|
||||
retVal['categorie'] = ""
|
||||
|
||||
if ("duration" not in retVal.keys()):
|
||||
retVal['duration'] = ""
|
||||
|
||||
if ("duration_unit" not in retVal.keys()):
|
||||
retVal['duration_unit'] = ""
|
||||
|
||||
if ("pourqui" not in retVal.keys()):
|
||||
retVal['pourqui'] = ""
|
||||
|
||||
if ("presentiel" not in retVal.keys()):
|
||||
retVal['presentiel'] = {'presentiel': '0', 'distantiel': '0'}
|
||||
|
||||
if ("price" not in retVal.keys()):
|
||||
retVal['price'] = "0"
|
||||
|
||||
if ("description" not in retVal.keys()):
|
||||
retVal['description'] = ""
|
||||
|
||||
if ("published" not in retVal.keys()):
|
||||
retVal['published'] = "0"
|
||||
|
||||
if ("archive" not in retVal.keys()):
|
||||
retVal['archive'] = "0"
|
||||
|
||||
if ("lms_class_code" not in retVal.keys()):
|
||||
retVal['lms_class_code'] = "0"
|
||||
|
||||
if ("recyclage_delai" not in retVal.keys()):
|
||||
retVal['recyclage_delai'] = ""
|
||||
|
||||
if ("recyclage_alert" not in retVal.keys()):
|
||||
retVal['recyclage_alert'] = ""
|
||||
|
||||
if ("recyclage_periodicite" not in retVal.keys()):
|
||||
retVal['recyclage_periodicite'] = ""
|
||||
|
||||
if ("note_finale_calculation_rule_id" not in retVal.keys()):
|
||||
retVal['note_finale_calculation_rule_id'] = ""
|
||||
|
||||
# Recuperation des données du formateur
|
||||
formateur_nom_prenom = ""
|
||||
# Si il y a un code formateur_id, alors on va recuperer les nom et prenom du formation
|
||||
if ("formateur_id" in retVal.keys() and retVal['formateur_id']):
|
||||
|
||||
formateur_data = MYSY_GV.dbname['ressource_humaine'].find_one(
|
||||
{'_id': ObjectId(str(retVal['formateur_id'])),
|
||||
'valide': '1',
|
||||
'locked': '0',
|
||||
'partner_recid': str(my_partner['recid'])
|
||||
})
|
||||
|
||||
if (formateur_data and "nom" in formateur_data.keys() and "prenom" in formateur_data.keys()):
|
||||
formateur_nom_prenom = str(formateur_data['nom']) + " " + str(formateur_data['prenom'])
|
||||
|
||||
retVal['formateur_nom_prenom'] = formateur_nom_prenom
|
||||
|
||||
# Recuperation des données du niveau de class
|
||||
class_level_description = ""
|
||||
# Si il y a un code class_level, alors on va recuperer la description
|
||||
if ("class_level" in retVal.keys() and retVal['class_level']):
|
||||
|
||||
class_level_data = MYSY_GV.dbname['class_niveau_formation'].find_one(
|
||||
{'code': str(retVal['class_level']),
|
||||
'valide': '1',
|
||||
'locked': '0',
|
||||
'partner_owner_recid': 'default'
|
||||
})
|
||||
|
||||
if (class_level_data and "description" in class_level_data.keys()):
|
||||
class_level_description = str(class_level_data['description'])
|
||||
|
||||
retVal['class_level_description'] = class_level_description
|
||||
|
||||
# Recuperer le nombre de session pour cette formation
|
||||
nb_session_formation_count = MYSY_GV.dbname['session_formation'].count_documents(
|
||||
{'class_internal_url': str(retVal['internal_url']),
|
||||
'valide': '1',
|
||||
'partner_owner_recid': str(my_partner['recid'])})
|
||||
retVal['nb_session_formation'] = nb_session_formation_count
|
||||
|
||||
user = retVal
|
||||
user['id'] = str(val_tmp)
|
||||
|
||||
'''
|
||||
Pour des facilité d'affichage coté front
|
||||
on va reformater le champ "zone_diffusion" de sorte à le renvoyer
|
||||
sous la forme "code_pays-ville"
|
||||
'''
|
||||
i = 0
|
||||
tmp_zone_diffusion = ""
|
||||
if ("zone_diffusion" in user.keys()):
|
||||
if (user['zone_diffusion'] and user['zone_diffusion']["city"]):
|
||||
for tmp_val in user['zone_diffusion']["city"]:
|
||||
tmp_zone_diffusion = tmp_zone_diffusion + str(user['zone_diffusion']["country"][i]) + "-" + str(
|
||||
user['zone_diffusion']["city"][i]) + ";"
|
||||
i = i + 1
|
||||
|
||||
user['zone_diffusion_str'] = str(tmp_zone_diffusion[:-1])
|
||||
|
||||
if ("duration" in user.keys() and "duration_unit" in user.keys() and str(user['duration_unit']) == "jour"):
|
||||
duration_in_hour = mycommon.tryFloat(user['duration']) * mycommon.tryFloat(nb_hour_per_day)
|
||||
if (duration_in_hour):
|
||||
user['duration_in_hour'] = str(duration_in_hour)
|
||||
else:
|
||||
user['duration_in_hour'] = ""
|
||||
|
||||
user['currecny'] = currency
|
||||
|
||||
RetObject.append(JSONEncoder().encode(user))
|
||||
val_tmp = val_tmp + 1
|
||||
|
||||
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 formation"
|
||||
|
||||
|
||||
"""
|
||||
Cette fonction recherche des formations avec une recherche large (like %value%)
|
||||
"""
|
||||
|
|
64
main.py
64
main.py
|
@ -503,6 +503,22 @@ def get_partner_class_external_code():
|
|||
|
||||
|
||||
|
||||
"""
|
||||
Cette API retourne les formation d'un partenaire SANS tenir compte du scope de celui qui fait appel.
|
||||
Cette fonction est utilisé pour definir le scope d'un user (il faut d'abord voir tout pour fixer un scope)
|
||||
"""
|
||||
@app.route('/myclass/api/get_partner_class_Without_Scope_Action/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def get_partner_class_Without_Scope_Action():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### get_partner_class_Without_Scope_Action payload = ",str(payload)+" IP requester = "+str(request.remote_addr))
|
||||
status, retval = cm.get_partner_class_Without_Scope_Action(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@app.route('/myclass/api/update_class/', methods=['POST'])
|
||||
@crossdomain(origin='*')
|
||||
|
@ -2401,6 +2417,25 @@ def GetAllValideSessionFormation_List():
|
|||
localStatus, message= SF.GetAllValideSessionFormation_List(payload)
|
||||
return jsonify(status=localStatus, message=message )
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Cette API recupere toutes les sessions de formation d'un partneaire
|
||||
Cette fonction est utilisé pour definir le scope d'un user (il faut d'abord voir tout pour fixer un scope)
|
||||
"""
|
||||
@app.route('/myclass/api/GetAllValideSessionPartner_List_Without_Scope_Action/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def GetAllValideSessionPartner_List_Without_Scope_Action():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### GetAllValideSessionPartner_List_Without_Scope_Action : payload = ",str(payload))
|
||||
localStatus, message= SF.GetAllValideSessionPartner_List_Without_Scope_Action(payload)
|
||||
return jsonify(status=localStatus, message=message )
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Cette API recupere toutes les sessions de formation d'un partneaire
|
||||
"""
|
||||
|
@ -6897,6 +6932,35 @@ def Get_Matrix_Acces_Right_By_Profil():
|
|||
|
||||
|
||||
|
||||
"""
|
||||
API qui permet de mettre à jour le scope (droit d'acces) de l'utilisateur
|
||||
"""
|
||||
@app.route('/myclass/api/Add_Update_User_Access_Scope/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Add_Update_User_Access_Scope():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Add_Update_User_Access_Scope payload = ",payload)
|
||||
status, retval = user_access_right.Add_Update_User_Access_Scope(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
|
||||
"""
|
||||
API qui permet de recuperer le scope (droit d'acces) de l'utilisateur
|
||||
"""
|
||||
@app.route('/myclass/api/Get_User_Access_Scope/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Get_User_Access_Scope():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Get_User_Access_Scope payload = ",payload)
|
||||
status, retval = user_access_right.Get_User_Access_Scope(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Ajout et mise à jour des droits d'acces d'un user (ressource_humaine_id)
|
||||
"""
|
||||
|
|
|
@ -692,10 +692,7 @@ def Get_Given_Unite_Enseignement(diction):
|
|||
local_node['_id'] = str(local_competence_data['_id'])
|
||||
local_node['code'] = str(local_competence_data['code'])
|
||||
local_node['label'] = str(local_competence_data['code'])
|
||||
|
||||
tab_competence_JSON.append(local_node)
|
||||
|
||||
|
||||
local_cpt = local_cpt +1
|
||||
|
||||
|
||||
|
|
|
@ -448,7 +448,7 @@ def Get_Matrix_Acces_Right_By_Profil_SAVE(diction):
|
|||
val_tmp = val_tmp + 1
|
||||
RetObject.append(mycommon.JSONEncoder().encode(user))
|
||||
|
||||
print(" RetObject = ", RetObject)
|
||||
#print(" RetObject = ", RetObject)
|
||||
return True, RetObject
|
||||
|
||||
|
||||
|
@ -456,3 +456,256 @@ def Get_Matrix_Acces_Right_By_Profil_SAVE(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 récupérer la matrice des droits "
|
||||
|
||||
|
||||
"""
|
||||
Cette fonction permet de mettre à jour le perimetre (scope)
|
||||
d'un utilisateur :
|
||||
"scope": {
|
||||
"class_id": [
|
||||
"6655b721fd47c656dcaf8f05", ==> class_id
|
||||
"66def22a19f54d3436deac0f",==> class_id
|
||||
]
|
||||
"session_id": [
|
||||
"68470d385546307026f07573", ==> session_id
|
||||
"684559896c259f02cb52b5bc",==> session_id
|
||||
]
|
||||
}
|
||||
|
||||
algo :
|
||||
- a chaque fois, on supprime tout et on ajoute tout.
|
||||
donc le front doit envoyer tout le scope à chaque fois
|
||||
|
||||
"""
|
||||
|
||||
def Add_Update_User_Access_Scope(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', 'user_id', 'tab_scope_class', 'tab_scope_session']
|
||||
|
||||
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', 'user_id', 'tab_scope_class', 'tab_scope_session']
|
||||
|
||||
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
|
||||
|
||||
# Verification de la validide du partnair_account
|
||||
is_partnair_account_existe_count = MYSY_GV.dbname['partnair_account'].count_documents({'ressource_humaine_id':str(diction['user_id']),
|
||||
'recid':str(my_partner['recid']),
|
||||
'active':'1',
|
||||
'locked':'0'})
|
||||
|
||||
if( is_partnair_account_existe_count != 1 ):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " - L'utilisateur est invalide ")
|
||||
return False, " L'utilisateur est invalide ",
|
||||
|
||||
partnair_account_data = MYSY_GV.dbname['partnair_account'].find_one(
|
||||
{'ressource_humaine_id': str(diction['user_id']),
|
||||
'recid': str(my_partner['recid']),
|
||||
'active': '1',
|
||||
'locked': '0'})
|
||||
|
||||
|
||||
## Verifier la valididité des elements fournis dans le scope
|
||||
tab_scope_class_work = str(diction['tab_scope_class']).split(",")
|
||||
tab_scope_class = []
|
||||
for tmp in tab_scope_class_work:
|
||||
if( tmp ):
|
||||
is_class_count = MYSY_GV.dbname['myclass'].count_documents({'_id':ObjectId(str(tmp)), 'partner_owner_recid':str(my_partner['recid'])})
|
||||
if(is_class_count != 1):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " La formation avec l'_id "+str(tmp)+" est invalide ")
|
||||
return False, " La formation avec l'_id "+str(tmp)+" est invalide "
|
||||
|
||||
tab_scope_class.append(str(tmp))
|
||||
|
||||
tab_scope_session_work = str(diction['tab_scope_session']).split(",")
|
||||
tab_scope_session = []
|
||||
for tmp in tab_scope_session_work:
|
||||
if (tmp):
|
||||
is_session_count = MYSY_GV.dbname['session_formation'].count_documents(
|
||||
{'_id': ObjectId(str(tmp)), 'partner_owner_recid': str(my_partner['recid'])})
|
||||
if (is_session_count != 1):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " La session ou promotion avec l'_id " + str(tmp) + " est invalide ")
|
||||
return False, " La session ou promotion avec l'_id " + str(tmp) + " est invalide "
|
||||
|
||||
tab_scope_session.append(str(tmp))
|
||||
|
||||
|
||||
new_data = {}
|
||||
new_data['scope'] = {}
|
||||
new_data['scope']['class_id'] = tab_scope_class
|
||||
new_data['scope']['session_id'] =tab_scope_session
|
||||
|
||||
new_data['date_update'] = str(datetime.now())
|
||||
new_data['update_by'] = str(my_partner['_id'])
|
||||
|
||||
|
||||
result = MYSY_GV.dbname['partnair_account'].find_one_and_update(
|
||||
{'ressource_humaine_id': str(diction['user_id']),
|
||||
'recid': str(my_partner['recid']),
|
||||
'active': '1',
|
||||
'locked': '0'},
|
||||
{"$set": new_data},
|
||||
upsert=False,
|
||||
return_document=ReturnDocument.AFTER
|
||||
)
|
||||
|
||||
if (result is None or "_id" not in result.keys()):
|
||||
mycommon.myprint(
|
||||
" Impossible mettre à jour les droits d'acces du user_id" + str(diction['user_id']))
|
||||
return False, " Impossible mettre à jour les droits d'acces (2) "
|
||||
|
||||
"""
|
||||
# Ajout de l'evenement dans l'historique
|
||||
"""
|
||||
now = str(datetime.now().strftime("%d/%m/%Y %H:%M:%S"))
|
||||
history_event_dict = {}
|
||||
history_event_dict['token'] = str(diction['token'])
|
||||
history_event_dict['related_collection'] = "ressource_humaine"
|
||||
history_event_dict['related_collection_recid'] = str(diction['user_id'])
|
||||
history_event_dict['action_date'] = str(now)
|
||||
history_event_dict['technical_comment'] = "Nouveaux perimetre d'acces : class_id = "+ str(tab_scope_class)+", session_id = "+str(tab_scope_session)
|
||||
history_event_dict['action_description'] = " Mise à jour du perimetre d'acces "
|
||||
local_status, local_retval = mycommon.Collection_Historique.Add_Historique_Event(history_event_dict)
|
||||
if (local_status is False):
|
||||
mycommon.myprint(
|
||||
" WARNING : Impossible de logguer l'historique : " + str(diction['user_id']) )
|
||||
|
||||
return True, " Les droits d'accès ont é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 les droits d'accès "
|
||||
|
||||
|
||||
"""
|
||||
Cette fonction recuperer le scope d'acces d'un user
|
||||
"""
|
||||
def Get_User_Access_Scope(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', 'user_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', 'user_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
|
||||
|
||||
partnair_account_data = MYSY_GV.dbname['partnair_account'].find_one(
|
||||
{'ressource_humaine_id': str(diction['user_id']),
|
||||
'recid': str(my_partner['recid']),
|
||||
'active': '1',
|
||||
'locked': '0'})
|
||||
|
||||
tab_node_class = []
|
||||
node_current_scope = {}
|
||||
tab_node_session = []
|
||||
|
||||
|
||||
if( partnair_account_data and 'scope' in partnair_account_data.keys()):
|
||||
# traitement de class
|
||||
if("class_id" in partnair_account_data['scope'].keys() ):
|
||||
## Verifier la valididité des elements fournis dans le scope
|
||||
# tab_scope_class_work = str(partnair_account_data['scope']['class_id']).split(",")
|
||||
tab_scope_class = []
|
||||
cpt = 0
|
||||
for tmp in partnair_account_data['scope']['class_id']:
|
||||
if (tmp):
|
||||
class_data = MYSY_GV.dbname['myclass'].find_one({'_id': ObjectId(str(tmp)), 'partner_owner_recid': str(my_partner['recid'])},
|
||||
{'_id':1, 'title':1, 'external_code':1})
|
||||
if (class_data and 'external_code' in class_data.keys() ):
|
||||
class_data['id'] = str(cpt)
|
||||
class_data['label'] = str(class_data['external_code'])
|
||||
tab_node_class.append(class_data)
|
||||
cpt = cpt + 1
|
||||
|
||||
|
||||
|
||||
cpt = 0
|
||||
for tmp in partnair_account_data['scope']['session_id']:
|
||||
if (tmp):
|
||||
session_data = MYSY_GV.dbname['session_formation'].find_one(
|
||||
{'_id': ObjectId(str(tmp)), 'partner_owner_recid': str(my_partner['recid'])},
|
||||
{'_id': 1, 'titre': 1, 'code_session': 1})
|
||||
if (session_data and 'code_session' in session_data.keys()):
|
||||
session_data['id'] = str(cpt)
|
||||
session_data['label'] = str(session_data['code_session'])
|
||||
tab_node_session.append(session_data)
|
||||
cpt = cpt + 1
|
||||
|
||||
node_current_scope['node_class'] = tab_node_class
|
||||
node_current_scope['node_session'] = tab_node_session
|
||||
|
||||
RetObject = []
|
||||
RetObject.append(mycommon.JSONEncoder().encode(node_current_scope))
|
||||
|
||||
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 le perimetre d'accès "
|
||||
|
|
Loading…
Reference in New Issue