parent
bc426a6dfe
commit
eb5a3cb462
|
|
@ -4,13 +4,18 @@
|
|||
<option name="autoReloadType" value="SELECTIVE" />
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="28/02/26 - 23h">
|
||||
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="01/03/26 - 13h30">
|
||||
<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$/attached_file_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/attached_file_mgt.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/class_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/class_mgt.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Session_Formation.py" beforeDir="false" afterPath="$PROJECT_DIR$/Session_Formation.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/ent_student_common.py" beforeDir="false" afterPath="$PROJECT_DIR$/ent_student_common.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/lms_chamilo/mysy_lms.py" beforeDir="false" afterPath="$PROJECT_DIR$/lms_chamilo/mysy_lms.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/prj_common.py" beforeDir="false" afterPath="$PROJECT_DIR$/prj_common.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/ressources_humaines.py" beforeDir="false" afterPath="$PROJECT_DIR$/ressources_humaines.py" afterDir="false" />
|
||||
<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$/user_session.py" beforeDir="false" afterPath="$PROJECT_DIR$/user_session.py" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
|
|
@ -454,7 +459,7 @@
|
|||
<option name="project" value="LOCAL" />
|
||||
<updated>1747251650255</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="544" />
|
||||
<option name="localTasksCounter" value="545" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="Vcs.Log.Tabs.Properties">
|
||||
|
|
@ -496,7 +501,6 @@
|
|||
</option>
|
||||
</component>
|
||||
<component name="VcsManagerConfiguration">
|
||||
<MESSAGE value="07/12/25 - 14h" />
|
||||
<MESSAGE value="13/12/25 - 14h" />
|
||||
<MESSAGE value="15/12/25 - 13h" />
|
||||
<MESSAGE value="02/01/26 - 13h" />
|
||||
|
|
@ -521,6 +525,7 @@
|
|||
<MESSAGE value="27/02/26 - 19h30" />
|
||||
<MESSAGE value="28/02/26 - 22h" />
|
||||
<MESSAGE value="28/02/26 - 23h" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="28/02/26 - 23h" />
|
||||
<MESSAGE value="01/03/26 - 13h30" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="01/03/26 - 13h30" />
|
||||
</component>
|
||||
</project>
|
||||
|
|
@ -9710,7 +9710,7 @@ def Get_Statgaire_List_Partner_with_filter(diction):
|
|||
try:
|
||||
field_list = ['token', 'class_internal_url', 'code_session', 'status', 'email', 'nom',
|
||||
'class_title', 'code_session', 'client_nom', 'client_rattachement_id',
|
||||
'session_id', 'archive']
|
||||
'session_id', 'archive', 'invoiced']
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
if val not in field_list and val.startswith('my_') is False:
|
||||
|
|
@ -9838,6 +9838,13 @@ def Get_Statgaire_List_Partner_with_filter(diction):
|
|||
if ("session_id" in diction.keys()):
|
||||
filt_session_id = {'session_id': str(diction['session_id'])}
|
||||
|
||||
filt_invoiced = {}
|
||||
if ("invoiced" in diction.keys() and str(diction['invoiced']).strip() == "1"):
|
||||
filt_invoiced = {'invoiced': str(diction['invoiced'])}
|
||||
|
||||
if ("invoiced" in diction.keys() and str(diction['invoiced']).strip() != "1" ):
|
||||
filt_invoiced = {'invoiced': {'$ne':'1'} }
|
||||
|
||||
# -----
|
||||
|
||||
filt_client_nom = {}
|
||||
|
|
@ -9859,7 +9866,7 @@ def Get_Statgaire_List_Partner_with_filter(diction):
|
|||
query = [{'$match': {
|
||||
'$and': [filt_archive, filt_class_internal_url, filt_session_code, filt_email, filt_nom, filt_client_nom,
|
||||
filt_client_rattachement_id,
|
||||
filt_session_id, {'partner_owner_recid': str(partner_recid), 'valide': '1'}]}},
|
||||
filt_session_id, filt_invoiced, {'partner_owner_recid': str(partner_recid), 'valide': '1'}]}},
|
||||
{'$sort': {'_id': -1}},
|
||||
{'$lookup':
|
||||
{
|
||||
|
|
@ -10151,130 +10158,53 @@ def Get_Statgaire_List_Partner_with_filter(diction):
|
|||
val['nb_jour_avant_recyclage'] = ""
|
||||
val['warning_recyclage'] = "0"
|
||||
|
||||
if (retVal['status'] == "1" and (
|
||||
"recyclage_managed" not in retVal.keys() or retVal['recyclage_managed'] != "1")):
|
||||
|
||||
if ("recyclage_delai" in retVal['myclass_collection'][0].keys()):
|
||||
val['class_recyclage_delai'] = retVal['myclass_collection'][0]['recyclage_delai']
|
||||
|
||||
if ("recyclage_periodicite" in retVal['myclass_collection'][0].keys()):
|
||||
val['class_recyclage_periodicite'] = retVal['myclass_collection'][0][
|
||||
'recyclage_periodicite']
|
||||
|
||||
if ("recyclage_alert" in retVal['myclass_collection'][0].keys()):
|
||||
val['class_recyclage_alert'] = retVal['myclass_collection'][0]['recyclage_alert']
|
||||
|
||||
if (str(val['class_recyclage_delai']) != "" and str(
|
||||
val['class_recyclage_periodicite']) != "" and str(val['class_recyclage_alert']) != ""):
|
||||
session_date_debut = str(session_retval['date_debut'])[0:10]
|
||||
session_date_debut_datetime = datetime.strptime(str(session_date_debut).strip(), '%d/%m/%Y')
|
||||
if (str(val['class_recyclage_periodicite']) == "mois"):
|
||||
class_recyclage_delai_int = mycommon.tryInt(str(val['class_recyclage_delai']))
|
||||
session_date_debut_datetime = session_date_debut_datetime + relativedelta(
|
||||
months=+class_recyclage_delai_int)
|
||||
|
||||
elif (str(val['class_recyclage_periodicite']) == "annee"):
|
||||
class_recyclage_delai_int = mycommon.tryInt(str(val['class_recyclage_delai']))
|
||||
session_date_debut_datetime = session_date_debut_datetime + relativedelta(
|
||||
years=+class_recyclage_delai_int)
|
||||
|
||||
mytoday = datetime.today().strftime("%d/%m/%Y")
|
||||
mytoday_datetime = datetime.strptime(str(mytoday).strip(), '%d/%m/%Y')
|
||||
|
||||
local_delta = session_date_debut_datetime - mytoday_datetime
|
||||
val['nb_jour_avant_recyclage'] = str(local_delta.days)
|
||||
|
||||
if (local_delta.days < mycommon.tryInt(str(val['class_recyclage_alert']))):
|
||||
val['warning_recyclage'] = "1"
|
||||
|
||||
"""
|
||||
Important : : 28/12/2023 - update
|
||||
S'il y a de la data dans la collection 'apprenant_collection' cela veut dire qu'il y a un dossier apprenant,
|
||||
alors on va plutot retourner les info qui sont dans cette collection
|
||||
|
||||
Important : 31/07/2024 - annulation de la recheche de l'apprenant
|
||||
if ('apprenant_collection' in retVal.keys() and len( retVal['apprenant_collection']) > 0):
|
||||
if ("civilite" in retVal['apprenant_collection'][0].keys()):
|
||||
val['civilite'] = str(retVal['apprenant_collection'][0]['civilite']).lower()
|
||||
else:
|
||||
val['civilite'] = ""
|
||||
|
||||
if (str(val['civilite']) not in MYSY_GV.CIVILITE):
|
||||
val['civilite'] = "neutre"
|
||||
|
||||
local_nom = ""
|
||||
if ("nom" in retVal['apprenant_collection'][0].keys()):
|
||||
local_nom = retVal['apprenant_collection'][0]['nom']
|
||||
val['nom'] = local_nom
|
||||
|
||||
local_prenom = ""
|
||||
if ("prenom" in retVal['apprenant_collection'][0].keys()):
|
||||
local_prenom = retVal['apprenant_collection'][0]['prenom']
|
||||
val['prenom'] = local_prenom
|
||||
|
||||
if ("date_naissance" in retVal['apprenant_collection'][0].keys()):
|
||||
val['date_naissance'] = retVal['apprenant_collection'][0]['date_naissance']
|
||||
else:
|
||||
val['date_naissance'] = ""
|
||||
|
||||
if ("adresse" in retVal['apprenant_collection'][0].keys()):
|
||||
val['adresse'] = retVal['apprenant_collection'][0]['adresse']
|
||||
else:
|
||||
val['adresse'] = ""
|
||||
|
||||
if ("code_postal" in retVal['apprenant_collection'][0].keys()):
|
||||
val['code_postal'] = retVal['apprenant_collection'][0]['code_postal']
|
||||
else:
|
||||
val['code_postal'] = ""
|
||||
|
||||
if ("ville" in retVal['apprenant_collection'][0].keys()):
|
||||
val['ville'] = retVal['apprenant_collection'][0]['ville']
|
||||
else:
|
||||
val['ville'] = ""
|
||||
|
||||
if ("pays" in retVal['apprenant_collection'][0].keys()):
|
||||
val['pays'] = retVal['apprenant_collection'][0]['pays']
|
||||
else:
|
||||
val['pays'] = ""
|
||||
local_class_recyclage = "0"
|
||||
local_class_recyclage_float = 0
|
||||
if ('myclass_collection' in retVal.keys() and len(retVal['myclass_collection']) > 0
|
||||
and "recyclage_alert" in retVal['myclass_collection'][0].keys()
|
||||
and retVal['myclass_collection'][0]['recyclage_alert'] ):
|
||||
local_class_recyclage = retVal['myclass_collection'][0]['recyclage_alert']
|
||||
local_class_recyclage_float = mycommon.tryFloat(str(retVal['myclass_collection'][0]['recyclage_alert']))
|
||||
|
||||
|
||||
if( local_class_recyclage_float > 0 ):
|
||||
if (retVal['status'] == "1" and (
|
||||
"recyclage_managed" not in retVal.keys() or retVal['recyclage_managed'] != "1")):
|
||||
|
||||
local_employeur = ""
|
||||
if ("employeur" in retVal['apprenant_collection'][0].keys()):
|
||||
local_employeur = retVal['apprenant_collection'][0]['employeur']
|
||||
val['employeur'] = local_employeur
|
||||
if ("recyclage_delai" in retVal['myclass_collection'][0].keys()):
|
||||
val['class_recyclage_delai'] = retVal['myclass_collection'][0]['recyclage_delai']
|
||||
|
||||
local_telephone = ""
|
||||
if ("telephone" in retVal['apprenant_collection'][0].keys()):
|
||||
local_telephone = retVal['apprenant_collection'][0]['telephone']
|
||||
val['telephone'] = local_telephone
|
||||
if ("recyclage_periodicite" in retVal['myclass_collection'][0].keys()):
|
||||
val['class_recyclage_periodicite'] = retVal['myclass_collection'][0][
|
||||
'recyclage_periodicite']
|
||||
|
||||
local_email = ""
|
||||
if ("email" in retVal['apprenant_collection'][0].keys()):
|
||||
local_email = retVal['apprenant_collection'][0]['email']
|
||||
val['email'] = local_email
|
||||
if ("recyclage_alert" in retVal['myclass_collection'][0].keys()):
|
||||
val['class_recyclage_alert'] = retVal['myclass_collection'][0]['recyclage_alert']
|
||||
|
||||
local_adresse = ""
|
||||
if ("adresse" in retVal['apprenant_collection'][0].keys()):
|
||||
local_adresse = retVal['apprenant_collection'][0]['adresse']
|
||||
val['adresse'] = local_adresse
|
||||
if (str(val['class_recyclage_delai']) != "" and str(
|
||||
val['class_recyclage_periodicite']) != "" and str(val['class_recyclage_alert']) != ""):
|
||||
session_date_debut = str(session_retval['date_debut'])[0:10]
|
||||
session_date_debut_datetime = datetime.strptime(str(session_date_debut).strip(), '%d/%m/%Y')
|
||||
if (str(val['class_recyclage_periodicite']) == "mois"):
|
||||
class_recyclage_delai_int = mycommon.tryInt(str(val['class_recyclage_delai']))
|
||||
session_date_debut_datetime = session_date_debut_datetime + relativedelta(
|
||||
months=+class_recyclage_delai_int)
|
||||
|
||||
if ("ville" in retVal['apprenant_collection'][0].keys()):
|
||||
val['ville'] = retVal['apprenant_collection'][0]['ville']
|
||||
else:
|
||||
val['ville'] = ""
|
||||
elif (str(val['class_recyclage_periodicite']) == "annee"):
|
||||
class_recyclage_delai_int = mycommon.tryInt(str(val['class_recyclage_delai']))
|
||||
session_date_debut_datetime = session_date_debut_datetime + relativedelta(
|
||||
years=+class_recyclage_delai_int)
|
||||
|
||||
if ("code_postal" in retVal['apprenant_collection'][0].keys()):
|
||||
val['code_postal'] = retVal['apprenant_collection'][0]['code_postal']
|
||||
else:
|
||||
val['code_postal'] = ""
|
||||
mytoday = datetime.today().strftime("%d/%m/%Y")
|
||||
mytoday_datetime = datetime.strptime(str(mytoday).strip(), '%d/%m/%Y')
|
||||
|
||||
local_delta = session_date_debut_datetime - mytoday_datetime
|
||||
val['nb_jour_avant_recyclage'] = str(local_delta.days)
|
||||
|
||||
if (local_delta.days < mycommon.tryInt(str(val['class_recyclage_alert']))):
|
||||
val['warning_recyclage'] = "1"
|
||||
|
||||
if ("pays" in retVal['apprenant_collection'][0].keys()):
|
||||
val['pays'] = retVal['apprenant_collection'][0]['pays']
|
||||
else:
|
||||
val['pays'] = ""
|
||||
|
||||
"""
|
||||
|
||||
RetObject.append(mycommon.JSONEncoder().encode(val))
|
||||
|
||||
|
|
|
|||
19670
Log/log_file.log
19670
Log/log_file.log
File diff suppressed because it is too large
Load Diff
|
|
@ -863,7 +863,7 @@ def Update_SessionFormation_Only_Step(diction):
|
|||
history_event_dict['related_collection'] = "session_formation"
|
||||
history_event_dict['related_collection_recid'] = str(ret_val['_id'])
|
||||
history_event_dict['action_date'] = str(now)
|
||||
history_event_dict['action_description'] = "Mise à jour : Session Etape passe à "+str(diction['session_etape'])
|
||||
history_event_dict['action_description'] = "Mise à jour : Etape passe à "+str(diction['session_etape'])
|
||||
|
||||
|
||||
local_status, local_retval = mycommon.Collection_Historique.Add_Historique_Event(history_event_dict)
|
||||
|
|
@ -16951,6 +16951,8 @@ def Update_SessionFormation_Doc_Automatic_Setup(diction):
|
|||
'partner_owner_recid': str(
|
||||
my_partner['recid'])})
|
||||
|
||||
|
||||
"""
|
||||
if( "invoiced_statut" in is_valide_session_data.keys() and is_valide_session_data['invoiced_statut'] == '1'):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " - Cette session est partiellement facturée. Modification impossible ")
|
||||
|
|
@ -16961,7 +16963,7 @@ def Update_SessionFormation_Doc_Automatic_Setup(diction):
|
|||
str(inspect.stack()[0][
|
||||
3]) + " - Cette session est complètement facturée. Modification impossible ")
|
||||
return False, "Cette session est complètement facturée. Modification impossible"
|
||||
|
||||
"""
|
||||
|
||||
"""
|
||||
Verifier la validité du type de document 'courrier_template_type_document_ref_interne'
|
||||
|
|
@ -17030,12 +17032,12 @@ def Update_SessionFormation_Doc_Automatic_Setup(diction):
|
|||
" WARNING : Impossible de logguer l'historique pour l'évènement : " + str(history_event_dict))
|
||||
|
||||
|
||||
return True, " La promotion de formation à bien été mise à jour"
|
||||
return True, " La formation à bien été mise à jour"
|
||||
|
||||
except Exception as e:
|
||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
|
||||
return False, "Impossible mettre à jour La promotion de formation"
|
||||
return False, "Impossible mettre à jour la formation"
|
||||
|
||||
|
||||
"""
|
||||
|
|
@ -17182,15 +17184,7 @@ def Update_SessionFormation_Relance_Automation_Setup(diction):
|
|||
{"xxx._id": ObjectId(str(diction['automation_relance_frequence_relance_auto_id']))},
|
||||
]
|
||||
)
|
||||
print(" ## update 02 = ", update.modified_count)
|
||||
# config_name": 'relance_auto'
|
||||
print({'_id': ObjectId(str(diction['_id'])),
|
||||
'valide': '1',
|
||||
'partner_owner_recid': str(my_partner['recid']),
|
||||
'relance_automation._id': ObjectId(str(
|
||||
diction['automation_relance_relance_auto_id']))
|
||||
|
||||
})
|
||||
update = MYSY_GV.dbname['session_formation'].update_one({'_id': ObjectId(str(diction['_id'])),
|
||||
'valide': '1',
|
||||
'partner_owner_recid': str(my_partner['recid']),
|
||||
|
|
@ -17234,12 +17228,12 @@ def Update_SessionFormation_Relance_Automation_Setup(diction):
|
|||
mycommon.myprint(
|
||||
" WARNING : Impossible de logguer l'historique pour l'évènement : " + str(history_event_dict))
|
||||
|
||||
return True, " La promotion de formation à bien été mise à jour"
|
||||
return True, " La mise à jour à é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) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
|
||||
return False, "Impossible mettre à jour La promotion de formation"
|
||||
return False, "Impossible de faire la mise à jour "
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1857,7 +1857,8 @@ def Get_Ent_Student_update_user_account(diction):
|
|||
# field_list.
|
||||
'''
|
||||
field_list = ['adr_street', 'adr_city', 'adr_zip', 'adr_country', 'mob_phone','link_facebook',
|
||||
'link_twitter', 'token', 'prenom', 'nom', 'birthday','link_linkedin', 'apprenant_id']
|
||||
'link_twitter', 'token', 'prenom', 'nom', 'birthday','link_linkedin', 'apprenant_id',
|
||||
'type_connexion', 'rh_id']
|
||||
incom_keys=diction.keys()
|
||||
for val in incom_keys:
|
||||
if val not in field_list and val.startswith('my_') is False:
|
||||
|
|
@ -1868,7 +1869,7 @@ def Get_Ent_Student_update_user_account(diction):
|
|||
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', 'apprenant_id']
|
||||
field_list_obligatoire = ['token', 'type_connexion']
|
||||
for val in field_list_obligatoire :
|
||||
if val not in diction:
|
||||
mycommon.myprint(" La valeur '"+val+"' n'est pas presente dans la liste des arguments ")
|
||||
|
|
@ -1876,24 +1877,48 @@ def Get_Ent_Student_update_user_account(diction):
|
|||
|
||||
mycommon.myprint(" MAJ de diction "+str(diction))
|
||||
|
||||
"""
|
||||
Verifier la validité de l'apprenant
|
||||
"""
|
||||
is_apprenant_valide_count = MYSY_GV.dbname['apprenant'].count_documents(
|
||||
{'_id': ObjectId(str(diction['apprenant_id'])),
|
||||
'valide': '1',
|
||||
'locked': '0'})
|
||||
if( diction['type_connexion'] == "apprenant"):
|
||||
"""
|
||||
Verifier la validité de l'apprenant
|
||||
"""
|
||||
is_apprenant_valide_count = MYSY_GV.dbname['apprenant'].count_documents(
|
||||
{'_id': ObjectId(str(diction['apprenant_id'])),
|
||||
'valide': '1',
|
||||
'locked': '0'})
|
||||
|
||||
if (is_apprenant_valide_count != 1):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " L'identifiant de l'apprenant est invalide ")
|
||||
return False, " L'identifiant de l'apprenant est invalide ",
|
||||
|
||||
apprenant_data = MYSY_GV.dbname['apprenant'].find_one(
|
||||
{'_id': ObjectId(str(diction['apprenant_id'])),
|
||||
'valide': '1',
|
||||
'locked': '0'})
|
||||
|
||||
elif( diction['type_connexion'] == "tuteur"):
|
||||
|
||||
"""
|
||||
Verifier la validité de rh_id
|
||||
"""
|
||||
is_ressource_humaine_valide_count = MYSY_GV.dbname['ressource_humaine'].count_documents(
|
||||
{'_id': ObjectId(str(diction['rh_id'])),
|
||||
'valide': '1',
|
||||
'locked': '0'})
|
||||
|
||||
if (is_ressource_humaine_valide_count != 1):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " L'identifiant du tuteur est invalide ")
|
||||
return False, " L'identifiant du tuteur est invalide ",
|
||||
|
||||
ressource_humaine_data = MYSY_GV.dbname['ressource_humaine'].find_one(
|
||||
{'_id': ObjectId(str(diction['rh_id'])),
|
||||
'valide': '1',
|
||||
'locked': '0'})
|
||||
|
||||
if (is_apprenant_valide_count != 1):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " L'identifiant de l'apprenant est invalide ")
|
||||
return False, " L'identifiant de l'apprenant est invalide ",
|
||||
|
||||
apprenant_data = MYSY_GV.dbname['apprenant'].find_one(
|
||||
{'_id': ObjectId(str(diction['apprenant_id'])),
|
||||
'valide': '1',
|
||||
'locked': '0'})
|
||||
|
||||
|
||||
coll_name = MYSY_GV.dbname['user_account']
|
||||
|
|
@ -1970,38 +1995,50 @@ def Get_Ent_Student_update_user_account(diction):
|
|||
23/12/2024 : Après avoir verifier la validité du token,
|
||||
on va aller chercher l'_id dans la collection 'user_account'
|
||||
"""
|
||||
print(" ### QRY011 = ", {'token':str(diction['token']),
|
||||
'active':'1', 'locked':'0',
|
||||
'apprenant_id':diction['apprenant_id']})
|
||||
|
||||
|
||||
is_token_valide_for_one_user = MYSY_GV.dbname['user_account'].count_documents({'token':str(diction['token']),
|
||||
'active':'1', 'locked':'0',
|
||||
'apprenant_id':diction['apprenant_id']})
|
||||
})
|
||||
if( is_token_valide_for_one_user != 1 ):
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " Le token correspond a plusieurs au aucun utilisateur de la collection 'user_account' ")
|
||||
return False, "La session est invalide "
|
||||
|
||||
|
||||
print(" ## qry == ", {'token':str(diction['token']),
|
||||
'active':'1', 'locked':'0',
|
||||
'apprenant_id':diction['apprenant_id']})
|
||||
|
||||
|
||||
ret_val = coll_name.find_one_and_update({'token':str(diction['token']),
|
||||
'active':'1', 'locked':'0',
|
||||
'apprenant_id': diction['apprenant_id'],
|
||||
},
|
||||
{"$set": dictionnary },
|
||||
return_document=ReturnDocument.AFTER
|
||||
)
|
||||
if( diction['type_connexion'] == "tuteur"):
|
||||
ret_val = coll_name.find_one_and_update({'token':str(diction['token']),
|
||||
'active':'1', 'locked':'0',
|
||||
'rh_id': diction['rh_id'],
|
||||
},
|
||||
{"$set": dictionnary },
|
||||
return_document=ReturnDocument.AFTER
|
||||
)
|
||||
|
||||
if (ret_val and ret_val['_id']):
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " -La modif a bien ete faite =" + str(ret_val['_id']))
|
||||
return True, " Le compte utilisateur a ete mis à jour"
|
||||
else:
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - Aucune modif n'a été faite")
|
||||
return False, "Impossible de mettre à jour le compte utilisateur"
|
||||
|
||||
elif (diction['type_connexion'] == "apprenant"):
|
||||
ret_val = coll_name.find_one_and_update({'token': str(diction['token']),
|
||||
'active': '1', 'locked': '0',
|
||||
'apprenant_id': diction['apprenant_id'],
|
||||
},
|
||||
{"$set": dictionnary},
|
||||
return_document=ReturnDocument.AFTER
|
||||
)
|
||||
|
||||
if (ret_val and ret_val['_id']):
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " -La modif a bien ete faite =" + str(ret_val['_id']))
|
||||
return True, " Le compte utilisateur a ete mis à jour"
|
||||
else:
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - Aucune modif n'a été faite")
|
||||
return False, "Impossible de mettre à jour le compte utilisateur"
|
||||
|
||||
if (ret_val and ret_val['_id']):
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " -La modif a bien ete faite =" + str(ret_val['_id']))
|
||||
return True, " Le compte utilisateur a ete mis à jour"
|
||||
else:
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - Aucune modif n'a été faite")
|
||||
return False, "Impossible de mettre à jour le compte utilisateur"
|
||||
|
||||
except Exception as e:
|
||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||
|
|
@ -2241,3 +2278,91 @@ def Get_Ent_Student_Stored_Downloaded_File(diction):
|
|||
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
|
||||
return False, False
|
||||
|
||||
|
||||
"""
|
||||
Cette fonction retourne les données du Footer d'un apprenant_id
|
||||
|
||||
"""
|
||||
def Get_ENT_Data_From_Subdomain_Light_Data_For_Footer(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', 'apprenant_id']
|
||||
|
||||
|
||||
"""
|
||||
Verification des champs obligatoires
|
||||
"""
|
||||
field_list_obligatoire = ['token', 'apprenant_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
|
||||
|
||||
|
||||
for retval in MYSY_GV.dbname['partnair_account'].find({'recid': my_partner['partner_owner_recid'],
|
||||
'active': '1',
|
||||
'locked': '0',
|
||||
'firstconnexion': '0','is_partner_admin_account':'1'
|
||||
}, {'_id':1, 'recid':1, 'nom':1}):
|
||||
user = retval
|
||||
user['id'] = str(val_tmp)
|
||||
val_tmp = val_tmp + 1
|
||||
|
||||
"""
|
||||
Recuperer les elements graphique : logo, bannière, etc
|
||||
"""
|
||||
config_partner_catalog_data = MYSY_GV.dbname['config_partner_catalog'].find_one({'valide':'1', 'locked':'0',
|
||||
'partner_owner_recid':str(retval['recid'])})
|
||||
|
||||
user['catalog_pub_cgv_pdf'] = ""
|
||||
if (config_partner_catalog_data and "cgv_pdf" in config_partner_catalog_data.keys()):
|
||||
user['catalog_pub_cgv_pdf'] = config_partner_catalog_data['cgv_pdf']
|
||||
|
||||
user['catalog_pub_cgu_pdf'] = ""
|
||||
if (config_partner_catalog_data and "cgu_pdf" in config_partner_catalog_data.keys()):
|
||||
user['catalog_pub_cgu_pdf'] = config_partner_catalog_data['cgu_pdf']
|
||||
|
||||
user['catalog_pub_mention_legale_pdf'] = ""
|
||||
if (config_partner_catalog_data and "mention_legale_pdf" in config_partner_catalog_data.keys()):
|
||||
user['catalog_pub_mention_legale_pdf'] = config_partner_catalog_data['mention_legale_pdf']
|
||||
|
||||
|
||||
user['catalog_pub_logo'] = ""
|
||||
#if( config_partner_catalog_data and "logo" in config_partner_catalog_data.keys() ):
|
||||
# user['catalog_pub_logo'] = config_partner_catalog_data['logo']
|
||||
|
||||
RetObject.append(mycommon.JSONEncoder().encode(user))
|
||||
|
||||
#print(" ### Get_Partner_Data_From_Subdomain 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écuperer les données liées au sous domaine "
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -2125,7 +2125,11 @@ def LMS_Get_Partner_Data(diction):
|
|||
#lms_part_recid = my_partner['recid']
|
||||
lms_part_recid = str(connected_user_data['_id'])
|
||||
lms_pwd_mask = str(connected_user_data['pwd'])
|
||||
lms_virtualhost_url = my_partner['lms_virtualhost_url']
|
||||
if("lms_virtualhost_url" in my_partner.keys() ):
|
||||
lms_virtualhost_url = my_partner['lms_virtualhost_url']
|
||||
else:
|
||||
lms_virtualhost_url = ""
|
||||
|
||||
lms_url = MYSY_GV.MYSY_LMS_URL
|
||||
|
||||
"""
|
||||
|
|
|
|||
100
main.py
100
main.py
|
|
@ -246,8 +246,9 @@ def Ent_Student_login():
|
|||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Ent_Student_login payload = ",payload)
|
||||
status, retval, firstconnexion, apprenant_id, user_account_id = us.Ent_Student_login(payload)
|
||||
return jsonify(status=status, message=retval, firstconnexion=firstconnexion, apprenant_id=apprenant_id, user_account_id=user_account_id)
|
||||
status, retval, firstconnexion, apprenant_id, user_account_id, type_connexion, tab_apprenant_tutored = us.Ent_Student_login(payload)
|
||||
return jsonify(status=status, message=retval, firstconnexion=firstconnexion, apprenant_id=apprenant_id, user_account_id=user_account_id,
|
||||
type_connexion=type_connexion, tab_apprenant_tutored=tab_apprenant_tutored)
|
||||
|
||||
|
||||
|
||||
|
|
@ -13153,6 +13154,26 @@ def Get_RH_List_Insc_Tutore():
|
|||
|
||||
|
||||
|
||||
|
||||
"""
|
||||
API permet de recuperer la liste des inscrits tutorés par cette ressource,
|
||||
en partant du RH_id, et sans token
|
||||
|
||||
Important : la securité viendra du fait que jamais il y a personne avec le meme _id dans la base, alors on refuse le traitement
|
||||
"""
|
||||
@app.route('/myclass/api/Get_RH_List_Insc_Tutore_From_RH_Id_NO_TOKEN_Light/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Get_RH_List_Insc_Tutore_From_RH_Id_NO_TOKEN_Light():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Get_RH_List_Insc_Tutore_From_RH_Id_NO_TOKEN_Light payload = ",payload)
|
||||
status, retval = ressources_humaines.Get_RH_List_Insc_Tutore_From_RH_Id_NO_TOKEN_Light(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
"""
|
||||
API permet de supprimer une liste d'inscrits tutoré à un RH
|
||||
"""
|
||||
|
|
@ -13167,6 +13188,46 @@ def Delete_RH_List_Insc_Tutore():
|
|||
|
||||
|
||||
|
||||
"""
|
||||
API permet de créer un compte ENT pour une ressource humaine
|
||||
"""
|
||||
@app.route('/myclass/api/ENT_Create_RH_Account/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def ENT_Create_RH_Account():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### ENT_Create_RH_Account payload = ",payload)
|
||||
status, retval = ressources_humaines.ENT_Create_RH_Account(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
"""
|
||||
API permet de desactiver un compte ENT d'une ressource humaine
|
||||
"""
|
||||
@app.route('/myclass/api/ENT_Disable_RH_Account/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def ENT_Disable_RH_Account():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### ENT_Disable_RH_Account payload = ",payload)
|
||||
status, retval = ressources_humaines.ENT_Disable_RH_Account(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
"""
|
||||
API permet de Reativer un compte ENT d'une ressource humaine
|
||||
"""
|
||||
@app.route('/myclass/api/ENT_Enable_RH_Account/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def ENT_Enable_RH_Account():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### ENT_Enable_RH_Account payload = ",payload)
|
||||
status, retval = ressources_humaines.ENT_Enable_RH_Account(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
|
||||
"""
|
||||
API permet de recuperer les data du partenaire proprietaire d'un sous domaine
|
||||
"""
|
||||
|
|
@ -13181,6 +13242,7 @@ def Get_Partner_Data_From_Subdomain():
|
|||
|
||||
|
||||
|
||||
|
||||
"""
|
||||
API de Recuperation de la liste de TYPE dispositifs de financement de la formation professionnelle
|
||||
"""
|
||||
|
|
@ -14940,6 +15002,23 @@ def Get_Ent_Student_Stored_Downloaded_File(token, file_name, apprenant_id):
|
|||
return retval
|
||||
|
||||
|
||||
|
||||
|
||||
"""
|
||||
API -retourne les données du Footer d'un apprenant_id
|
||||
"""
|
||||
@app.route('/myclass/api/Get_ENT_Data_From_Subdomain_Light_Data_For_Footer/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Get_ENT_Data_From_Subdomain_Light_Data_For_Footer():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Get_ENT_Data_From_Subdomain_Light_Data_For_Footer : payload = ",str(payload))
|
||||
status, retval = ent_student_common.Get_ENT_Data_From_Subdomain_Light_Data_For_Footer( payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
|
||||
|
||||
"""
|
||||
API - Gestion ENT Apprenant : pour publier des document dans l'espace ENT des apprenants
|
||||
"""
|
||||
|
|
@ -15596,6 +15675,23 @@ def Disable_Session_Formation_Automation():
|
|||
return jsonify(status=localStatus, message=message )
|
||||
|
||||
|
||||
|
||||
"""
|
||||
API pour Correction 'type_session' pour les ancienne sessions qui n'ont pas cette valeur
|
||||
"""
|
||||
@app.route('/myclass/api/Correcte_Type_session_For_Old_Session/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Correcte_Type_session_For_Old_Session():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Correcte_Type_session_For_Old_Session : payload = ",payload)
|
||||
localStatus, message= tools_cherif.Correcte_Type_session_For_Old_Session(payload)
|
||||
return jsonify(status=localStatus, message=message )
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
"""
|
||||
API pour Creation de la configuration d'admission
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -2470,7 +2470,12 @@ def getRecodedClassImage_no_token(diction=None):
|
|||
'related_collection_recid':str(diction['related_collection_recid']),
|
||||
"related_collection":str(diction['related_collection'])} ):
|
||||
user2={}
|
||||
user2['update_date'] = retVal['update_date']
|
||||
if( "update_date" in retVal.keys()):
|
||||
user2['update_date'] = retVal['update_date']
|
||||
|
||||
if ("date_update" in retVal.keys()):
|
||||
user2['update_date'] = retVal['date_update']
|
||||
|
||||
decode = retVal['img'].decode()
|
||||
user2['img'] = decode
|
||||
data1 = json.loads(json.dumps(user2))
|
||||
|
|
@ -7542,6 +7547,9 @@ def Get_Partner_Data_From_Subdomain(diction):
|
|||
return False, " Impossible de récuperer les données liées au sous domaine "
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Recuperation de la liste de TYPE dispositifs de financement de la formation professionnelle
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -1364,6 +1364,24 @@ def Get_List_Ressource_Humaine(diction):
|
|||
|
||||
user['groupe_prix_achat_code'] = groupe_prix_achat_code
|
||||
|
||||
"""
|
||||
Aller voir s'il a un compte ENT (en gros est-ce un tuteur avec un compte verrouillé ou pas)
|
||||
"""
|
||||
compte_ent = "0"
|
||||
compte_ent_locked = ""
|
||||
has_ent_account = MYSY_GV.dbname['user_account'].find_one(
|
||||
{'rh_id': str(retval['_id']),
|
||||
'type': 'tuteur',
|
||||
'partner_owner_recid': str(retval['partner_recid'])})
|
||||
|
||||
if (has_ent_account and "locked" in has_ent_account.keys()):
|
||||
compte_ent = "1"
|
||||
compte_ent_locked = str(has_ent_account['locked'])
|
||||
|
||||
|
||||
|
||||
user['is_ent_compte'] = compte_ent
|
||||
user['is_ent_compte_locked'] = compte_ent_locked
|
||||
|
||||
RetObject.append(mycommon.JSONEncoder().encode(user))
|
||||
|
||||
|
|
@ -1632,8 +1650,7 @@ def Get_List_Ressource_Humaine_with_filter(diction):
|
|||
}
|
||||
]
|
||||
|
||||
print(" ##### new_myquery aa = ", new_myquery)
|
||||
print(" ##### find_qry aa = ", find_qry)
|
||||
|
||||
|
||||
New_RetObject = []
|
||||
New_val_tmp = 1
|
||||
|
|
@ -1643,6 +1660,7 @@ def Get_List_Ressource_Humaine_with_filter(diction):
|
|||
Si dans la requette on a les champ : 'formation' ou 'session' on utiliser la requete ci-dessous.
|
||||
Cela veut dire qu'on cherche des ressources qui sont des affectation avec une formation ou une session.
|
||||
"""
|
||||
|
||||
if( "formation" in diction.keys() or "session" in diction.keys()):
|
||||
for New_retVal in MYSY_GV.dbname['ressource_humaine'].aggregate(new_myquery):
|
||||
if ('ressource_humaine_affectation_collection' in New_retVal.keys() and len(New_retVal['ressource_humaine_affectation_collection']) > 0):
|
||||
|
|
@ -1652,12 +1670,12 @@ def Get_List_Ressource_Humaine_with_filter(diction):
|
|||
New_val_tmp = New_val_tmp + 1
|
||||
|
||||
|
||||
|
||||
user['_id'] = New_retVal['_id']
|
||||
user['partner_recid'] = New_retVal['partner_recid']
|
||||
user['nom'] = New_retVal['nom']
|
||||
user['email'] = New_retVal['email']
|
||||
|
||||
|
||||
if ("type_rh" in New_retVal.keys()):
|
||||
user['type_rh'] = New_retVal['type_rh']
|
||||
else:
|
||||
|
|
@ -1756,6 +1774,25 @@ def Get_List_Ressource_Humaine_with_filter(diction):
|
|||
user['telephone_mobile'] = "New_retVal['telephone_mobile']"
|
||||
|
||||
|
||||
"""
|
||||
Aller voir s'il a un compte ENT (en gros est-ce un tuteur avec un compte verrouillé ou pas)
|
||||
"""
|
||||
compte_ent = "0"
|
||||
compte_ent_locked = ""
|
||||
has_ent_account = MYSY_GV.dbname['user_account'].find_one(
|
||||
{'rh_id': str(New_retVal['_id']),
|
||||
'type': 'tuteur',
|
||||
'partner_owner_recid': str(New_retVal['partner_recid'])})
|
||||
|
||||
if (has_ent_account and "locked" in has_ent_account.keys()):
|
||||
compte_ent = "1"
|
||||
compte_ent_locked = str(has_ent_account['locked'])
|
||||
|
||||
|
||||
user['is_ent_compte'] = compte_ent
|
||||
user['is_ent_compte_locked'] = compte_ent_locked
|
||||
|
||||
|
||||
user['affectation'] = []
|
||||
for local_affectation in New_retVal['ressource_humaine_affectation_collection']:
|
||||
affectation = {}
|
||||
|
|
@ -1834,6 +1871,23 @@ def Get_List_Ressource_Humaine_with_filter(diction):
|
|||
else:
|
||||
user['ismanager'] = ""
|
||||
|
||||
"""
|
||||
Aller voir s'il a un compte ENT (en gros est-ce un tuteur avec un compte verrouillé ou pas)
|
||||
"""
|
||||
compte_ent = "0"
|
||||
compte_ent_locked = ""
|
||||
has_ent_account = MYSY_GV.dbname['user_account'].find_one(
|
||||
{'rh_id': str(retval['_id']),
|
||||
'type': 'tuteur',
|
||||
'partner_owner_recid': str(retval['partner_recid'])})
|
||||
|
||||
if (has_ent_account and "locked" in has_ent_account.keys()):
|
||||
compte_ent = "1"
|
||||
compte_ent_locked = str(has_ent_account['locked'])
|
||||
|
||||
user['is_ent_compte'] = compte_ent
|
||||
user['is_ent_compte_locked'] = compte_ent_locked
|
||||
|
||||
val_tmp = val_tmp + 1
|
||||
RetObject.append(mycommon.JSONEncoder().encode(user))
|
||||
|
||||
|
|
@ -1984,6 +2038,25 @@ def Get_List_Ressource_Humaine_no_filter(diction):
|
|||
else:
|
||||
user['user_login'] = ""
|
||||
|
||||
"""
|
||||
Aller voir s'il a un compte ENT (en gros est-ce un tuteur avec un compte verrouillé ou pas)
|
||||
"""
|
||||
compte_ent = "0"
|
||||
compte_ent_locked = ""
|
||||
has_ent_account = MYSY_GV.dbname['user_account'].find_one(
|
||||
{'rh_id': str(retval['_id']),
|
||||
'type': 'tuteur',
|
||||
'partner_owner_recid': str(retval['partner_recid'])})
|
||||
|
||||
if (has_ent_account and "locked" in has_ent_account.keys()):
|
||||
compte_ent = "1"
|
||||
compte_ent_locked = str(has_ent_account['locked'])
|
||||
|
||||
|
||||
user['is_ent_compte'] = compte_ent
|
||||
user['is_ent_compte_locked'] = compte_ent_locked
|
||||
|
||||
|
||||
val_tmp = val_tmp + 1
|
||||
|
||||
"""06/09 /2024 - peut etre ne pas exclure les comptes admin
|
||||
|
|
@ -6568,99 +6641,100 @@ def Get_RH_List_Insc_Tutore(diction):
|
|||
'partner_owner_recid':my_partner['recid']})
|
||||
|
||||
|
||||
|
||||
if( "email" in inscription_data.keys()):
|
||||
node_inscrit_totore['email'] = inscription_data["email"]
|
||||
else:
|
||||
node_inscrit_totore['email'] = ""
|
||||
|
||||
if ("nom" in inscription_data.keys()):
|
||||
node_inscrit_totore['nom'] = inscription_data["nom"]
|
||||
else:
|
||||
node_inscrit_totore['nom'] = ""
|
||||
|
||||
if ("prenom" in inscription_data.keys()):
|
||||
node_inscrit_totore['prenom'] = inscription_data["prenom"]
|
||||
else:
|
||||
node_inscrit_totore['prenom'] = ""
|
||||
|
||||
if ("civilite" in inscription_data.keys()):
|
||||
node_inscrit_totore['civilite'] = inscription_data["civilite"]
|
||||
else:
|
||||
node_inscrit_totore['civilite'] = ""
|
||||
|
||||
if ("telephone" in inscription_data.keys()):
|
||||
node_inscrit_totore['telephone'] = inscription_data["telephone"]
|
||||
else:
|
||||
node_inscrit_totore['telephone'] = ""
|
||||
|
||||
|
||||
if ("apprenant_id" in inscription_data.keys()):
|
||||
node_inscrit_totore['apprenant_id'] = inscription_data["apprenant_id"]
|
||||
else:
|
||||
node_inscrit_totore['apprenant_id'] = ""
|
||||
|
||||
if ("session_id" in inscription_data.keys()):
|
||||
node_inscrit_totore['session_id'] = inscription_data["session_id"]
|
||||
else:
|
||||
node_inscrit_totore['session_id'] = ""
|
||||
|
||||
if ("date_naissance" not in inscription_data.keys() or str(inscription_data['date_naissance']) == ""):
|
||||
node_inscrit_totore['date_naissance'] = "01/01/1900"
|
||||
|
||||
else:
|
||||
node_inscrit_totore['date_naissance'] = inscription_data["date_naissance"]
|
||||
|
||||
|
||||
if( "session_id" in inscription_data.keys() and ObjectId.is_valid(inscription_data['session_id']) ):
|
||||
session_data = MYSY_GV.dbname['session_formation'].find_one({'_id':ObjectId(str(inscription_data['session_id'])),
|
||||
'partner_owner_recid':my_partner['recid']})
|
||||
|
||||
if ("code_session" in session_data.keys()):
|
||||
node_inscrit_totore['code_session'] = session_data["code_session"]
|
||||
if( inscription_data):
|
||||
if( "email" in inscription_data.keys()):
|
||||
node_inscrit_totore['email'] = inscription_data["email"]
|
||||
else:
|
||||
node_inscrit_totore['code_session'] = ""
|
||||
node_inscrit_totore['email'] = ""
|
||||
|
||||
if ("titre" in session_data.keys()):
|
||||
node_inscrit_totore['session_titre'] = session_data["titre"]
|
||||
if ("nom" in inscription_data.keys()):
|
||||
node_inscrit_totore['nom'] = inscription_data["nom"]
|
||||
else:
|
||||
node_inscrit_totore['session_titre'] = ""
|
||||
node_inscrit_totore['nom'] = ""
|
||||
|
||||
|
||||
if ("date_debut" in session_data.keys()):
|
||||
node_inscrit_totore['date_debut'] = session_data["date_debut"]
|
||||
if ("prenom" in inscription_data.keys()):
|
||||
node_inscrit_totore['prenom'] = inscription_data["prenom"]
|
||||
else:
|
||||
node_inscrit_totore['date_debut'] = ""
|
||||
node_inscrit_totore['prenom'] = ""
|
||||
|
||||
if ("date_fin" in session_data.keys()):
|
||||
node_inscrit_totore['date_fin'] = session_data["date_fin"]
|
||||
if ("civilite" in inscription_data.keys()):
|
||||
node_inscrit_totore['civilite'] = inscription_data["civilite"]
|
||||
else:
|
||||
node_inscrit_totore['date_fin'] = ""
|
||||
node_inscrit_totore['civilite'] = ""
|
||||
|
||||
if ("mode_animation" in session_data.keys()):
|
||||
node_inscrit_totore['mode_animation'] = session_data["mode_animation"]
|
||||
if ("telephone" in inscription_data.keys()):
|
||||
node_inscrit_totore['telephone'] = inscription_data["telephone"]
|
||||
else:
|
||||
node_inscrit_totore['mode_animation'] = ""
|
||||
node_inscrit_totore['telephone'] = ""
|
||||
|
||||
if ("class_id" in session_data.keys()):
|
||||
node_inscrit_totore['class_id'] = session_data["class_id"]
|
||||
|
||||
if ("apprenant_id" in inscription_data.keys()):
|
||||
node_inscrit_totore['apprenant_id'] = inscription_data["apprenant_id"]
|
||||
else:
|
||||
node_inscrit_totore['class_id'] = ""
|
||||
node_inscrit_totore['apprenant_id'] = ""
|
||||
|
||||
if ("session_id" in inscription_data.keys()):
|
||||
node_inscrit_totore['session_id'] = inscription_data["session_id"]
|
||||
else:
|
||||
node_inscrit_totore['session_id'] = ""
|
||||
|
||||
if ("date_naissance" not in inscription_data.keys() or str(inscription_data['date_naissance']) == ""):
|
||||
node_inscrit_totore['date_naissance'] = "01/01/1900"
|
||||
|
||||
else:
|
||||
node_inscrit_totore['date_naissance'] = inscription_data["date_naissance"]
|
||||
|
||||
|
||||
if( "class_id" in session_data.keys() and session_data['class_id']):
|
||||
class_data = MYSY_GV.dbname['myclass'].find_one(
|
||||
{'_id': ObjectId(str(session_data['class_id'])),
|
||||
'partner_owner_recid': my_partner['recid']})
|
||||
if( "session_id" in inscription_data.keys() and ObjectId.is_valid(inscription_data['session_id']) ):
|
||||
session_data = MYSY_GV.dbname['session_formation'].find_one({'_id':ObjectId(str(inscription_data['session_id'])),
|
||||
'partner_owner_recid':my_partner['recid']})
|
||||
|
||||
if ("title" in class_data.keys()):
|
||||
node_inscrit_totore['class_title'] = class_data["title"]
|
||||
if ("code_session" in session_data.keys()):
|
||||
node_inscrit_totore['code_session'] = session_data["code_session"]
|
||||
else:
|
||||
node_inscrit_totore['class_title'] = ""
|
||||
node_inscrit_totore['code_session'] = ""
|
||||
|
||||
node_inscrit_totore['id'] = str(val_tmp)
|
||||
val_tmp = val_tmp + 1
|
||||
RetObject.append(mycommon.JSONEncoder().encode(node_inscrit_totore))
|
||||
if ("titre" in session_data.keys()):
|
||||
node_inscrit_totore['session_titre'] = session_data["titre"]
|
||||
else:
|
||||
node_inscrit_totore['session_titre'] = ""
|
||||
|
||||
|
||||
if ("date_debut" in session_data.keys()):
|
||||
node_inscrit_totore['date_debut'] = session_data["date_debut"]
|
||||
else:
|
||||
node_inscrit_totore['date_debut'] = ""
|
||||
|
||||
if ("date_fin" in session_data.keys()):
|
||||
node_inscrit_totore['date_fin'] = session_data["date_fin"]
|
||||
else:
|
||||
node_inscrit_totore['date_fin'] = ""
|
||||
|
||||
if ("mode_animation" in session_data.keys()):
|
||||
node_inscrit_totore['mode_animation'] = session_data["mode_animation"]
|
||||
else:
|
||||
node_inscrit_totore['mode_animation'] = ""
|
||||
|
||||
if ("class_id" in session_data.keys()):
|
||||
node_inscrit_totore['class_id'] = session_data["class_id"]
|
||||
else:
|
||||
node_inscrit_totore['class_id'] = ""
|
||||
|
||||
|
||||
if( "class_id" in session_data.keys() and session_data['class_id']):
|
||||
class_data = MYSY_GV.dbname['myclass'].find_one(
|
||||
{'_id': ObjectId(str(session_data['class_id'])),
|
||||
'partner_owner_recid': my_partner['recid']})
|
||||
|
||||
if ("title" in class_data.keys()):
|
||||
node_inscrit_totore['class_title'] = class_data["title"]
|
||||
else:
|
||||
node_inscrit_totore['class_title'] = ""
|
||||
|
||||
|
||||
node_inscrit_totore['id'] = str(val_tmp)
|
||||
val_tmp = val_tmp + 1
|
||||
RetObject.append(mycommon.JSONEncoder().encode(node_inscrit_totore))
|
||||
|
||||
|
||||
return True, RetObject
|
||||
|
|
@ -6671,6 +6745,108 @@ def Get_RH_List_Insc_Tutore(diction):
|
|||
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 inscrits tutorés "
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Cette fonction permet de recuperer la liste des inscrits tutorés par cette ressource,
|
||||
en partant du RH_id, et sans token
|
||||
|
||||
Important : la securité viendra du fait que jamais il y a personne avec le meme _id dans la base, alors on refuse le traitement
|
||||
"""
|
||||
def Get_RH_List_Insc_Tutore_From_RH_Id_NO_TOKEN_Light(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = [ 'rh_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 = ['rh_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",
|
||||
|
||||
|
||||
|
||||
"""
|
||||
check validité RH
|
||||
"""
|
||||
is_rh_valide = MYSY_GV.dbname['ressource_humaine'].count_documents({"_id":ObjectId(str(diction['rh_id'])),})
|
||||
|
||||
if( is_rh_valide != 1):
|
||||
mycommon.myprint(str(
|
||||
inspect.stack()[0][3]) + " L'identifiant RH est invalide ")
|
||||
return False, " L'identifiant RH est invalide ",
|
||||
|
||||
RetObject = []
|
||||
val_tmp = 0
|
||||
|
||||
retval = MYSY_GV.dbname['ressource_humaine'].find_one({"_id": ObjectId(str(diction['rh_id']))})
|
||||
if( retval ):
|
||||
if( "tab_inscription_id" in retval.keys() and retval["tab_inscription_id"]):
|
||||
|
||||
|
||||
for insc_tutore_data in retval["tab_inscription_id"]:
|
||||
|
||||
node_inscrit_totore = {}
|
||||
inscription_data = {}
|
||||
if( "inscription_id" in insc_tutore_data.keys() and ObjectId.is_valid(insc_tutore_data['inscription_id']) ) :
|
||||
inscription_data = MYSY_GV.dbname['inscription'].find_one({'_id':ObjectId(str(insc_tutore_data['inscription_id'])),
|
||||
'partner_owner_recid':retval['partner_recid']})
|
||||
|
||||
|
||||
if( inscription_data):
|
||||
if ("apprenant_id" in inscription_data.keys() and inscription_data['apprenant_id']):
|
||||
node_inscrit_totore['apprenant_id'] = inscription_data["apprenant_id"]
|
||||
|
||||
apprenant_data = MYSY_GV.dbname['apprenant'].find_one({'_id':ObjectId(inscription_data["apprenant_id"]),
|
||||
'valide':'1',
|
||||
'partner_owner_recid':retval['partner_recid']}, {'_id':1, 'nom':1, 'prenom':1})
|
||||
|
||||
if( apprenant_data):
|
||||
if("_id" in apprenant_data.keys()):
|
||||
node_inscrit_totore['_id'] = str(apprenant_data['_id'])
|
||||
else:
|
||||
node_inscrit_totore['_id'] = ""
|
||||
|
||||
if ("nom" in apprenant_data.keys()):
|
||||
node_inscrit_totore['nom'] = str(apprenant_data['nom'])
|
||||
else:
|
||||
node_inscrit_totore['nom'] = ""
|
||||
|
||||
if ("prenom" in apprenant_data.keys()):
|
||||
node_inscrit_totore['prenom'] = str(apprenant_data['prenom'])
|
||||
else:
|
||||
node_inscrit_totore['prenom'] = ""
|
||||
|
||||
node_inscrit_totore['id'] = str(val_tmp)
|
||||
val_tmp = val_tmp + 1
|
||||
RetObject.append(mycommon.JSONEncoder().encode(node_inscrit_totore))
|
||||
|
||||
|
||||
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 inscrits tutorés "
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Cette fonction permet de modifier les données de tutorat.
|
||||
/!\ : on ne peut modiier que le role et include_com et comment
|
||||
|
|
@ -7074,3 +7250,495 @@ def Delete_RH_List_Insc_Tutore(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 suppression les tutorés "
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Cette fonction permet de créer un compte ENT pour une ressource humaine
|
||||
"""
|
||||
def ENT_Create_RH_Account(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', 'tab_rh_ids']
|
||||
|
||||
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', 'tab_rh_ids']
|
||||
|
||||
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
|
||||
|
||||
tab_rh_ids_work = str(diction['tab_rh_ids']).split(",")
|
||||
tab_rh_ids = []
|
||||
|
||||
for tmp in tab_rh_ids_work:
|
||||
if( tmp ):
|
||||
tab_rh_ids.append(tmp)
|
||||
|
||||
for val in tab_rh_ids :
|
||||
is_valide_rh = MYSY_GV.dbname['ressource_humaine'].count_documents({'_id':ObjectId(str(val)),
|
||||
'valide':'1',
|
||||
'locked':'0',
|
||||
'partner_recid':str(my_partner['recid'])})
|
||||
|
||||
if( is_valide_rh != 1):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " L'identifiant de la ressource "+str(val)+" est invalide ")
|
||||
return False, " L'identifiant de la ressource "+str(val)+" est invalide "
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Recuperer l'url vers l'espace ENT
|
||||
local_partner_ent_student_url = ""
|
||||
config_partner_catalog_data = MYSY_GV.dbname['config_partner_catalog'].find_one(
|
||||
{'partner_owner_recid': str(my_partner['recid']),
|
||||
'valide': '1',
|
||||
'locked': '0'}, {'_id': 1, 'partner_ent_student_url': 1})
|
||||
|
||||
if (config_partner_catalog_data and "partner_ent_student_url" in config_partner_catalog_data.keys() and
|
||||
config_partner_catalog_data['partner_ent_student_url']):
|
||||
local_partner_ent_student_url = config_partner_catalog_data['partner_ent_student_url']
|
||||
|
||||
# recuperer le model de document
|
||||
local_diction = {}
|
||||
local_diction['ref_interne'] = "STUDENT_CREDENTIALS_FOR_ENT"
|
||||
local_diction['type_doc'] = "email"
|
||||
local_diction['partner_owner_recid'] = str(my_partner['recid'])
|
||||
|
||||
courrier_data_status, courrier_data_retval = mycommon.Get_Courrier_Template_Include_Default_Data(
|
||||
local_diction)
|
||||
if (courrier_data_status is False):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " Impossible de récuperer le modèle de courrier 'STUDENT_CREDENTIALS_FOR_ENT' ")
|
||||
return False, " Impossible de récuperer le modèle de courrier 'STUDENT_CREDENTIALS_FOR_ENT' "
|
||||
|
||||
if ("contenu_doc" not in courrier_data_retval.keys() or str(courrier_data_retval['contenu_doc']) == ""):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " Le modèle de courrier 'STUDENT_CREDENTIALS_FOR_ENT' n'est pas correctement configuré - contenu_doc")
|
||||
return False, " Le modèle de courrier 'STUDENT_CREDENTIALS_FOR_ENT' n'est pas correctement configuré - contenu_doc"
|
||||
|
||||
|
||||
"""
|
||||
Envoie des email de notification des apprenants
|
||||
"""
|
||||
|
||||
# Recuperation des donnes SMTP
|
||||
(local_stpm_status, partner_SMTP_COUNT_smtpsrv, partner_own_smtp_value, partner_SMTP_COUNT_password, partner_SMTP_COUNT_user, partner_SMTP_COUNT_From_User,
|
||||
partner_SMTP_COUNT_port) = mycommon.Get_Partner_SMTP_Param(my_partner['recid'])
|
||||
|
||||
if (local_stpm_status is False):
|
||||
return local_stpm_status, partner_SMTP_COUNT_smtpsrv
|
||||
|
||||
smtpserver = None
|
||||
|
||||
if (str(partner_own_smtp_value) == "1"):
|
||||
smtpserver = smtplib.SMTP(partner_SMTP_COUNT_smtpsrv, partner_SMTP_COUNT_port)
|
||||
else:
|
||||
smtpserver = smtplib.SMTP(MYSY_GV.O365_SMTP_COUNT_smtpsrv, MYSY_GV.O365_SMTP_COUNT_port)
|
||||
|
||||
smtpserver.ehlo()
|
||||
smtpserver.starttls()
|
||||
smtpserver.login(MYSY_GV.O365_SMTP_COUNT_user, MYSY_GV.O365_SMTP_COUNT_password)
|
||||
cpt_email_envoye = 0
|
||||
|
||||
# Creation du dictionnaire d'information à utiliser pour la creation du doc
|
||||
convention_dictionnary_data = {}
|
||||
new_diction = {}
|
||||
new_diction['token'] = my_partner['token']
|
||||
new_diction['list_stagiaire_id'] = []
|
||||
new_diction['list_session_id'] = []
|
||||
new_diction['list_class_id'] = []
|
||||
new_diction['list_client_id'] = []
|
||||
|
||||
local_status, local_retval = mycommon.Get_Dictionnary_data_For_Template(new_diction)
|
||||
|
||||
if (local_status is False):
|
||||
return local_status, local_retval
|
||||
|
||||
convention_dictionnary_data = local_retval
|
||||
convention_dictionnary_data['url_ent_student'] = local_partner_ent_student_url
|
||||
|
||||
"""
|
||||
A présent tous les apprenants sont valides,
|
||||
les comptes vont etre créer pour l'ENT
|
||||
"""
|
||||
|
||||
nb_compte = 0
|
||||
for val in tab_rh_ids:
|
||||
local_rh_data = MYSY_GV.dbname['ressource_humaine'].find_one({'_id': ObjectId(str(val)),
|
||||
'valide': '1',
|
||||
'locked': '0',
|
||||
'partner_recid': str(
|
||||
my_partner['recid'])})
|
||||
|
||||
if( local_rh_data ):
|
||||
|
||||
new_account = {}
|
||||
new_account['rh_id'] = str(val)
|
||||
new_account['nom'] = local_rh_data['nom']
|
||||
new_account['prenom'] = local_rh_data['prenom']
|
||||
new_account['civilite'] = local_rh_data['civilite']
|
||||
if( str(local_rh_data['civilite']).strip() == ""):
|
||||
new_account['civilite'] = "neutre"
|
||||
|
||||
new_account['email'] = local_rh_data['email']
|
||||
|
||||
new_account['mob_phone'] = local_rh_data['telephone']
|
||||
new_account['adr_street'] = local_rh_data['adr_adresse']
|
||||
new_account['code_postal'] = local_rh_data['adr_code_postal']
|
||||
new_account['adr_city'] = local_rh_data['adr_ville']
|
||||
new_account['adr_country'] = local_rh_data['adr_pays']
|
||||
|
||||
new_account['partner_owner_recid'] = local_rh_data['partner_recid']
|
||||
|
||||
new_account['type'] = 'tuteur'
|
||||
new_account['rh_id'] = str(val)
|
||||
new_account['active'] = '1'
|
||||
new_account['locked'] = '0'
|
||||
new_account['firstconnexion'] = '1'
|
||||
|
||||
new_account['creation_date'] = str(datetime.now())
|
||||
new_account['creation_by'] = str(my_partner['_id'])
|
||||
|
||||
new_account['notification_send'] = "0"
|
||||
|
||||
new_account['pwd'] = str(secrets.token_urlsafe(8))
|
||||
|
||||
data_key = {}
|
||||
data_key['type'] = 'tuteur'
|
||||
data_key['email'] = str(local_rh_data['email'])
|
||||
data_key['rh_id'] = str(val)
|
||||
data_key['partner_owner_recid'] = str( local_rh_data['partner_recid'])
|
||||
|
||||
|
||||
ret_val = MYSY_GV.dbname['user_account'].find_one_and_update(
|
||||
data_key,
|
||||
{"$set": new_account},
|
||||
upsert=True,
|
||||
return_document=ReturnDocument.AFTER
|
||||
)
|
||||
|
||||
civilite = "neutre"
|
||||
if( "civilite" in local_rh_data.keys() and local_rh_data['civilite']):
|
||||
civilite = local_rh_data['civilite']
|
||||
|
||||
if( str(civilite).strip() == ""):
|
||||
civilite = "neutre"
|
||||
|
||||
convention_dictionnary_data['civilite'] = civilite
|
||||
|
||||
convention_dictionnary_data['nom'] = local_rh_data['nom']
|
||||
convention_dictionnary_data['prenom'] = local_rh_data['prenom']
|
||||
convention_dictionnary_data['email'] = local_rh_data['email']
|
||||
|
||||
convention_dictionnary_data['ent_login'] = local_rh_data['email']
|
||||
convention_dictionnary_data['ent_pwd'] = new_account['pwd']
|
||||
|
||||
body = {
|
||||
"params": convention_dictionnary_data,
|
||||
}
|
||||
|
||||
# Traitement du sujet du mail
|
||||
sujet_mail_Template = jinja2.Template(str(courrier_data_retval['sujet']))
|
||||
sujetHtml = sujet_mail_Template.render(params=body["params"])
|
||||
|
||||
# Traitement du corps du mail
|
||||
contenu_doc_Template = jinja2.Template(str(courrier_data_retval['contenu_doc']))
|
||||
contenu_docHtml = contenu_doc_Template.render(params=body["params"])
|
||||
html_mime = MIMEText(contenu_docHtml, 'html')
|
||||
|
||||
# Creation de l'email à enoyer
|
||||
msg = MIMEMultipart("alternative")
|
||||
|
||||
if (str(partner_own_smtp_value) == "1"):
|
||||
msg.attach(html_mime)
|
||||
msg['From'] = partner_SMTP_COUNT_From_User
|
||||
msg['Bcc'] = "contact@mysy-training.com"
|
||||
msg['Subject'] = sujetHtml
|
||||
msg['to'] = str(local_rh_data['email'])
|
||||
|
||||
val = smtpserver.send_message(msg)
|
||||
print(" Email a envoyé " + str(email))
|
||||
|
||||
|
||||
else:
|
||||
msg.attach(html_mime)
|
||||
msg['From'] = partner_SMTP_COUNT_From_User
|
||||
msg['Bcc'] = "contact@mysy-training.com"
|
||||
msg['Subject'] = sujetHtml
|
||||
msg['to'] = str(local_rh_data['email'])
|
||||
|
||||
val = smtpserver.send_message(msg)
|
||||
print(" Email a envoyé " + str(email))
|
||||
|
||||
|
||||
nb_compte = nb_compte + 1
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
print(" NB_email envoyé = ", nb_compte)
|
||||
smtpserver.close()
|
||||
return True, str(nb_compte)+" compte(s) ENT créé(s) "
|
||||
|
||||
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 les accès ENT "
|
||||
|
||||
"""
|
||||
Cette fonction permet de desactiver un compte ENT d'une ressource humaine
|
||||
"""
|
||||
def ENT_Disable_RH_Account(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', 'tab_rh_ids']
|
||||
|
||||
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', 'tab_rh_ids']
|
||||
|
||||
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
|
||||
|
||||
tab_rh_ids_work = str(diction['tab_rh_ids']).split(",")
|
||||
tab_rh_ids = []
|
||||
|
||||
for tmp in tab_rh_ids_work:
|
||||
if( tmp ):
|
||||
tab_rh_ids.append(tmp)
|
||||
|
||||
for val in tab_rh_ids :
|
||||
is_valide_rh = MYSY_GV.dbname['ressource_humaine'].count_documents({'_id':ObjectId(str(val)),
|
||||
'valide':'1',
|
||||
'locked':'0',
|
||||
'partner_recid':str(my_partner['recid'])})
|
||||
|
||||
if( is_valide_rh != 1):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " L'identifiant de la ressource "+str(val)+" est invalide ")
|
||||
return False, " L'identifiant de la ressource "+str(val)+" est invalide "
|
||||
|
||||
|
||||
"""
|
||||
A présent tous les apprenants sont valides,
|
||||
les comptes vont etre créer pour l'ENT
|
||||
"""
|
||||
|
||||
nb_compte = 0
|
||||
for val in tab_rh_ids:
|
||||
local_rh_data = MYSY_GV.dbname['ressource_humaine'].find_one({'_id': ObjectId(str(val)),
|
||||
'valide': '1',
|
||||
'locked': '0',
|
||||
'partner_recid': str(
|
||||
my_partner['recid'])})
|
||||
|
||||
new_account = {}
|
||||
|
||||
new_account['active'] = '0'
|
||||
new_account['locked'] = '1'
|
||||
|
||||
new_account['update_date'] = str(datetime.now())
|
||||
new_account['update_by'] = str(my_partner['_id'])
|
||||
|
||||
data_key = {}
|
||||
data_key['type'] = 'tuteur'
|
||||
data_key['email'] = str(local_rh_data['email'])
|
||||
data_key['rh_id'] = str(val)
|
||||
data_key['partner_owner_recid'] = str( local_rh_data['partner_recid'])
|
||||
|
||||
|
||||
ret_val = MYSY_GV.dbname['user_account'].find_one_and_update(
|
||||
data_key,
|
||||
{"$set": new_account},
|
||||
upsert=False,
|
||||
return_document=ReturnDocument.AFTER
|
||||
)
|
||||
|
||||
nb_compte = nb_compte + 1
|
||||
|
||||
|
||||
return True, str(nb_compte)+" compte(s) ENT désactivé(s) "
|
||||
|
||||
except Exception as e:
|
||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - Line : " + str(exc_tb.tb_lineno))
|
||||
return False, " Impossible désactiver les accès ENT "
|
||||
|
||||
|
||||
"""
|
||||
Cette fonction permet de Reativer un compte ENT d'une ressource humaine
|
||||
# Dans le cadre d'une reactivation, on modifie le mot de passe.
|
||||
"""
|
||||
def ENT_Enable_RH_Account(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', 'tab_rh_ids']
|
||||
|
||||
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', 'tab_rh_ids']
|
||||
|
||||
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
|
||||
|
||||
tab_rh_ids_work = str(diction['tab_rh_ids']).split(",")
|
||||
tab_rh_ids = []
|
||||
|
||||
for tmp in tab_rh_ids_work:
|
||||
if( tmp ):
|
||||
tab_rh_ids.append(tmp)
|
||||
|
||||
for val in tab_rh_ids :
|
||||
is_valide_rh = MYSY_GV.dbname['ressource_humaine'].count_documents({'_id':ObjectId(str(val)),
|
||||
'valide':'1',
|
||||
'locked':'0',
|
||||
'partner_recid':str(my_partner['recid'])})
|
||||
|
||||
if( is_valide_rh != 1):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " L'identifiant de la ressource "+str(val)+" est invalide ")
|
||||
return False, " L'identifiant de la ressource "+str(val)+" est invalide "
|
||||
|
||||
|
||||
"""
|
||||
A présent tous les apprenants sont valides,
|
||||
les comptes vont etre créer pour l'ENT
|
||||
"""
|
||||
|
||||
nb_compte = 0
|
||||
for val in tab_rh_ids:
|
||||
local_apprenant_data = MYSY_GV.dbname['ressource_humaine'].find_one({'_id': ObjectId(str(val)),
|
||||
'valide': '1',
|
||||
'locked': '0',
|
||||
'partner_recid': str(
|
||||
my_partner['recid'])})
|
||||
|
||||
new_account = {}
|
||||
|
||||
# Dans le cadre d'une reactivation, on modifie le mot de passe.
|
||||
new_account['pwd'] = str(secrets.token_urlsafe(8))
|
||||
new_account['active'] = '1'
|
||||
new_account['locked'] = '0'
|
||||
|
||||
new_account['update_date'] = str(datetime.now())
|
||||
new_account['update_by'] = str(my_partner['_id'])
|
||||
|
||||
data_key = {}
|
||||
data_key['type'] = 'tuteur'
|
||||
data_key['email'] = str(local_apprenant_data['email'])
|
||||
data_key['rh_id'] = str(val)
|
||||
data_key['partner_owner_recid'] = str( local_apprenant_data['partner_recid'])
|
||||
|
||||
|
||||
ret_val = MYSY_GV.dbname['user_account'].find_one_and_update(
|
||||
data_key,
|
||||
{"$set": new_account},
|
||||
upsert=False,
|
||||
return_document=ReturnDocument.AFTER
|
||||
)
|
||||
|
||||
nb_compte = nb_compte + 1
|
||||
|
||||
|
||||
return True, str(nb_compte)+" compte(s) ENT désactivé(s) "
|
||||
|
||||
except Exception as e:
|
||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - Line : " + str(exc_tb.tb_lineno))
|
||||
return False, " Impossible désactiver les accès ENT "
|
||||
|
||||
|
|
|
|||
|
|
@ -2489,3 +2489,35 @@ def Disable_Session_Formation_Automation(diction):
|
|||
return False, " Impossible de faire la mise à jour"
|
||||
|
||||
|
||||
"""
|
||||
Correction 'type_session' pour les ancienne sessions qui n'ont pas cette valeur
|
||||
"""
|
||||
def Correcte_Type_session_For_Old_Session(diction):
|
||||
try:
|
||||
a = 2
|
||||
|
||||
qry_session = ""
|
||||
if( diction['partner_owner_recid'] == "all"):
|
||||
qry_session = {}
|
||||
else:
|
||||
qry_session = {'partner_owner_recid':str(diction['partner_owner_recid'])}
|
||||
|
||||
|
||||
for session_data in MYSY_GV.dbname['session_formation'].find(qry_session):
|
||||
|
||||
if( "type_session" not in session_data.keys() or session_data['type_session'] == ""):
|
||||
print("### session_data kkk = ", session_data)
|
||||
|
||||
MYSY_GV.dbname['session_formation'].find_one_and_update({'_id':ObjectId(str(session_data['_id'])),
|
||||
'partner_owner_recid':str(session_data['partner_owner_recid'])},
|
||||
{'$set':{'type_session':'0'}})
|
||||
|
||||
|
||||
|
||||
|
||||
return True, "Mise à jour Correcte_Type_session_For_Old_Session ==> 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"
|
||||
|
|
|
|||
|
|
@ -364,7 +364,7 @@ def Ent_Student_login(diction):
|
|||
for val in incom_keys:
|
||||
if str(val).lower() not in str(field_list).lower():
|
||||
mycommon.myprint(str(inspect.stack()[0][3])+" Le champ '" + val + "' n'existe pas, MAJ annulée")
|
||||
return False, " Impossible de se connecter, merci de contacter le support technique", False, False, False
|
||||
return False, " Impossible de se connecter, merci de contacter le support technique", False, False, False, False, False
|
||||
|
||||
'''
|
||||
Une fois qu'on a controlé que toutes les clés mise dans l'API sont correcte. etape precedente,
|
||||
|
|
@ -374,7 +374,7 @@ def Ent_Student_login(diction):
|
|||
for val in field_list_obligatoire:
|
||||
if str(val).lower() 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 se connecter, merci de contacter le support technique", False, False, False
|
||||
return False, " Impossible de se connecter, merci de contacter le support technique", False, False, False, False, False
|
||||
|
||||
query = {}
|
||||
# recuperation des paramettre
|
||||
|
|
@ -389,14 +389,25 @@ def Ent_Student_login(diction):
|
|||
pwd = diction['pwd']
|
||||
query['pwd'] = diction['pwd']
|
||||
|
||||
if ("type" in diction.keys()):
|
||||
if diction['type']:
|
||||
type = diction['type']
|
||||
query['type'] = diction['type']
|
||||
|
||||
query['active'] = '1'
|
||||
query['locked'] = '0'
|
||||
|
||||
filter_type = {}
|
||||
if ("type" in diction.keys()):
|
||||
if diction['type']:
|
||||
if( diction['type'] == "student"):
|
||||
filter_type = {'$or':[{'type':'student'}, {'type':'tuteur'}]}
|
||||
else:
|
||||
filter_type = {'type': str(diction['type'])}
|
||||
|
||||
|
||||
find_qry = {'$and': [
|
||||
query,
|
||||
filter_type, ]}
|
||||
|
||||
#print(' ## find_qry = ', find_qry)
|
||||
|
||||
# Recuperation du RecId du user connecté
|
||||
coll_name = MYSY_GV.dbname['user_account']
|
||||
|
||||
|
|
@ -406,11 +417,11 @@ def Ent_Student_login(diction):
|
|||
# Verification si ce user existe (controle : login et passwd)
|
||||
|
||||
|
||||
tmp = coll_name.count_documents(query)
|
||||
tmp = coll_name.count_documents(find_qry)
|
||||
|
||||
if (tmp != 1):
|
||||
mycommon.myprint(str(inspect.stack()[0][3])+" Login/mot de passe invalide " + str(query)+ " my_user.count() = "+str(tmp))
|
||||
return False, " Login/mot de passe invalide, merci de verifier votre saisie. ", False, False, False
|
||||
return False, " Login/mot de passe invalide, merci de verifier votre saisie. ", False, False, False, False, False
|
||||
|
||||
my_user = coll_name.find(query)
|
||||
|
||||
|
|
@ -484,15 +495,45 @@ def Ent_Student_login(diction):
|
|||
if ("_id" not in ret_val.keys()):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " Impossible de récupérer les données de l'utilisateur (2)")
|
||||
return False, " Impossible de récupérer les données de l'utilisateur (2) ", False, False, False
|
||||
return False, " Impossible de récupérer les données de l'utilisateur (2) ", False, False, False, False, False
|
||||
|
||||
return True, str(my_token), str(user_firstconnexion), str(ret_val['apprenant_id']), str(ret_val['_id'])
|
||||
returned_id = ""
|
||||
type_connexion = ""
|
||||
tab_apprenant_tutored = []
|
||||
|
||||
if( "apprenant_id" in ret_val.keys() and ret_val['apprenant_id']):
|
||||
returned_id = ret_val['apprenant_id']
|
||||
type_connexion = "apprenant"
|
||||
|
||||
elif ("rh_id" in ret_val.keys() and ret_val['rh_id']):
|
||||
returned_id = ret_val['rh_id']
|
||||
type_connexion = "tuteur"
|
||||
|
||||
"""
|
||||
Recuperer la liste des apprenants tutoré
|
||||
"""
|
||||
|
||||
inscrit_tmp = MYSY_GV.dbname['ressource_humaine'].find_one({'_id':ObjectId(str(ret_val['rh_id'])),
|
||||
'partner_recid':str(ret_val['partner_owner_recid'])}, {'tab_inscription_id':1,
|
||||
'partner_recid':1})
|
||||
|
||||
if( inscrit_tmp and "tab_inscription_id" in inscrit_tmp.keys()):
|
||||
for tutored in inscrit_tmp['tab_inscription_id']:
|
||||
local_inscription_data = MYSY_GV.dbname['inscription'].find_one({'_id':ObjectId(str(tutored['inscription_id'])),
|
||||
'partner_owner_recid':str(inscrit_tmp['partner_recid'])}, {'apprenant_id':1})
|
||||
|
||||
if(local_inscription_data and 'apprenant_id' in local_inscription_data.keys()):
|
||||
tab_apprenant_tutored.append(str(local_inscription_data['apprenant_id']))
|
||||
|
||||
|
||||
|
||||
return True, str(my_token), str(user_firstconnexion), str(returned_id), str(ret_val['_id']), str(type_connexion), str(tab_apprenant_tutored)
|
||||
else:
|
||||
mycommon.myprint(str(inspect.stack()[0][3])+" Impossible d'enregistrer le token " + my_token)
|
||||
return False, " Impossible de se connecter, merci de contacter le support technique", False, False, False
|
||||
return False, " Impossible de se connecter, merci de contacter le support technique", False, False, False, False, False
|
||||
|
||||
|
||||
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 se connecter, merci de contacter le support technique", False, False, False
|
||||
return False, "Impossible de se connecter, merci de contacter le support technique", False, False, False, False
|
||||
Loading…
Reference in New Issue