qsdsq
parent
e060ec266a
commit
f8feacdb00
|
@ -1,16 +1,14 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="30/01/2025 - 16h">
|
||||
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="01/02/2025 - 20h">
|
||||
<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$/Session_Formation.py" beforeDir="false" afterPath="$PROJECT_DIR$/Session_Formation.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/articles_avis.py" beforeDir="false" afterPath="$PROJECT_DIR$/articles_avis.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/class_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/class_mgt.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/lms_chamilo/mysy_lms.py" beforeDir="false" afterPath="$PROJECT_DIR$/lms_chamilo/mysy_lms.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/email_inscription_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/email_inscription_mgt.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/tools_cherif/tools_cherif.py" beforeDir="false" afterPath="$PROJECT_DIR$/tools_cherif/tools_cherif.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/partner_client.py" beforeDir="false" afterPath="$PROJECT_DIR$/partner_client.py" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
|
@ -81,13 +79,6 @@
|
|||
<option name="presentableId" value="Default" />
|
||||
<updated>1680804787304</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00384" summary="dddqsddddss">
|
||||
<created>1725026643840</created>
|
||||
<option name="number" value="00384" />
|
||||
<option name="presentableId" value="LOCAL-00384" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1725026643840</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00385" summary="31082024">
|
||||
<created>1725106474933</created>
|
||||
<option name="number" value="00385" />
|
||||
|
@ -424,7 +415,14 @@
|
|||
<option name="project" value="LOCAL" />
|
||||
<updated>1738251430865</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="433" />
|
||||
<task id="LOCAL-00433" summary="01/02/2025 - 20h">
|
||||
<created>1738436729990</created>
|
||||
<option name="number" value="00433" />
|
||||
<option name="presentableId" value="LOCAL-00433" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1738436729991</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="434" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="Vcs.Log.Tabs.Properties">
|
||||
|
@ -466,7 +464,6 @@
|
|||
</option>
|
||||
</component>
|
||||
<component name="VcsManagerConfiguration">
|
||||
<MESSAGE value="13/10/2024 - sdf14h" />
|
||||
<MESSAGE value="13/10/2024 - sdfqsdqs14h" />
|
||||
<MESSAGE value="qsdsq" />
|
||||
<MESSAGE value="qsdsqqs" />
|
||||
|
@ -491,6 +488,7 @@
|
|||
<MESSAGE value="18/01/2025 - 17h" />
|
||||
<MESSAGE value="20/01/2025 - 18h" />
|
||||
<MESSAGE value="30/01/2025 - 16h" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="30/01/2025 - 16h" />
|
||||
<MESSAGE value="01/02/2025 - 20h" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="01/02/2025 - 20h" />
|
||||
</component>
|
||||
</project>
|
|
@ -1553,6 +1553,21 @@ def GetAllClassStagiaire(diction):
|
|||
if( str( user['civilite']) not in MYSY_GV.CIVILITE):
|
||||
user['civilite'] = "neutre"
|
||||
|
||||
lms_account_expiration_date = ""
|
||||
if ("lms_account_expiration_date" in retval.keys()):
|
||||
lms_account_expiration_date = retval['lms_account_expiration_date']
|
||||
user['lms_account_expiration_date'] = lms_account_expiration_date
|
||||
|
||||
lms_class_code = ""
|
||||
if ("lms_class_code" in retval.keys()):
|
||||
lms_class_code = retval['lms_class_code']
|
||||
user['lms_class_code'] = lms_class_code
|
||||
|
||||
lms_user_id = ""
|
||||
if ("lms_user_id" in retval.keys()):
|
||||
lms_user_id = retval['lms_user_id']
|
||||
user['lms_user_id'] = lms_user_id
|
||||
|
||||
RetObject.append(mycommon.JSONEncoder().encode(user))
|
||||
|
||||
return True, RetObject
|
||||
|
@ -5549,8 +5564,7 @@ def RefuseAttendeeInscription_with_motif(diction):
|
|||
history_event_dict['action_date'] = str(now)
|
||||
|
||||
local_session_info = ""
|
||||
if ("_id" in local_session.keys()):
|
||||
local_session_info = "_Id Session : " + str(local_session["_id"])
|
||||
|
||||
if ("code_session" in local_session.keys()):
|
||||
local_session_info = local_session_info + ", Code Session : " + local_session["code_session"]
|
||||
|
||||
|
@ -6699,8 +6713,7 @@ def AcceptAttendeeInscription(diction):
|
|||
history_event_dict['action_date'] = str(now)
|
||||
|
||||
local_session_info = ""
|
||||
if ("_id" in local_session.keys()):
|
||||
local_session_info = "_Id Session : " + str(local_session["_id"])
|
||||
|
||||
if( "code_session" in local_session.keys() ):
|
||||
local_session_info = local_session_info+ ", Code Session : "+local_session["code_session"]
|
||||
|
||||
|
@ -7241,6 +7254,10 @@ def Send_LMS_Credentials_to_particpants(diction):
|
|||
email_data['lms_url'] = str(lms_virtualhost_url)
|
||||
email_data['course_owner_email'] = my_partner['email']
|
||||
email_data['partner_recid'] = my_partner['recid']
|
||||
email_data['token'] = str(mytoken)
|
||||
email_data['inscription_id'] = str(local_inscription[0]['_id'])
|
||||
email_data['session_code'] = str(local_session['code_session'])
|
||||
|
||||
|
||||
#split_mail_tab = str(email).split('@')
|
||||
#email_data['login'] = split_mail_tab[0]
|
||||
|
@ -9502,9 +9519,11 @@ def Sent_Convention_Stagiaire_By_Email(tab_files, Folder, diction):
|
|||
history_event_dict['related_collection_recid'] = str(diction['inscription_id'])
|
||||
history_event_dict['action_date'] = str(now)
|
||||
|
||||
local_session_info = "Id Session : " + str(session_data['_id'])
|
||||
local_session_info = ""
|
||||
if ("code_session" in session_data.keys()):
|
||||
local_session_info = local_session_info + ", " + session_data["code_session"]
|
||||
else:
|
||||
local_session_info = "Id Session : " + str(session_data['_id'])
|
||||
|
||||
history_event_dict['action_description'] = "Convention envoyée par email à la liste : "+str(tab_emails_destinataire)+" pour la session "+str(local_session_info)
|
||||
local_status, local_retval = mycommon.Collection_Historique.Add_Historique_Event(history_event_dict)
|
||||
|
@ -10031,9 +10050,12 @@ def Sent_Convention_Individuelle_Stagiaire_By_Email(tab_files, Folder, diction):
|
|||
history_event_dict['related_collection_recid'] = str(diction['inscription_id'])
|
||||
history_event_dict['action_date'] = str(now)
|
||||
|
||||
local_session_info = "Id Session : " + str(session_data['_id'])
|
||||
local_session_info = ""
|
||||
if ("code_session" in session_data.keys()):
|
||||
local_session_info = local_session_info + ", " + session_data["code_session"]
|
||||
else:
|
||||
local_session_info = "Id Session : " + str(session_data['_id'])
|
||||
|
||||
|
||||
history_event_dict['action_description'] = "Convention envoyée par email à la liste : " + str(
|
||||
tab_emails_destinataire) + " pour la session " + str(local_session_info)
|
||||
|
@ -11466,9 +11488,12 @@ def Sent_Convention_Stagiaire_By_Email_By_Partner_client(tab_files_name_full_pat
|
|||
history_event_dict['related_collection_recid'] = str(inscription['_id'])
|
||||
history_event_dict['action_date'] = str(now)
|
||||
|
||||
local_session_info = "Id Session : " + str(session_data['_id'])
|
||||
local_session_info = ""
|
||||
if ("code_session" in session_data.keys()):
|
||||
local_session_info = local_session_info + ", " + session_data["code_session"]
|
||||
else:
|
||||
local_session_info = "Id Session : " + str(session_data['_id'])
|
||||
|
||||
|
||||
history_event_dict['action_description'] = "Convention envoyée par email à la liste : " + str(
|
||||
tab_emails_destinataire)+" pour la session "+str(local_session_info)
|
||||
|
@ -13953,6 +13978,17 @@ def Update_LMS_Inscrition_End_Date(diction):
|
|||
inspect.stack()[0][3]) + " La date de fin n'est pas au format jj/mm/aaaa.")
|
||||
return False, " La date de fin n'est pas au format jj/mm/aaaa."
|
||||
|
||||
mytoday = datetime.today().strftime("%d/%m/%Y")
|
||||
if (datetime.strptime(str(diction['end_date'])[0:10], '%d/%m/%Y') < datetime.strptime(str(mytoday).strip(),
|
||||
'%d/%m/%Y')):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " La date de fin d'accès au LMS " + str(
|
||||
diction['end_date']) + " est antérieure à la date du jour ")
|
||||
|
||||
return False, " La date de fin d'accès au LMS " + str(
|
||||
diction['end_date']) + " est antérieure à la date du jour "
|
||||
|
||||
|
||||
# Verifier que la session est valide
|
||||
is_session_id_valide = MYSY_GV.dbname['session_formation'].count_documents(
|
||||
|
|
5179
Log/log_file.log
5179
Log/log_file.log
File diff suppressed because one or more lines are too long
|
@ -761,7 +761,8 @@ def GetSessionFormation(diction):
|
|||
'from': 'myclass',
|
||||
'localField': 'class_internal_url',
|
||||
'foreignField': 'internal_url',
|
||||
'pipeline': [{'$project': {'title': 1, 'lms_class_code':1, 'external_code':1, 'published':1, 'recyclage_delai':1, 'recyclage_periodicite':1}}],
|
||||
'pipeline': [{'$project': {'title': 1, 'lms_class_code':1, 'external_code':1, 'published':1, 'recyclage_delai':1, 'recyclage_periodicite':1,
|
||||
'lms_class_code':1}}],
|
||||
'as': 'myclass'
|
||||
}
|
||||
}
|
||||
|
@ -781,6 +782,7 @@ def GetSessionFormation(diction):
|
|||
lms_class_code = ""
|
||||
class_external_code = ""
|
||||
class_ispublished = "0"
|
||||
class_lms_class_code = ""
|
||||
|
||||
if ('myclass' in retval.keys() and len(retval['myclass']) > 0):
|
||||
|
||||
|
@ -798,10 +800,14 @@ def GetSessionFormation(diction):
|
|||
if ("published" in retval['myclass'][0].keys()):
|
||||
class_ispublished = retval['myclass'][0]['published']
|
||||
|
||||
if ("lms_class_code" in retval['myclass'][0].keys()):
|
||||
class_lms_class_code = retval['myclass'][0]['lms_class_code']
|
||||
|
||||
user['title'] = title
|
||||
user['lms_class_code'] = lms_class_code
|
||||
user['class_external_code'] = class_external_code
|
||||
user['class_ispublished'] = class_ispublished
|
||||
user['class_lms_class_code'] = class_lms_class_code
|
||||
|
||||
if ("invoiced_statut" in retval.keys()):
|
||||
user['invoiced_statut'] = retval['invoiced_statut']
|
||||
|
@ -949,7 +955,8 @@ def Get_Given_SessionFormation_From_Id(diction):
|
|||
'from': 'myclass',
|
||||
'localField': 'class_internal_url',
|
||||
'foreignField': 'internal_url',
|
||||
'pipeline': [{'$project': {'title': 1, 'lms_class_code':1, 'external_code':1, 'published':1, 'recyclage_delai':1, 'recyclage_periodicite':1}}],
|
||||
'pipeline': [{'$project': {'title': 1, 'lms_class_code':1, 'external_code':1, 'published':1, 'recyclage_delai':1, 'recyclage_periodicite':1,
|
||||
'lms_class_code':1}}],
|
||||
'as': 'myclass'
|
||||
}
|
||||
}
|
||||
|
@ -969,6 +976,7 @@ def Get_Given_SessionFormation_From_Id(diction):
|
|||
lms_class_code = ""
|
||||
class_external_code = ""
|
||||
class_ispublished = "0"
|
||||
class_lms_class_code = ""
|
||||
|
||||
if ('myclass' in retval.keys() and len(retval['myclass']) > 0):
|
||||
|
||||
|
@ -986,10 +994,14 @@ def Get_Given_SessionFormation_From_Id(diction):
|
|||
if ("published" in retval['myclass'][0].keys()):
|
||||
class_ispublished = retval['myclass'][0]['published']
|
||||
|
||||
if ("lms_class_code" in retval['myclass'][0].keys()):
|
||||
class_lms_class_code = retval['myclass'][0]['lms_class_code']
|
||||
|
||||
user['title'] = title
|
||||
user['lms_class_code'] = lms_class_code
|
||||
user['class_external_code'] = class_external_code
|
||||
user['class_ispublished'] = class_ispublished
|
||||
user['class_lms_class_code'] = class_lms_class_code
|
||||
|
||||
if ("invoiced_statut" in retval.keys() ):
|
||||
user['invoiced_statut'] = retval['invoiced_statut']
|
||||
|
@ -1436,7 +1448,8 @@ def GetAllValideSessionPartner_List(diction):
|
|||
'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}}],
|
||||
'published':1, 'recyclage_delai':1, 'recyclage_periodicite':1,
|
||||
'lms_class_code':1}}],
|
||||
'as': 'myclass_collection'
|
||||
}
|
||||
}
|
||||
|
@ -1552,6 +1565,11 @@ def GetAllValideSessionPartner_List(diction):
|
|||
else:
|
||||
val['domaine'] = ""
|
||||
|
||||
if ("lms_class_code" in retVal['myclass_collection'][0].keys()):
|
||||
val['class_lms_class_code'] = retVal['myclass_collection'][0]['lms_class_code']
|
||||
else:
|
||||
val['class_lms_class_code'] = ""
|
||||
|
||||
val['class_id'] = retVal['myclass_collection'][0]['_id']
|
||||
|
||||
val['class_external_code'] = retVal['myclass_collection'][0]['external_code']
|
||||
|
@ -1782,7 +1800,8 @@ def GetAllValideSessionPartner_List_filter_like(diction):
|
|||
'localField': 'class_internal_url',
|
||||
'foreignField': 'internal_url',
|
||||
'pipeline': [{'$match': { '$and' : [ filt_class_title, filt_class_internal_url, filt_class_external_code, {'partner_owner_recid':str(my_partner['recid'])} ]} }, {'$project': {'title': 1, 'domaine':1,
|
||||
'duration':1, 'duration_unit':1, 'external_code':1, 'recyclage_delai':1, 'recyclage_periodicite':1}}],
|
||||
'duration':1, 'duration_unit':1, 'external_code':1, 'recyclage_delai':1, 'recyclage_periodicite':1,
|
||||
'lms_class_code':1}}],
|
||||
'as': 'myclass_collection'
|
||||
}
|
||||
}
|
||||
|
@ -1906,6 +1925,10 @@ def GetAllValideSessionPartner_List_filter_like(diction):
|
|||
else:
|
||||
val['domaine'] = ""
|
||||
|
||||
if ("lms_class_code" in retVal['myclass_collection'][0].keys()):
|
||||
val['class_lms_class_code'] = retVal['myclass_collection'][0]['lms_class_code']
|
||||
else:
|
||||
val['class_lms_class_code'] = ""
|
||||
|
||||
val['class_external_code'] = retVal['myclass_collection'][0]['external_code']
|
||||
|
||||
|
@ -2116,7 +2139,8 @@ def GetAllValideSessionPartner_List_no_filter(diction):
|
|||
'foreignField': 'internal_url',
|
||||
'pipeline': [{'$match': {'partner_owner_recid': str(my_partner['recid'])} },
|
||||
{'$project': {'title': 1, 'domaine': 1,
|
||||
'duration': 1, 'duration_unit': 1, 'external_code':1, 'recyclage_delai':1, 'recyclage_periodicite':1}}],
|
||||
'duration': 1, 'duration_unit': 1, 'external_code':1, 'recyclage_delai':1, 'recyclage_periodicite':1,
|
||||
'lms_class_code':1}}],
|
||||
'as': 'myclass_collection'
|
||||
}
|
||||
}
|
||||
|
@ -2222,6 +2246,10 @@ def GetAllValideSessionPartner_List_no_filter(diction):
|
|||
else:
|
||||
val['domaine'] = ""
|
||||
|
||||
if ("lms_class_code" in retVal['myclass_collection'][0].keys()):
|
||||
val['class_lms_class_code'] = retVal['myclass_collection'][0]['lms_class_code']
|
||||
else:
|
||||
val['class_lms_class_code'] = ""
|
||||
|
||||
val['class_external_code'] = retVal['myclass_collection'][0]['external_code']
|
||||
|
||||
|
@ -4428,9 +4456,12 @@ def Delete_SessionFormation(diction):
|
|||
history_event_dict['related_collection_recid'] = str(session_data['_id'])
|
||||
history_event_dict['action_date'] = str(now)
|
||||
|
||||
local_session_info = "Id Session : " + str(session_data['_id'])
|
||||
local_session_info = ""
|
||||
|
||||
if ("code_session" in session_data.keys()):
|
||||
local_session_info = local_session_info + ", " + session_data["code_session"]
|
||||
else:
|
||||
local_session_info = "Id Session : " + str(session_data['_id'])
|
||||
|
||||
history_event_dict['action_description'] = "Suppression de " + str(local_session_info)
|
||||
local_status, local_retval = mycommon.Collection_Historique.Add_Historique_Event(history_event_dict)
|
||||
|
@ -4638,7 +4669,8 @@ def Is_Corresponding_SessionFormation(diction):
|
|||
'from': 'myclass',
|
||||
'localField': 'class_internal_url',
|
||||
'foreignField': 'internal_url',
|
||||
'pipeline': [{'$project': {'title': 1, 'lms_class_code':1, 'recyclage_delai':1, 'recyclage_periodicite':1}}],
|
||||
'pipeline': [{'$project': {'title': 1, 'lms_class_code':1, 'recyclage_delai':1, 'recyclage_periodicite':1,
|
||||
'lms_class_code':'1'}}],
|
||||
'as': 'myclass'
|
||||
}
|
||||
}
|
||||
|
@ -4969,6 +5001,202 @@ def Prepare_and_Send_Convention_From_Session_By_Email(tab_files, Folder, diction
|
|||
|
||||
|
||||
|
||||
return True, " Les conventions ont été correctement envoyées par emails"
|
||||
|
||||
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'envoyer les conventions par email "
|
||||
|
||||
|
||||
"""
|
||||
La meme que la précedente mais pour un groupe d'inscrit
|
||||
/!\ : Les convention entreprise se font par CLIENT.
|
||||
On utilise l'_id des inscrit pour aller chercher la liste des clients concernée.
|
||||
|
||||
Donc cela veut dire que mm si je n'ai pas selectionné un inscrit, si il a meme client qu'un autre inscrit qui est
|
||||
selectionné, alors la convention mentionnera la liste des 2 inscrits, car tous les 2 releve de la meme entreprise.
|
||||
"""
|
||||
def Prepare_and_Send_Convention_From_Session_For_Selected_Inscrit_By_Email(tab_files, Folder, diction):
|
||||
try:
|
||||
|
||||
field_list_obligatoire = ['token', 'session_id', 'courrier_template_id', 'email_test',
|
||||
'email_production', 'tab_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 liste ")
|
||||
return False, " La valeur '" + val + "' n'est pas presente dans liste"
|
||||
|
||||
my_token = ""
|
||||
if ("token" in diction.keys()):
|
||||
if diction['token']:
|
||||
my_token = diction['token']
|
||||
|
||||
local_status, my_partner = mycommon.Check_Connexion_And_Return_Partner_Data(diction)
|
||||
if (local_status is not True):
|
||||
return local_status, my_partner
|
||||
|
||||
# Verifier que la session est valide
|
||||
is_session_valide = MYSY_GV.dbname['session_formation'].count_documents(
|
||||
{'_id': ObjectId(str(diction['session_id'])),
|
||||
'valide': '1',
|
||||
'partner_owner_recid': str(my_partner['recid'])})
|
||||
|
||||
if (is_session_valide != 1):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " L'identifiant de la session est invalide ")
|
||||
return False, " L'identifiant de la session est invalide "
|
||||
|
||||
my_inscription_ids = ""
|
||||
if ("tab_ids" in diction.keys()):
|
||||
if diction['tab_ids']:
|
||||
my_inscription_ids = diction['tab_ids']
|
||||
|
||||
tab_my_inscription_Object_ids = []
|
||||
|
||||
tab_my_inscription_ids = str(my_inscription_ids).split(",")
|
||||
for my_inscription_id in tab_my_inscription_ids:
|
||||
tab_my_inscription_Object_ids.append(ObjectId(str(my_inscription_id)))
|
||||
|
||||
# Verifier qu'il ya bien des inscriptions valides dans la session pour le client
|
||||
liste_client_rattachement_id = MYSY_GV.dbname['inscription'].distinct("client_rattachement_id",
|
||||
{'session_id':str(diction['session_id']),
|
||||
'status': '1',
|
||||
'_id': {'$in': tab_my_inscription_Object_ids},
|
||||
'partner_owner_recid': str(
|
||||
my_partner['recid']),
|
||||
"client_rattachement_id": { '$ne': ''}
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
print(" ### la liste des liste_client_rattachement_id = ", liste_client_rattachement_id)
|
||||
|
||||
|
||||
# Sauvegarde des fichiers joints depuis le front
|
||||
tab_saved_file_full_path = []
|
||||
for file in tab_files:
|
||||
status, saved_file_full_path = mycommon.Upload_Save_PDF_IMG_File(file, Folder)
|
||||
if (status is False):
|
||||
mycommon.myprint("Impossible de récupérer correctement le fichier à importer")
|
||||
return False, "Impossible de récupérer correctement le fichier à importer"
|
||||
|
||||
tab_saved_file_full_path.append(saved_file_full_path)
|
||||
|
||||
print(" #### tab_saved_file_full_path = ", tab_saved_file_full_path)
|
||||
|
||||
# Recupération des données du modèle de document
|
||||
is_convention_by_client = "0"
|
||||
courrier_template_data = MYSY_GV.dbname['courrier_template'].find_one(
|
||||
{'_id': ObjectId(str(diction['courrier_template_id'])),
|
||||
'valide': '1',
|
||||
'locked': '0',
|
||||
'partner_owner_recid': str(my_partner['recid'])}
|
||||
)
|
||||
|
||||
if( courrier_template_data and "edit_by_client" in courrier_template_data.keys() and courrier_template_data['edit_by_client'] == "1"):
|
||||
is_convention_by_client = "1"
|
||||
|
||||
if( str(is_convention_by_client) == "1" ):
|
||||
# Envoie des conventions pour les inscrits AVEC client_id (conventions d'entreprise)
|
||||
for single_client in liste_client_rattachement_id :
|
||||
print(" Traintement du client_id = ", single_client)
|
||||
|
||||
# Recuperation des contacts de communication du client
|
||||
local_diction = {}
|
||||
local_diction['token'] = diction['token']
|
||||
local_diction['_id'] = str(single_client)
|
||||
|
||||
#print(" ##### local_diction = ", local_diction)
|
||||
local_status, partner_client_contact_communication = partner_client.Get_Partner_Client_Communication_Contact(local_diction)
|
||||
|
||||
|
||||
if (local_status is False):
|
||||
mycommon.myprint(" Impossible de récupérer les contacts de communication du client ")
|
||||
return False, " Impossible de récupérer les contacts de communication du client "
|
||||
|
||||
#print(" ### partner_client_contact_communication = ", partner_client_contact_communication)
|
||||
tab_local_email_production = []
|
||||
for tmp in partner_client_contact_communication:
|
||||
tmp_JSON = ast.literal_eval(tmp)
|
||||
if ("email" in tmp_JSON.keys()):
|
||||
tab_local_email_production.append(str(tmp_JSON["email"]))
|
||||
|
||||
list_local_email_production = ",".join(tab_local_email_production)
|
||||
|
||||
new_diction_client = {}
|
||||
new_diction_client['partner_client_id'] = single_client
|
||||
new_diction_client['token'] = diction['token']
|
||||
new_diction_client['courrier_template_id'] = diction['courrier_template_id']
|
||||
new_diction_client['email_test'] = diction['email_test']
|
||||
new_diction_client['email_production'] = str(list_local_email_production)
|
||||
new_diction_client['session_id'] = diction['session_id']
|
||||
new_diction_client['request_digital_signature'] = ""
|
||||
if( "request_digital_signature" in diction.keys() ):
|
||||
new_diction_client['request_digital_signature'] = diction['request_digital_signature']
|
||||
|
||||
|
||||
#print(" ##### new_diction_client 0102 = ", new_diction_client)
|
||||
|
||||
local_status, local_retval = Inscription_mgt.Sent_Convention_Stagiaire_By_Email_By_Partner_client(tab_saved_file_full_path, Folder, new_diction_client)
|
||||
|
||||
if( local_status is False):
|
||||
mycommon.myprint(" WARNING : impossible d'envoyer la convention au client : "+str( single_client))
|
||||
|
||||
elif (str(is_convention_by_client) == "0"):
|
||||
liste_inscription_no_client = MYSY_GV.dbname['inscription'].find(
|
||||
{"$or": [{'session_id': str(diction['session_id']),
|
||||
'status': '1',
|
||||
'_id': {'$in': tab_my_inscription_Object_ids},
|
||||
'partner_owner_recid': str(my_partner['recid']),
|
||||
"client_rattachement_id": ''
|
||||
},
|
||||
{'session_id': str(diction['session_id']),
|
||||
'status': '1',
|
||||
'_id': {'$in': tab_my_inscription_Object_ids},
|
||||
'partner_owner_recid': str(my_partner['recid']),
|
||||
'client_rattachement_id': {'$exists': False}
|
||||
}]
|
||||
}
|
||||
)
|
||||
# Envoie des conventions pour les inscrits SANS client_id (conventions individuelles)
|
||||
print(" ### is_convention_by_client ==== 0 : ")
|
||||
print(" ### LIST traitement de l'inscrit : ", liste_inscription_no_client)
|
||||
|
||||
|
||||
for single_inscrit_no_client in liste_inscription_no_client :
|
||||
print(" ### traitement de l'inscrit : ",single_inscrit_no_client )
|
||||
#field_list_obligatoire = [ 'token', 'inscription_id', 'courrier_template_id', 'email_test', 'email_production' ]
|
||||
new_diction_no_client = {}
|
||||
new_diction_no_client['token'] = str(diction['token'])
|
||||
new_diction_no_client['inscription_id'] = str(single_inscrit_no_client['_id'])
|
||||
new_diction_no_client['courrier_template_id'] = diction['courrier_template_id']
|
||||
|
||||
new_diction_no_client['session_id'] = diction['session_id']
|
||||
new_diction_no_client['email_test'] = diction['email_test']
|
||||
new_diction_no_client['email_production'] = diction['email_production']
|
||||
new_diction_no_client['request_digital_signature'] = ""
|
||||
if ("request_digital_signature" in diction.keys()):
|
||||
new_diction_no_client['request_digital_signature'] = diction['request_digital_signature']
|
||||
|
||||
print(" ##### new_diction_no_client = ", new_diction_no_client)
|
||||
local_status, local_retval = Inscription_mgt.Sent_Convention_Stagiaire_By_Email(tab_saved_file_full_path, Folder, new_diction_no_client)
|
||||
|
||||
if (local_status is False):
|
||||
mycommon.myprint(" WARNING impossible d'envoyer la convention a l'apprenant : " + str(single_inscrit_no_client['_id']) )
|
||||
|
||||
else:
|
||||
return False, " Vous devez definir si la convention est individuelle ou par client"
|
||||
|
||||
# Traitement de l'eventuel fichier joint
|
||||
tab_files_to_attache_to_mail = []
|
||||
|
||||
|
||||
|
||||
return True, " Les conventions ont été correctement envoyées par emails"
|
||||
|
||||
except Exception as e:
|
||||
|
@ -5480,6 +5708,199 @@ def Prepare_and_Send_Convention_From_Session_By_PDF(diction):
|
|||
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - Line : " + str(exc_tb.tb_lineno))
|
||||
return False, " Impossible de générer les conventions par pdf PDF "
|
||||
|
||||
"""
|
||||
La meme que la précedente sauf qu'on fourni une liste d'inscrit en argument
|
||||
/!\ : Les convention entreprise se font par CLIENT.
|
||||
On utilise l'_id des inscrit pour aller chercher la liste des clients concernée.
|
||||
|
||||
Donc cela veut dire que mm si je n'ai pas selectionné un inscrit, si il a meme client qu'un autre inscrit qui est
|
||||
selectionné, alors la convention mentionnera la liste des 2 inscrits, car tous les 2 releve de la meme entreprise.
|
||||
"""
|
||||
def Prepare_and_Send_Convention_From_Session_For_Selected_Inscrit_By_PDF(diction):
|
||||
try:
|
||||
field_list_obligatoire = ['token', 'session_id', 'courrier_template_id', 'tab_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 liste ")
|
||||
return False, " La valeur '" + val + "' n'est pas presente dans liste"
|
||||
elif str(diction[val]).strip() == "":
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " Le champ obligatoire '" + val + "' est vide ")
|
||||
return False, " Le champ obligatoire '" + val + "' est vide "
|
||||
|
||||
|
||||
my_token = ""
|
||||
if ("token" in diction.keys()):
|
||||
if diction['token']:
|
||||
my_token = diction['token']
|
||||
|
||||
local_status, my_partner = mycommon.Check_Connexion_And_Return_Partner_Data(diction)
|
||||
if (local_status is not True):
|
||||
return local_status, my_partner
|
||||
|
||||
# Verifier que la session est valide
|
||||
is_session_valide = MYSY_GV.dbname['session_formation'].count_documents(
|
||||
{'_id': ObjectId(str(diction['session_id'])),
|
||||
'valide': '1',
|
||||
'partner_owner_recid': str(my_partner['recid'])})
|
||||
|
||||
if (is_session_valide != 1):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " L'identifiant de la session est invalide ")
|
||||
return False, " L'identifiant de la session est invalide "
|
||||
|
||||
my_inscription_ids = ""
|
||||
if ("tab_ids" in diction.keys()):
|
||||
if diction['tab_ids']:
|
||||
my_inscription_ids = diction['tab_ids']
|
||||
|
||||
tab_my_inscription_Object_ids = []
|
||||
|
||||
tab_my_inscription_ids = str(my_inscription_ids).split(",")
|
||||
for my_inscription_id in tab_my_inscription_ids:
|
||||
tab_my_inscription_Object_ids.append(ObjectId(str(my_inscription_id)))
|
||||
|
||||
# Stokage des nom de fichier à zipper
|
||||
list_file_name_to_zip = []
|
||||
|
||||
# Verifier qu'il ya bien des inscriptions valides dans la session pour le client
|
||||
|
||||
liste_client_rattachement_id = MYSY_GV.dbname['inscription'].distinct("client_rattachement_id",
|
||||
{'session_id':str(diction['session_id']),
|
||||
'status': '1',
|
||||
'_id': {
|
||||
'$in': tab_my_inscription_Object_ids},
|
||||
'partner_owner_recid': str(
|
||||
my_partner['recid']),
|
||||
"client_rattachement_id": { '$ne': ''}
|
||||
}
|
||||
)
|
||||
|
||||
print(" ### la liste des liste_client_rattachement_id = ", liste_client_rattachement_id)
|
||||
|
||||
# Recuperer inscriptions indépenantes, donc pas liée à un client
|
||||
|
||||
|
||||
liste_inscription_no_client = MYSY_GV.dbname['inscription'].find({"$or": [{'session_id': str(diction['session_id']),
|
||||
'status': '1',
|
||||
'_id': {
|
||||
'$in': tab_my_inscription_Object_ids},
|
||||
'partner_owner_recid': str(my_partner['recid']),
|
||||
"client_rattachement_id": ''
|
||||
},
|
||||
{'session_id': str(diction['session_id']),
|
||||
'status': '1',
|
||||
'_id': {
|
||||
'$in': tab_my_inscription_Object_ids},
|
||||
'partner_owner_recid': str(my_partner['recid']),
|
||||
'client_rattachement_id': {'$exists': False}
|
||||
}]
|
||||
}
|
||||
)
|
||||
|
||||
"""
|
||||
for val in liste_inscription_no_client:
|
||||
print(" ### la liste des liste_inscription_no_client = ", str(val))
|
||||
"""
|
||||
|
||||
|
||||
|
||||
# Recupération des données du modèle de document
|
||||
is_convention_by_client = "0"
|
||||
courrier_template_data = MYSY_GV.dbname['courrier_template'].find_one(
|
||||
{'_id': ObjectId(str(diction['courrier_template_id'])),
|
||||
'valide': '1',
|
||||
'locked': '0',
|
||||
'partner_owner_recid': str(my_partner['recid'])}
|
||||
)
|
||||
|
||||
if (courrier_template_data and "edit_by_client" in courrier_template_data.keys() and courrier_template_data[
|
||||
'edit_by_client'] == "1"):
|
||||
is_convention_by_client = "1"
|
||||
|
||||
if (str(is_convention_by_client) == "1"):
|
||||
# Envoie des conventions pour les inscrits AVEC client_id
|
||||
for val in liste_client_rattachement_id:
|
||||
local_diction = {}
|
||||
# field_list_obligatoire = ['token', 'session_id', 'courrier_template_id', 'client_id']
|
||||
local_diction['token'] = diction['token']
|
||||
local_diction['session_id'] = diction['session_id']
|
||||
local_diction['courrier_template_id'] = diction['courrier_template_id']
|
||||
local_diction['client_id'] = str(val)
|
||||
|
||||
|
||||
local_status, local_full_file_name = Create_Convention_By_Client_PDF(local_diction)
|
||||
if( local_status is False):
|
||||
return local_status, local_full_file_name
|
||||
else:
|
||||
list_file_name_to_zip.append(str(local_full_file_name))
|
||||
|
||||
|
||||
|
||||
|
||||
elif (str(is_convention_by_client) == "0"):
|
||||
liste_inscription_no_client = MYSY_GV.dbname['inscription'].find(
|
||||
{"$or": [{'session_id': str(diction['session_id']),
|
||||
'status': '1',
|
||||
'_id': {'$in': tab_my_inscription_Object_ids},
|
||||
'partner_owner_recid': str(my_partner['recid']),
|
||||
"client_rattachement_id": ''
|
||||
},
|
||||
{'session_id': str(diction['session_id']),
|
||||
'status': '1',
|
||||
'_id': {'$in': tab_my_inscription_Object_ids},
|
||||
'partner_owner_recid': str(my_partner['recid']),
|
||||
'client_rattachement_id': {'$exists': False}
|
||||
}]
|
||||
}
|
||||
)
|
||||
for val in liste_inscription_no_client:
|
||||
local_diction = {}
|
||||
# field_list_obligatoire = ['token', 'session_id', 'courrier_template_id', 'client_id']
|
||||
local_diction['token'] = diction['token']
|
||||
local_diction['session_id'] = diction['session_id']
|
||||
local_diction['courrier_template_id'] = diction['courrier_template_id']
|
||||
local_diction['inscription_id'] = str(val['_id'])
|
||||
|
||||
#print(" #### Traitemnt de local_diction bb = ", local_diction)
|
||||
local_status, local_full_file_name = Create_Convention_By_Stagiaire_PDF(local_diction)
|
||||
if( local_status is False):
|
||||
return local_status, local_full_file_name
|
||||
else:
|
||||
list_file_name_to_zip.append(str(local_full_file_name))
|
||||
|
||||
|
||||
# Create a ZipFile Object
|
||||
todays_date = str(date.today().strftime("%d/%m/%Y"))
|
||||
ts = datetime.now().timestamp()
|
||||
ts = str(ts).replace(".", "").replace(",", "")[-3:]
|
||||
zip_file_name = str(MYSY_GV.TEMPORARY_DIRECTORY_V2)+"List_Convention_session_"+str(diction['session_id'])+"_"+str(ts)+".zip"
|
||||
|
||||
with ZipFile(zip_file_name, 'w') as zip_object:
|
||||
for pdf_files in list_file_name_to_zip :
|
||||
#print(" ### fichier a zipper = ", pdf_files)
|
||||
zip_object.write(str(pdf_files))
|
||||
|
||||
|
||||
if os.path.exists(zip_file_name):
|
||||
# print(" ### ok os.path.exists(outputFilename) "+str(outputFilename))
|
||||
|
||||
return True, send_file(zip_file_name, as_attachment=True)
|
||||
|
||||
|
||||
return False, " Impossible de générer les conventions par pdf PDF (1) "
|
||||
|
||||
|
||||
|
||||
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 générer les conventions par pdf PDF "
|
||||
|
||||
|
||||
"""
|
||||
|
@ -6234,6 +6655,129 @@ def Prepare_and_Send_Convocation_From_Session_By_PDF(diction):
|
|||
return False, " Impossible de générer les conventions par pdf PDF "
|
||||
|
||||
|
||||
"""
|
||||
La meme que la précedente mais juste pour une liste d'inscrit"""
|
||||
def Prepare_and_Send_Convocation_From_Session_For_Selected_Inscrit_By_PDF(diction):
|
||||
try:
|
||||
field_list_obligatoire = ['token', 'session_id', 'courrier_template_id', 'tab_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 liste ")
|
||||
return False, " La valeur '" + val + "' n'est pas presente dans liste"
|
||||
|
||||
my_token = ""
|
||||
if ("token" in diction.keys()):
|
||||
if diction['token']:
|
||||
my_token = diction['token']
|
||||
|
||||
local_status, my_partner = mycommon.Check_Connexion_And_Return_Partner_Data(diction)
|
||||
if (local_status is not True):
|
||||
return local_status, my_partner
|
||||
|
||||
# Verifier que la session est valide
|
||||
is_session_valide = MYSY_GV.dbname['session_formation'].count_documents(
|
||||
{'_id': ObjectId(str(diction['session_id'])),
|
||||
'valide': '1',
|
||||
'partner_owner_recid': str(my_partner['recid'])})
|
||||
|
||||
if (is_session_valide != 1):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " L'identifiant de la session est invalide ")
|
||||
return False, " L'identifiant de la session est invalide "
|
||||
|
||||
# Stokage des nom de fichier à zipper
|
||||
list_file_name_to_zip = []
|
||||
|
||||
my_inscription_ids = ""
|
||||
if ("tab_ids" in diction.keys()):
|
||||
if diction['tab_ids']:
|
||||
my_inscription_ids = diction['tab_ids']
|
||||
|
||||
tab_my_inscription_Object_ids = []
|
||||
|
||||
tab_my_inscription_ids = str(my_inscription_ids).split(",")
|
||||
for my_inscription_id in tab_my_inscription_ids:
|
||||
tab_my_inscription_Object_ids.append(ObjectId(str(my_inscription_id)))
|
||||
|
||||
|
||||
"""
|
||||
for val in liste_inscription_no_client:
|
||||
print(" ### la liste des liste_inscription_no_client = ", str(val))
|
||||
"""
|
||||
|
||||
|
||||
|
||||
# Recupération des données du modèle de document
|
||||
is_convention_by_client = "0"
|
||||
courrier_template_data = MYSY_GV.dbname['courrier_template'].find_one(
|
||||
{'_id': ObjectId(str(diction['courrier_template_id'])),
|
||||
'valide': '1',
|
||||
'locked': '0',
|
||||
'partner_owner_recid': str(my_partner['recid'])}
|
||||
)
|
||||
|
||||
if (courrier_template_data and "edit_by_client" in courrier_template_data.keys() and courrier_template_data[
|
||||
'edit_by_client'] == "1"):
|
||||
is_convention_by_client = "1"
|
||||
|
||||
|
||||
if (str(is_convention_by_client) == "0"):
|
||||
liste_participants = MYSY_GV.dbname['inscription'].find({'session_id': str(diction['session_id']),
|
||||
'_id': {'$in': tab_my_inscription_Object_ids},
|
||||
'status': '1',
|
||||
'partner_owner_recid': str(my_partner['recid']),
|
||||
}
|
||||
)
|
||||
for val in liste_participants:
|
||||
local_diction = {}
|
||||
# field_list_obligatoire = ['token', 'session_id', 'courrier_template_id', 'client_id']
|
||||
local_diction['token'] = diction['token']
|
||||
local_diction['session_id'] = diction['session_id']
|
||||
local_diction['courrier_template_id'] = diction['courrier_template_id']
|
||||
local_diction['inscription_id'] = str(val['_id'])
|
||||
|
||||
print(" #### Traitemnt de local_diction bb = ", local_diction)
|
||||
local_status, local_full_file_name = Create_Convocation_By_Stagiaire_PDF(local_diction)
|
||||
if( local_status is False):
|
||||
return local_status, local_full_file_name
|
||||
else:
|
||||
list_file_name_to_zip.append(str(local_full_file_name))
|
||||
|
||||
|
||||
# Create a ZipFile Object
|
||||
todays_date = str(date.today().strftime("%d/%m/%Y"))
|
||||
ts = datetime.now().timestamp()
|
||||
ts = str(ts).replace(".", "").replace(",", "")[-3:]
|
||||
zip_file_name = str(MYSY_GV.TEMPORARY_DIRECTORY_V2)+"List_Convocation_session_"+str(diction['session_id'])+"_"+str(ts)+".zip"
|
||||
|
||||
with ZipFile(zip_file_name, 'w') as zip_object:
|
||||
for pdf_files in list_file_name_to_zip :
|
||||
#print(" ### fichier a zipper = ", pdf_files)
|
||||
zip_object.write(str(pdf_files))
|
||||
|
||||
|
||||
if os.path.exists(zip_file_name):
|
||||
# print(" ### ok os.path.exists(outputFilename) "+str(outputFilename))
|
||||
|
||||
return True, send_file(zip_file_name, as_attachment=True)
|
||||
|
||||
|
||||
return False, " Impossible de générer les conventions par pdf PDF (1) "
|
||||
|
||||
|
||||
|
||||
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 générer les conventions par pdf PDF "
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Cette fonction créer une convocation PDF par participant à une session de formation
|
||||
|
@ -6541,6 +7085,147 @@ def Prepare_and_Send_Convocation_From_Session_By_Email(tab_files, Folder, dictio
|
|||
return False, " Impossible d'envoyer les conventions par email "
|
||||
|
||||
|
||||
"""
|
||||
La meme que la précedentes, a la difference qu'on envoie les convocation
|
||||
pour une liste d'inscrits bien précise.
|
||||
|
||||
"""
|
||||
def Prepare_and_Send_Convocation_From_Session_For_Selected_Inscrit_By_Email(tab_files, Folder, diction):
|
||||
try:
|
||||
|
||||
field_list_obligatoire = ['token', 'session_id', 'courrier_template_id', 'email_test', 'email_production',
|
||||
'tab_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 liste ")
|
||||
return False, " La valeur '" + val + "' n'est pas presente dans liste"
|
||||
|
||||
my_token = ""
|
||||
if ("token" in diction.keys()):
|
||||
if diction['token']:
|
||||
my_token = diction['token']
|
||||
|
||||
local_status, my_partner = mycommon.Check_Connexion_And_Return_Partner_Data(diction)
|
||||
if (local_status is not True):
|
||||
return local_status, my_partner
|
||||
|
||||
# Verifier que la session est valide
|
||||
is_session_valide = MYSY_GV.dbname['session_formation'].count_documents(
|
||||
{'_id': ObjectId(str(diction['session_id'])),
|
||||
'valide': '1',
|
||||
'partner_owner_recid': str(my_partner['recid'])})
|
||||
|
||||
if (is_session_valide != 1):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " L'identifiant de la session est invalide ")
|
||||
return False, " L'identifiant de la session est invalide "
|
||||
|
||||
my_inscription_ids = ""
|
||||
if ("tab_ids" in diction.keys()):
|
||||
if diction['tab_ids']:
|
||||
my_inscription_ids = diction['tab_ids']
|
||||
|
||||
tab_my_inscription_Object_ids = []
|
||||
|
||||
tab_my_inscription_ids = str(my_inscription_ids).split(",")
|
||||
for my_inscription_id in tab_my_inscription_ids:
|
||||
tab_my_inscription_Object_ids.append(ObjectId(str(my_inscription_id)))
|
||||
|
||||
# Verifier qu'il ya bien des inscriptions valides dans la session pour le client
|
||||
liste_participants = MYSY_GV.dbname['inscription'].find({'session_id': str(diction['session_id']),
|
||||
'_id': {'$in': tab_my_inscription_Object_ids},
|
||||
'status': '1',
|
||||
'partner_owner_recid': str(my_partner['recid']),
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
print(" ### la liste des liste_participants = ", liste_participants)
|
||||
|
||||
|
||||
# Sauvegarde des fichiers joints depuis le front
|
||||
tab_saved_file_full_path = []
|
||||
for file in tab_files:
|
||||
status, saved_file_full_path = mycommon.Upload_Save_PDF_IMG_File(file, Folder)
|
||||
if (status is False):
|
||||
mycommon.myprint("Impossible de récupérer correctement le fichier à importer")
|
||||
return False, "Impossible de récupérer correctement le fichier à importer"
|
||||
|
||||
tab_saved_file_full_path.append(saved_file_full_path)
|
||||
|
||||
print(" #### tab_saved_file_full_path = ", tab_saved_file_full_path)
|
||||
|
||||
# Recupération des données du modèle de document
|
||||
is_convention_by_client = "0"
|
||||
courrier_template_data = MYSY_GV.dbname['courrier_template'].find_one(
|
||||
{'_id': ObjectId(str(diction['courrier_template_id'])),
|
||||
'valide': '1',
|
||||
'locked': '0',
|
||||
'partner_owner_recid': str(my_partner['recid'])}
|
||||
)
|
||||
|
||||
if( courrier_template_data and "edit_by_client" in courrier_template_data.keys() and courrier_template_data['edit_by_client'] == "1"):
|
||||
is_convention_by_client = "1"
|
||||
|
||||
|
||||
if (str(is_convention_by_client) == "0"):
|
||||
liste_inscription = MYSY_GV.dbname['inscription'].find({'session_id': str(diction['session_id']),
|
||||
'_id': {'$in': tab_my_inscription_Object_ids},
|
||||
'status': '1',
|
||||
'partner_owner_recid': str(my_partner['recid']),
|
||||
}
|
||||
)
|
||||
|
||||
print(" ### LIST liste_inscription: ", liste_inscription)
|
||||
|
||||
|
||||
for single_inscrit in liste_inscription :
|
||||
print(" ### convocation traitement de l'inscrit : ",single_inscrit )
|
||||
#field_list_obligatoire = [ 'token', 'inscription_id', 'courrier_template_id', 'email_test', 'email_production' ]
|
||||
new_diction_no_client = {}
|
||||
new_diction_no_client['token'] = str(diction['token'])
|
||||
new_diction_no_client['inscription_id'] = str(single_inscrit['_id'])
|
||||
new_diction_no_client['courrier_template_id'] = diction['courrier_template_id']
|
||||
|
||||
new_diction_no_client['session_id'] = diction['session_id']
|
||||
new_diction_no_client['email_test'] = diction['email_test']
|
||||
new_diction_no_client['email_production'] = diction['email_production']
|
||||
|
||||
print(" ##### new_diction_no_client = ", new_diction_no_client)
|
||||
local_status, local_retval = Sent_Convocation_Stagiaire_By_Email(tab_saved_file_full_path, Folder, new_diction_no_client)
|
||||
|
||||
if (local_status is False):
|
||||
mycommon.myprint(" WARNING impossible d'envoyer la convocation a l'apprenant : " + str(single_inscrit['_id']) )
|
||||
|
||||
|
||||
# Traitement de l'eventuel fichier joint
|
||||
tab_files_to_attache_to_mail = []
|
||||
|
||||
"""
|
||||
25/01/2024 : pour loger une action dans la collection ==> courrier_template_tracking_history
|
||||
"""
|
||||
"""local_status, local_retval = module_editique.Editic_Log_History_Action(my_partner, courrier_template_data,
|
||||
str(diction['session_id']), "inscription", str(single_inscrit['_id']))"""
|
||||
|
||||
local_status, local_retval = module_editique.Editic_Log_History_Action_From_courrier_template_type_document_ref_interne(
|
||||
my_partner, "CONVOCATION_STAGIAIRE", str(diction['session_id']), 'inscription',
|
||||
str(single_inscrit['_id']),
|
||||
str(str(courrier_template_data['_id'])))
|
||||
|
||||
|
||||
return True, " Les convocations ont été correctement envoyées par emails"
|
||||
|
||||
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'envoyer les conventions par email "
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Envoi d'une convocation pour un participant donné par email
|
||||
Si le participants est rattaché à un client , alors on va mettre en copie de
|
||||
|
@ -6944,7 +7629,7 @@ def Sent_Convocation_Stagiaire_By_Email(tab_files, Folder, diction):
|
|||
|
||||
val = smtpserver.send_message(msg)
|
||||
smtpserver.close()
|
||||
print(" Email envoyé " + str(val))
|
||||
print(" Email envoyé 66" + str(val))
|
||||
|
||||
"""
|
||||
# Ajout de l'evenement dans l'historique
|
||||
|
@ -6958,7 +7643,7 @@ def Sent_Convocation_Stagiaire_By_Email(tab_files, Folder, diction):
|
|||
history_event_dict['related_collection'] = "inscription"
|
||||
history_event_dict['related_collection_recid'] = str(diction['inscription_id'])
|
||||
history_event_dict['action_date'] = str(now)
|
||||
history_event_dict['action_description'] = "Convention envoyée par email à la liste : " + str(
|
||||
history_event_dict['action_description'] = "Convocation envoyée par email à la liste : " + str(
|
||||
tab_emails_destinataire)
|
||||
local_status, local_retval = mycommon.Collection_Historique.Add_Historique_Event(history_event_dict)
|
||||
if (local_status is False):
|
||||
|
@ -9203,7 +9888,7 @@ def Sent_Facture_Stagiaire_By_Email_By_Partner_client(tab_files_name_full_path,
|
|||
|
||||
val = smtpserver.send_message(msg)
|
||||
smtpserver.close()
|
||||
print(" Email envoyé " + str(val))
|
||||
print(" 22 Email envoyé " + str(val))
|
||||
|
||||
"""
|
||||
25/01/2024 : pour loger une action dans la collection ==> courrier_template_tracking_history
|
||||
|
@ -9236,7 +9921,7 @@ def Sent_Facture_Stagiaire_By_Email_By_Partner_client(tab_files_name_full_path,
|
|||
history_event_dict['related_collection'] = "partner_client"
|
||||
history_event_dict['related_collection_recid'] = str(diction['partner_client_id'])
|
||||
history_event_dict['action_date'] = str(now)
|
||||
history_event_dict['action_description'] = "Convention envoyée par email à la liste : " + str(
|
||||
history_event_dict['action_description'] = "Facture envoyée par email à la liste : " + str(
|
||||
tab_emails_destinataire)
|
||||
local_status, local_retval = mycommon.Collection_Historique.Add_Historique_Event(history_event_dict)
|
||||
if (local_status is False):
|
||||
|
@ -12023,7 +12708,8 @@ def Invoice_Create_Secure_E_Document(diction):
|
|||
{'$project': {'title': 1, 'domaine': 1,
|
||||
'duration': 1,
|
||||
'duration_unit': 1,
|
||||
'external_code': 1,'recyclage_delai':1, 'recyclage_periodicite':1}}],
|
||||
'external_code': 1,'recyclage_delai':1, 'recyclage_periodicite':1,
|
||||
'lms_class_code':1}}],
|
||||
'as': 'myclass_collection'
|
||||
}
|
||||
}
|
||||
|
@ -12829,7 +13515,7 @@ def Send_Email_request_presinscription_data_validation(diction):
|
|||
|
||||
val = smtpserver.send_message(msg)
|
||||
smtpserver.close()
|
||||
print(" Email envoyé " + str(val))
|
||||
print(" Email envoyé 44" + str(val))
|
||||
|
||||
return True, "Les demandes de mise à jour ont été envoyées"
|
||||
|
||||
|
|
|
@ -1903,7 +1903,9 @@ def LMS_Credential_Sending_mail(diction):
|
|||
"""
|
||||
Verification de la liste des champs obligatoires
|
||||
"""
|
||||
field_list_obligatoire = ['nom', 'prenom', 'email', 'date_du', 'date_au', 'title', 'login', 'pwd', 'lms_url', 'course_owner_email', 'partner_recid' ]
|
||||
field_list_obligatoire = ['token', 'inscription_id', 'session_code','nom', 'prenom', 'email',
|
||||
'date_du', 'date_au', 'title', 'login', 'pwd',
|
||||
'lms_url', 'course_owner_email', 'partner_recid' ]
|
||||
for val in field_list_obligatoire:
|
||||
if val not in diction:
|
||||
mycommon.myprint(
|
||||
|
@ -1945,35 +1947,56 @@ def LMS_Credential_Sending_mail(diction):
|
|||
|
||||
adresse_session = my_adress
|
||||
|
||||
"""
|
||||
A présent on va aller recuperer le modele de courrier de notification
|
||||
"""
|
||||
local_diction = {}
|
||||
local_diction['ref_interne'] = "LMS_USER_ACCES_NOTIF"
|
||||
local_diction['type_doc'] = "email"
|
||||
local_diction['partner_owner_recid'] = str(diction['partner_recid'])
|
||||
|
||||
# on rentre les renseignements pris sur le site du fournisseur
|
||||
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 'LMS_USER_ACCES_NOTIF' ")
|
||||
return False, " Impossible de récuperer le modèle de courrier 'LMS_USER_ACCES_NOTIF' "
|
||||
|
||||
# msg = MIMEMultipart("alternative")
|
||||
|
||||
# JINJA2
|
||||
templateLoader = jinja2.FileSystemLoader(searchpath="./")
|
||||
templateEnv = jinja2.Environment(loader=templateLoader)
|
||||
TEMPLATE_FILE = "Template/MySy_LMS_credential_sending_tpl.html"
|
||||
template = templateEnv.get_template(TEMPLATE_FILE)
|
||||
# This data can come from database query
|
||||
body = {}
|
||||
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 'LMS_USER_ACCES_NOTIF' n'est pas correctement configuré ")
|
||||
return False, " Le modèle de courrier 'LMS_USER_ACCES_NOTIF' n'est pas correctement configuré "
|
||||
|
||||
new_diction = {}
|
||||
new_diction['token'] = str(diction['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
|
||||
|
||||
dictionnary_data = local_retval
|
||||
dictionnary_data['credential_data'] = diction
|
||||
|
||||
body = {
|
||||
"params": dictionnary_data,
|
||||
}
|
||||
|
||||
"params": {"nom": str(diction['nom']),
|
||||
"prenom": str(diction['prenom']),
|
||||
"date_du": str(diction['date_du']),
|
||||
"date_fin": str(diction['date_au']),
|
||||
"adresse": str(adresse_session),
|
||||
"title": str(diction['title']),
|
||||
"email": str(diction['email']),
|
||||
"login": str(diction['login']),
|
||||
"pwd": str(diction['pwd']),
|
||||
"lms_url": str(diction['lms_url']),
|
||||
"course_owner_email": str(diction['course_owner_email'])},
|
||||
}
|
||||
# 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']))
|
||||
sourceHtml = contenu_doc_Template.render(params=body["params"])
|
||||
html_mime = MIMEText(sourceHtml, 'html')
|
||||
|
||||
sourceHtml = template.render(params=body["params"])
|
||||
|
||||
"""
|
||||
Recuperation des parametre SMTP du partner si le client a decidé d'utiliser son propre smpt
|
||||
|
@ -2019,43 +2042,63 @@ def LMS_Credential_Sending_mail(diction):
|
|||
'valide': '1',
|
||||
'locked': '0'}, {'config_value': 1})['config_value'])
|
||||
|
||||
msg = MIMEMultipart("alternative")
|
||||
if (str(partner_own_smtp_value) == "1"):
|
||||
smtpserver = smtplib.SMTP(partner_SMTP_COUNT_smtpsrv, partner_SMTP_COUNT_port)
|
||||
msg = EmailMessage()
|
||||
msg.set_content(sourceHtml, subtype='html')
|
||||
msg.attach(html_mime)
|
||||
msg['From'] = partner_SMTP_COUNT_From_User
|
||||
msg['Bcc'] = 'contact@mysy-training.com,' + str(str(diction['course_owner_email']))
|
||||
msg['Subject'] = '[MySy Training]: Vos identifications de connexion'
|
||||
msg['Subject'] = sujetHtml
|
||||
msg['To'] = str(diction['email'])
|
||||
smtpserver.ehlo()
|
||||
smtpserver.starttls()
|
||||
smtpserver.login(partner_SMTP_COUNT_user, partner_SMTP_COUNT_password)
|
||||
val = smtpserver.send_message(msg)
|
||||
smtpserver.close()
|
||||
print(" Email confirlation envoyé " + str(val))
|
||||
print(" Email d'acces lms envoyé à " + str(diction['email']))
|
||||
|
||||
else:
|
||||
smtpserver = smtplib.SMTP(MYSY_GV.O365_SMTP_COUNT_smtpsrv, MYSY_GV.O365_SMTP_COUNT_port)
|
||||
msg = EmailMessage()
|
||||
msg.set_content(sourceHtml, subtype='html')
|
||||
msg.attach(html_mime)
|
||||
msg['From'] = MYSY_GV.O365_SMTP_COUNT_From_User
|
||||
msg['Bcc'] = 'contact@mysy-training.com,'+str(str(diction['course_owner_email']))
|
||||
msg['Subject'] = '[MySy Training]: Vos identifications de connexion'
|
||||
msg['Subject'] = sujetHtml
|
||||
msg['To'] = str(diction['email'])
|
||||
smtpserver.ehlo()
|
||||
smtpserver.starttls()
|
||||
smtpserver.login(MYSY_GV.O365_SMTP_COUNT_user, MYSY_GV.O365_SMTP_COUNT_password)
|
||||
val = smtpserver.send_message(msg)
|
||||
smtpserver.close()
|
||||
print(" Email confirlation envoyé " + str(val))
|
||||
print(" Email d'acces lms envoyé à " + str(diction['email']))
|
||||
|
||||
|
||||
return True, " Email d'identification de connexion envoyé "
|
||||
"""
|
||||
Logguer l'action dans l'historique de l'apprenant
|
||||
"""
|
||||
now = str(datetime.datetime.now().strftime("%d/%m/%Y %H:%M:%S"))
|
||||
# print(" ####### laaaa diction = ", diction)
|
||||
|
||||
history_event_dict = {}
|
||||
history_event_dict['token'] = str(diction['token'])
|
||||
history_event_dict['related_collection'] = "inscription"
|
||||
history_event_dict['related_collection_recid'] = str(diction['inscription_id'])
|
||||
history_event_dict['action_date'] = str(now)
|
||||
|
||||
|
||||
history_event_dict['action_description'] = "(R)envoi des accès à la plateforme de E-Learning à pour session de formation " + str(diction['session_code'])
|
||||
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 pour l'évènement : " + str(history_event_dict))
|
||||
|
||||
return True, "Les identifiants accès à la plateforme de E-Learning ont été correctement envoyés "
|
||||
|
||||
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 d'envoyer l'email de notification "
|
||||
return False, " Impossible d'envoyer les identifiants accès à la plateforme de E-Learning "
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Fonction qui envoi les identifiant de connexion à un employé dont on vient de créer le compte
|
||||
|
|
93
main.py
93
main.py
|
@ -2446,6 +2446,30 @@ def Prepare_and_Send_Convention_From_Session_By_Email():
|
|||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
|
||||
"""
|
||||
API : pour préparer et envoyer les convention en partant d'une session MAIS
|
||||
Avec un liste d'inscrits
|
||||
"""
|
||||
@app.route('/myclass/api/Prepare_and_Send_Convention_From_Session_For_Selected_Inscrit_By_Email/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Prepare_and_Send_Convention_From_Session_For_Selected_Inscrit_By_Email():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Prepare_and_Send_Convention_From_Session_For_Selected_Inscrit_By_Email : payload = ",str(payload))
|
||||
|
||||
file = []
|
||||
if request.method == 'POST':
|
||||
# Create variable for uploaded file
|
||||
tab_files = []
|
||||
for tmp in request.files.getlist("File"):
|
||||
tab_files.append(tmp)
|
||||
|
||||
status, retval = SF.Prepare_and_Send_Convention_From_Session_For_Selected_Inscrit_By_Email(tab_files, MYSY_GV.TEMPORARY_DIRECTORY_V2, payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
|
||||
"""
|
||||
API : pour préprer et envoyer les conventions PAR DEFAUT en partant d'une session
|
||||
"""
|
||||
|
@ -2490,6 +2514,29 @@ def Prepare_and_Send_Convention_From_Session_By_PDF(token, session_id, courrier_
|
|||
else:
|
||||
return False
|
||||
|
||||
"""
|
||||
API : pour préprer et générer un zip de fichier PDF pour les convention en partant d'une session avec une liste d'inscrit
|
||||
"""
|
||||
@app.route('/myclass/api/Prepare_and_Send_Convention_From_Session_For_Selected_Inscrit_By_PDF/<token>/<session_id>/<courrier_template_id>/<tab_ids>', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Prepare_and_Send_Convention_From_Session_For_Selected_Inscrit_By_PDF(token, session_id, courrier_template_id, tab_ids):
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
payload = {}
|
||||
payload['token'] = str(token)
|
||||
payload['session_id'] = str(session_id)
|
||||
payload['courrier_template_id'] = str(courrier_template_id)
|
||||
payload['tab_ids'] = str(tab_ids)
|
||||
|
||||
|
||||
print(" ### Prepare_and_Send_Convention_From_Session_For_Selected_Inscrit_By_PDF : payload = ",str(payload))
|
||||
|
||||
localStatus, response= SF.Prepare_and_Send_Convention_From_Session_For_Selected_Inscrit_By_PDF(payload)
|
||||
if(localStatus ):
|
||||
return response
|
||||
else:
|
||||
return False
|
||||
|
||||
|
||||
"""
|
||||
API : pour préprer et générer un zip de fichier PDF pour les convention par defaut en partant d'une session.
|
||||
|
@ -8463,6 +8510,30 @@ def Prepare_and_Send_Convocation_From_Session_By_PDF(token, session_id, courrier
|
|||
|
||||
|
||||
|
||||
"""
|
||||
API : pour préprer et générer un zip de fichier PDF pour les convocation en partant d'une session
|
||||
pour une liste d'inscrit bien definie
|
||||
"""
|
||||
@app.route('/myclass/api/Prepare_and_Send_Convocation_From_Session_For_Selected_Inscrit_By_PDF/<token>/<session_id>/<courrier_template_id>/<tab_ids>', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Prepare_and_Send_Convocation_From_Session_For_Selected_Inscrit_By_PDF(token, session_id, courrier_template_id, tab_ids):
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
payload = {}
|
||||
payload['token'] = str(token)
|
||||
payload['session_id'] = str(session_id)
|
||||
payload['courrier_template_id'] = str(courrier_template_id)
|
||||
payload['tab_ids'] = str(tab_ids)
|
||||
|
||||
print(" ### Prepare_and_Send_Convocation_From_Session_For_Selected_Inscrit_By_PDF : payload = ",str(payload))
|
||||
|
||||
localStatus, response= SF.Prepare_and_Send_Convocation_From_Session_For_Selected_Inscrit_By_PDF(payload)
|
||||
if(localStatus ):
|
||||
return response
|
||||
else:
|
||||
return False
|
||||
|
||||
|
||||
"""
|
||||
API : pour préprer et envoyer les convocations en partant d'une session
|
||||
"""
|
||||
|
@ -8484,6 +8555,28 @@ def Prepare_and_Send_Convocation_From_Session_By_Email():
|
|||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
"""
|
||||
API : pour préprer et envoyer les convocations en partant d'une session avec une liste d'inscrits bien definie
|
||||
"""
|
||||
@app.route('/myclass/api/Prepare_and_Send_Convocation_From_Session_For_Selected_Inscrit_By_Email/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Prepare_and_Send_Convocation_From_Session_For_Selected_Inscrit_By_Email():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Prepare_and_Send_Convocation_From_Session_For_Selected_Inscrit_By_Email : payload = ",str(payload))
|
||||
|
||||
file = []
|
||||
if request.method == 'POST':
|
||||
# Create variable for uploaded file
|
||||
tab_files = []
|
||||
for tmp in request.files.getlist("File"):
|
||||
tab_files.append(tmp)
|
||||
|
||||
status, retval = SF.Prepare_and_Send_Convocation_From_Session_For_Selected_Inscrit_By_Email(tab_files, MYSY_GV.TEMPORARY_DIRECTORY_V2, payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
|
||||
|
||||
"""
|
||||
API pour initialiser les attestation de formation pour une session données
|
||||
|
|
|
@ -2713,7 +2713,7 @@ def Create_Partner_Client_Intranet_Account(diction):
|
|||
if( admin_partnair and 'subdomaine_catalog_pub' in admin_partnair.keys() ):
|
||||
subdomaine_catalog_pub = admin_partnair['subdomaine_catalog_pub']
|
||||
else:
|
||||
return True, " WARNING : Le compte intranet du client a été mais impossible d'envoyer l'email de notification au client (22) "
|
||||
return True, " WARNING : Le compte intranet du client a été mais impossible d'envoyer l'email de notification au client "
|
||||
|
||||
|
||||
dictionnary_data = local_retval
|
||||
|
|
Loading…
Reference in New Issue