27/02/2025 - 21h
parent
95b126d3e1
commit
2936a4e17a
|
@ -1,14 +1,19 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="11/02/2025 - 21h">
|
||||
<change afterPath="$PROJECT_DIR$/base_document_automatic_setup.py" afterDir="false" />
|
||||
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="18/02/2025 - 21h">
|
||||
<change afterPath="$PROJECT_DIR$/Job_Cron_Common.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/GlobalVariable.py" beforeDir="false" afterPath="$PROJECT_DIR$/GlobalVariable.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Inscription_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/Inscription_mgt.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Job_Cron.py" beforeDir="false" afterPath="$PROJECT_DIR$/Job_Cron.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$/base_partner_catalog_config.py" beforeDir="false" afterPath="$PROJECT_DIR$/base_partner_catalog_config.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Session_Formation.py" beforeDir="false" afterPath="$PROJECT_DIR$/Session_Formation.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$/module_editique.py" beforeDir="false" afterPath="$PROJECT_DIR$/module_editique.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/partners.py" beforeDir="false" afterPath="$PROJECT_DIR$/partners.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/prj_common.py" beforeDir="false" afterPath="$PROJECT_DIR$/prj_common.py" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
|
@ -79,13 +84,6 @@
|
|||
<option name="presentableId" value="Default" />
|
||||
<updated>1680804787304</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00390" summary="04/09/2024 - 23h">
|
||||
<created>1725482228553</created>
|
||||
<option name="number" value="00390" />
|
||||
<option name="presentableId" value="LOCAL-00390" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1725482228555</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00391" summary="qsh">
|
||||
<created>1725630280201</created>
|
||||
<option name="number" value="00391" />
|
||||
|
@ -422,7 +420,14 @@
|
|||
<option name="project" value="LOCAL" />
|
||||
<updated>1739302914543</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="439" />
|
||||
<task id="LOCAL-00439" summary="18/02/2025 - 21h">
|
||||
<created>1739911910803</created>
|
||||
<option name="number" value="00439" />
|
||||
<option name="presentableId" value="LOCAL-00439" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1739911910804</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="440" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="Vcs.Log.Tabs.Properties">
|
||||
|
@ -464,7 +469,6 @@
|
|||
</option>
|
||||
</component>
|
||||
<component name="VcsManagerConfiguration">
|
||||
<MESSAGE value="22/11/2024 - 18h" />
|
||||
<MESSAGE value="27/11/2024 : 12h30" />
|
||||
<MESSAGE value="08/12/2024 - 12h" />
|
||||
<MESSAGE value="10/12/2024 - 22h" />
|
||||
|
@ -489,6 +493,7 @@
|
|||
<MESSAGE value="10/02/205 - 21h" />
|
||||
<MESSAGE value="11/02/2025 - 15h30" />
|
||||
<MESSAGE value="11/02/2025 - 21h" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="11/02/2025 - 21h" />
|
||||
<MESSAGE value="18/02/2025 - 21h" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="18/02/2025 - 21h" />
|
||||
</component>
|
||||
</project>
|
|
@ -628,7 +628,8 @@ Pour mettre en place un système de configuration global, on va definir les vale
|
|||
PARTNER_BASE_CONFIG_NAME = ['tva', 'smtp_server', 'smtp_user', 'smtp_user_pwd', 'smtp_count_from_name',
|
||||
'smtp_count_port', 'partner_smtp', 'partner_jour_heure', 'nb_relance_auto',
|
||||
'relance_auto', 'frequence_relance_auto', 'session_warning', 'session_warning_lead_time',
|
||||
'recyclage_warning', 'recyclage_warning_lead_time']
|
||||
'recyclage_warning', 'recyclage_warning_lead_time',
|
||||
'preinscription_notification_email', 'inscription_notification_email']
|
||||
|
||||
|
||||
"""
|
||||
|
|
|
@ -611,19 +611,28 @@ def AddStagiairetoClass(diction):
|
|||
|
||||
## Envoie de l'email de preinscription
|
||||
mail_data = {}
|
||||
mail_data['token'] = diction['token']
|
||||
mail_data['email'] = diction['email']
|
||||
mail_data['class_internal_url'] = diction['class_internal_url']
|
||||
mail_data['session_id'] = diction['session_id']
|
||||
mail_data['inscription_id'] = ret_val['_id']
|
||||
|
||||
#print(" ### l'inscription est ok, il faut declencher l'envoi des email a "+str(mail_data))
|
||||
local_status, message = SendPre_InscriptionEmail(mail_data)
|
||||
if( local_status is False):
|
||||
mycommon.myprint(" WARNING : Impossible d'envoyer le mail de preinscriton à "+
|
||||
str(inspect.stack()[0][3]) + " - l'adresse email " + str(
|
||||
mydata['email']) + " pour la session " + str(mydata['session_id']) + " ")
|
||||
"""
|
||||
26/02/2025 :
|
||||
Si le paramettre, 'inscription_notification_email' de la collection 'base_partner_setup' est à 1,
|
||||
alors on envoie un email de notification à l'apprenant
|
||||
"""
|
||||
local_insc_status, local_insc_retval = mycommon.Is_Partnair_Prenscription_Notification(
|
||||
{'token': diction['token']})
|
||||
if (local_insc_status and local_insc_retval == "1"):
|
||||
local_status, message = SendPre_InscriptionEmail(mail_data)
|
||||
if( local_status is False):
|
||||
mycommon.myprint(" WARNING : Impossible d'envoyer le mail de preinscriton à "+
|
||||
str(inspect.stack()[0][3]) + " - l'adresse email " + str(
|
||||
mydata['email']) + " pour la session " + str(mydata['session_id']) + " ")
|
||||
|
||||
Warning_message = " WARNING : Impossible d'envoyer le mail de preinscriton à "+ str(inspect.stack()[0][3]) + " - l'adresse email " + str( mydata['email']) + " pour la session " + str(mydata['session_id']) + " "
|
||||
Warning_message = " WARNING : Impossible d'envoyer le mail de preinscriton à "+ str(inspect.stack()[0][3]) + " - l'adresse email " + str( mydata['email']) + " pour la session " + str(mydata['session_id']) + " "
|
||||
|
||||
|
||||
else:
|
||||
|
@ -1276,8 +1285,17 @@ def UpdateStagiairetoClass(diction):
|
|||
|
||||
# Il s'agit d'envoyer le message de confirmation d'une inscription
|
||||
email_data['partner_owner_recid'] = str(partner_recid)
|
||||
local_status, local_message = email_session.incription_training_confirmation_mail(email_data)
|
||||
message_for_historic = message_for_historic + " : Email Inscription "
|
||||
|
||||
"""
|
||||
26/02/2025 :
|
||||
Si le paramettre, 'inscription_notification_email' de la collection 'base_partner_setup' est à 1,
|
||||
alors on envoie un email de notification à l'apprenant
|
||||
"""
|
||||
local_insc_status, local_insc_retval = mycommon.Is_Partnair_Inscription_Notification(
|
||||
{'token': diction['token']})
|
||||
if (local_insc_status and local_insc_retval == "1"):
|
||||
local_status, local_message = email_session.incription_training_confirmation_mail(email_data)
|
||||
message_for_historic = message_for_historic + " : Email Inscription "
|
||||
|
||||
"""
|
||||
Update du 28/12/2023
|
||||
|
@ -1625,6 +1643,7 @@ def SendInscriptionConfirmation(diction):
|
|||
return False, " Impossible d'envoyer le mail de confirmation"
|
||||
|
||||
|
||||
|
||||
data_mail = {}
|
||||
# 1 - Recuperation des données de la formation
|
||||
local_class = MYSY_GV.dbname['myclass'].find({'internal_url':str(diction['class_internal_url'])})
|
||||
|
@ -1693,9 +1712,19 @@ def SendInscriptionConfirmation(diction):
|
|||
data_mail['code_session'] = code_session
|
||||
|
||||
data_mail['partner_owner_recid'] = str(partner_recid)
|
||||
local_status, local_message = email_session.incription_training_confirmation_mail(data_mail)
|
||||
|
||||
return local_status, "La confirmation d'inscription a bien ete envoyée"
|
||||
"""
|
||||
26/02/2025 :
|
||||
Si le paramettre, 'inscription_notification_email' de la collection 'base_partner_setup' est à 1,
|
||||
alors on envoie un email de notification à l'apprenant
|
||||
"""
|
||||
local_insc_status, local_insc_retval = mycommon.Is_Partnair_Inscription_Notification(
|
||||
{'token': diction['token']})
|
||||
if (local_insc_status and local_insc_retval == "1"):
|
||||
local_status, local_message = email_session.incription_training_confirmation_mail(data_mail)
|
||||
return local_status, "La confirmation d'inscription a bien ete envoyée"
|
||||
else:
|
||||
return True, "La notification par email des inscriptions n'est pas activée."
|
||||
|
||||
except Exception as e:
|
||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||
|
@ -1712,7 +1741,7 @@ def SendPre_InscriptionEmail(diction):
|
|||
Verification de la liste des champs obligatoires
|
||||
"""
|
||||
|
||||
field_list_obligatoire = [ 'email', 'session_id', 'inscription_id']
|
||||
field_list_obligatoire = [ 'email', 'session_id', 'inscription_id', 'token']
|
||||
for val in field_list_obligatoire:
|
||||
if val not in diction:
|
||||
mycommon.myprint(
|
||||
|
@ -1723,7 +1752,6 @@ def SendPre_InscriptionEmail(diction):
|
|||
data_mail = {}
|
||||
|
||||
|
||||
|
||||
# 2 - Recuperation des données de l'inscription
|
||||
local_session = MYSY_GV.dbname['inscription'].find({'session_id':str(diction['session_id']),
|
||||
'email':str(diction['email']),
|
||||
|
@ -1856,7 +1884,15 @@ def SendPre_InscriptionEmail(diction):
|
|||
#print(" Pre_incription_training_confirmation_mail DATA = ",data_mail )
|
||||
|
||||
# Envoi de l'email de confirmation au demandeur de la formation
|
||||
local_status, local_message = email_session.Pre_incription_training_confirmation_mail(data_mail)
|
||||
"""
|
||||
26/02/2025 :
|
||||
Si le paramettre, 'inscription_notification_email' de la collection 'base_partner_setup' est à 1,
|
||||
alors on envoie un email de notification à l'apprenant
|
||||
"""
|
||||
local_insc_status, local_insc_retval = mycommon.Is_Partnair_Prenscription_Notification(
|
||||
{'token': diction['token']})
|
||||
if (local_insc_status and local_insc_retval == "1"):
|
||||
local_status, local_message = email_session.Pre_incription_training_confirmation_mail(data_mail)
|
||||
|
||||
|
||||
# Envoi de l'email de notification au formateur
|
||||
|
@ -2507,7 +2543,7 @@ def AddStagiairetoClass_mass(file=None, Folder=None, diction=None):
|
|||
if (local_controle_status is False):
|
||||
return local_controle_status, local_controle_message
|
||||
|
||||
print(" #### local_controle_message = ", local_controle_message)
|
||||
#print(" #### local_controle_message = ", local_controle_message)
|
||||
|
||||
df = pd.read_csv(saved_file, encoding='utf8', on_bad_lines='skip', sep=';', encoding_errors='ignore', skipinitialspace=True)
|
||||
df = df.fillna('')
|
||||
|
@ -6409,78 +6445,85 @@ def AcceptAttendeeInscription(diction):
|
|||
Verification s'il y a une inscription LMS, au quel cas, on l'annule aussi
|
||||
"""
|
||||
|
||||
email_data = {}
|
||||
email_data['nom'] = nom
|
||||
email_data['prenom'] = prenom
|
||||
email_data['email'] = email
|
||||
email_data['date_du'] = date_du
|
||||
email_data['date_au'] = date_au
|
||||
email_data['title'] = class_title
|
||||
email_data['partner_owner_recid'] = str(partner_recid)
|
||||
"""
|
||||
26/02/2025 :
|
||||
Si le paramettre, 'inscription_notification_email' de la collection 'base_partner_setup' est à 1,
|
||||
alors on envoie un email de notification à l'apprenant
|
||||
"""
|
||||
local_insc_status, local_insc_retval = mycommon.Is_Partnair_Inscription_Notification({'token':diction['token']})
|
||||
if( local_insc_status and str(local_insc_retval) == "1"):
|
||||
email_data = {}
|
||||
email_data['nom'] = nom
|
||||
email_data['prenom'] = prenom
|
||||
email_data['email'] = email
|
||||
email_data['date_du'] = date_du
|
||||
email_data['date_au'] = date_au
|
||||
email_data['title'] = class_title
|
||||
email_data['partner_owner_recid'] = str(partner_recid)
|
||||
|
||||
if( "code_session" in local_session.keys()):
|
||||
email_data['code_session'] = local_session['code_session']
|
||||
else:
|
||||
email_data['code_session'] = ""
|
||||
if( "code_session" in local_session.keys()):
|
||||
email_data['code_session'] = local_session['code_session']
|
||||
else:
|
||||
email_data['code_session'] = ""
|
||||
|
||||
if ("date_debut" in local_session.keys()):
|
||||
email_data['date_debut'] = local_session['date_debut']
|
||||
else:
|
||||
email_data['date_debut'] = ""
|
||||
if ("date_debut" in local_session.keys()):
|
||||
email_data['date_debut'] = local_session['date_debut']
|
||||
else:
|
||||
email_data['date_debut'] = ""
|
||||
|
||||
if ("distantiel" in local_session.keys()):
|
||||
email_data['distantiel'] = local_session['distantiel']
|
||||
else:
|
||||
email_data['distantiel'] = ""
|
||||
if ("distantiel" in local_session.keys()):
|
||||
email_data['distantiel'] = local_session['distantiel']
|
||||
else:
|
||||
email_data['distantiel'] = ""
|
||||
|
||||
if ("presentiel" in local_session.keys()):
|
||||
email_data['presentiel'] = local_session['presentiel']
|
||||
else:
|
||||
email_data['presentiel'] = ""
|
||||
if ("presentiel" in local_session.keys()):
|
||||
email_data['presentiel'] = local_session['presentiel']
|
||||
else:
|
||||
email_data['presentiel'] = ""
|
||||
|
||||
if ("session_ondemande" in local_session.keys()):
|
||||
email_data['session_ondemande'] = local_session['session_ondemande']
|
||||
else:
|
||||
email_data['session_ondemande'] = ""
|
||||
if ("session_ondemande" in local_session.keys()):
|
||||
email_data['session_ondemande'] = local_session['session_ondemande']
|
||||
else:
|
||||
email_data['session_ondemande'] = ""
|
||||
|
||||
if ("adresse" in local_session.keys()):
|
||||
email_data['adresse'] = local_session['adresse']
|
||||
else:
|
||||
email_data['adresse'] = ""
|
||||
if ("adresse" in local_session.keys()):
|
||||
email_data['adresse'] = local_session['adresse']
|
||||
else:
|
||||
email_data['adresse'] = ""
|
||||
|
||||
if ("code_postal" in local_session.keys()):
|
||||
email_data['code_postal'] = local_session['code_postal']
|
||||
else:
|
||||
email_data['code_postal'] = ""
|
||||
if ("code_postal" in local_session.keys()):
|
||||
email_data['code_postal'] = local_session['code_postal']
|
||||
else:
|
||||
email_data['code_postal'] = ""
|
||||
|
||||
if ("ville" in local_session.keys()):
|
||||
email_data['ville'] = local_session['ville']
|
||||
else:
|
||||
email_data['ville'] = ""
|
||||
if ("ville" in local_session.keys()):
|
||||
email_data['ville'] = local_session['ville']
|
||||
else:
|
||||
email_data['ville'] = ""
|
||||
|
||||
if ("pays" in local_session.keys()):
|
||||
email_data['pays'] = local_session['pays']
|
||||
else:
|
||||
email_data['pays'] = ""
|
||||
if ("pays" in local_session.keys()):
|
||||
email_data['pays'] = local_session['pays']
|
||||
else:
|
||||
email_data['pays'] = ""
|
||||
|
||||
if ("formateur" in local_session.keys()):
|
||||
email_data['formateur'] = local_session['formateur']
|
||||
else:
|
||||
email_data['formateur'] = ""
|
||||
if ("formateur" in local_session.keys()):
|
||||
email_data['formateur'] = local_session['formateur']
|
||||
else:
|
||||
email_data['formateur'] = ""
|
||||
|
||||
if ("ville" in local_session.keys()):
|
||||
email_data['ville'] = local_session['ville']
|
||||
else:
|
||||
email_data['ville'] = ""
|
||||
if ("ville" in local_session.keys()):
|
||||
email_data['ville'] = local_session['ville']
|
||||
else:
|
||||
email_data['ville'] = ""
|
||||
|
||||
|
||||
local_status, local_message = email_session.incription_training_confirmation_mail(email_data)
|
||||
if( local_status is False ):
|
||||
mycommon.myprint(str(
|
||||
inspect.stack()[0][3]) + " - WARNING : Impossible d'envoyer le mail de notification pour " + str(
|
||||
diction['email']))
|
||||
return_message = return_message + str(" - Impossible d'envoyer le mail de notification pour : " + str(diction['email'])+" \n")
|
||||
is_warning_message = 1
|
||||
local_status, local_message = email_session.incription_training_confirmation_mail(email_data)
|
||||
if( local_status is False ):
|
||||
mycommon.myprint(str(
|
||||
inspect.stack()[0][3]) + " - WARNING : Impossible d'envoyer le mail de notification pour " + str(
|
||||
diction['email']))
|
||||
return_message = return_message + str(" - Impossible d'envoyer le mail de notification pour : " + str(diction['email'])+" \n")
|
||||
is_warning_message = 1
|
||||
|
||||
|
||||
|
||||
|
@ -10993,8 +11036,6 @@ def Sent_Convention_Stagiaire_By_Email_By_Partner_client(tab_files_name_full_pat
|
|||
if (is_signature_digital_count == 1):
|
||||
is_partner_digital_signature = "1"
|
||||
|
||||
|
||||
|
||||
# Verifier que la session est valide
|
||||
is_session_id_valide = MYSY_GV.dbname['session_formation'].count_documents(
|
||||
{'_id': ObjectId(str(diction['session_id'])),
|
||||
|
|
369
Job_Cron.py
369
Job_Cron.py
|
@ -13,8 +13,7 @@ from bson import ObjectId
|
|||
import re
|
||||
from datetime import datetime, date, timedelta
|
||||
|
||||
|
||||
|
||||
import Session_Formation
|
||||
import module_editique
|
||||
import partner_base_setup
|
||||
import partner_client
|
||||
|
@ -43,7 +42,7 @@ from email.mime.text import MIMEText
|
|||
from email.mime.base import MIMEBase
|
||||
from email import encoders
|
||||
import survey_mgt as survey_mgt
|
||||
|
||||
import Job_Cron_Common as Job_Cron_Common
|
||||
|
||||
"""
|
||||
Ce job permet d'envoyer les demandes d'enquetes comme les
|
||||
|
@ -1130,7 +1129,8 @@ Dans cette collection
|
|||
Alogorithme :
|
||||
|
||||
|
||||
1 - On va aller directement dans le collection 'session_formation' recuperer toutes les session ayant : {'automatic_traitement.actif':'1'}
|
||||
1 - On va aller directement dans le collection 'session_formation' recuperer toutes les session ayant : {'automatic_traitement.actif':'1',
|
||||
automatic_traitement.statut != '2' (statut 2 = Done) }
|
||||
|
||||
2 - Pour chacune des line retournées, on va faire le calcul manuellement (on pas un nombre gigantesque de session, ca peut donc passer pendant
|
||||
qqtps, deplus ce sont des traitement noctures, donc ca devrait aller.
|
||||
|
@ -1138,8 +1138,367 @@ qqtps, deplus ce sont des traitement noctures, donc ca devrait aller.
|
|||
- si start_date session = Date Today + nb_jour_action, alors il faut lancer l'edition des documents.
|
||||
A la fin, ne surtout pas oublié de mettre à jour la ligne "session_formation.automatic_traitement" avec les info :
|
||||
- actif = -1
|
||||
- statut = 2 (done)
|
||||
- date_traitement = date du jour
|
||||
- statut traitement :
|
||||
- commentaire : combien de document envoyé.
|
||||
|
||||
"""
|
||||
"""
|
||||
|
||||
def Cron_Daily_Document_Sending():
|
||||
try:
|
||||
print(" Cron : In function = Cron_Daily_Document_Sending")
|
||||
|
||||
|
||||
todays_date = str(date.today().strftime("%d/%m/%Y"))
|
||||
todays_date_ISODATE = datetime.strptime(str(todays_date), '%d/%m/%Y')
|
||||
|
||||
qry_list_session_concerned = {}
|
||||
qry_list_session_concerned['valide'] = "1"
|
||||
qry_list_session_concerned['automatic_traitement.actif'] = "1"
|
||||
qry_list_session_concerned['automatic_traitement.valide'] = "1"
|
||||
qry_list_session_concerned['automatic_traitement.statut'] = {"$ne": "2"}
|
||||
|
||||
|
||||
print(" ### qry_list_session_concerned = ", qry_list_session_concerned)
|
||||
|
||||
for my_session in MYSY_GV.dbname['session_formation'].find(qry_list_session_concerned):
|
||||
#print(" ## Session à traiter = ", my_session)
|
||||
|
||||
print(" # Date Start Session = ", my_session['date_debut'])
|
||||
print(" # Date End Session = ", my_session['date_fin'])
|
||||
#print(" # automatic_traitement = ", my_session['automatic_traitement'])
|
||||
|
||||
for data_automatic_traitement in my_session['automatic_traitement'] :
|
||||
|
||||
print(" # Nb jour action = ", data_automatic_traitement['nb_jour_action'])
|
||||
print(" # Date du jour = ", str(todays_date))
|
||||
|
||||
local_status, nb_jour_action_Int = mycommon.IsInt(str(data_automatic_traitement['nb_jour_action']).strip())
|
||||
if (local_status is False):
|
||||
mycommon.myprint(str(
|
||||
inspect.stack()[0][
|
||||
3]) + " CRON WARNING : nb_jour_action_Int n'est pas une valeur entière. Session Formation = ", str(my_session['_id']))
|
||||
# On log une erreur, et on continue le traitement dans la boucle.
|
||||
continue
|
||||
|
||||
local_session_start_date = datetime.strptime(str(my_session['date_debut']).strip(), '%d/%m/%Y')
|
||||
local_session_start_date_added_nb_jour_action = local_session_start_date + timedelta(days=nb_jour_action_Int)
|
||||
local_session_start_date_added_nb_jour_action_formated = str(local_session_start_date_added_nb_jour_action.strftime("%d/%m/%Y"))
|
||||
|
||||
print(" ### CMP 1 local_session_start_date_added_nb_jour_action = ", local_session_start_date_added_nb_jour_action)
|
||||
print(" ### CMP 2 datetime.strptime(str(todays_date).strip(), '%d/%m/%Y') = ",
|
||||
datetime.strptime(str(todays_date).strip(), '%d/%m/%Y'))
|
||||
|
||||
print(" ### delta day = ", datetime.strptime(str(todays_date).strip(), '%d/%m/%Y') - local_session_start_date )
|
||||
|
||||
if (local_session_start_date_added_nb_jour_action > datetime.strptime(str(todays_date).strip(), '%d/%m/%Y')):
|
||||
print(" ### SUPPPPPP : Action à faire dans le futur ")
|
||||
|
||||
elif (local_session_start_date_added_nb_jour_action < datetime.strptime(str(todays_date).strip(), '%d/%m/%Y')):
|
||||
print(" ### INFFFFFF : Alert il y a un pb sur une action non realiser ")
|
||||
mycommon.myprint(str(
|
||||
inspect.stack()[0][
|
||||
3]) + " CRON WARNING * Cron_Daily_Document_Sending: Il a un CRON qui ne n'est pas exécuté à la date prévue."
|
||||
" Session Formation = " + str(
|
||||
my_session['_id']) + " Id du CRON courrier_template_type_document_id = " + str(
|
||||
data_automatic_traitement['courrier_template_type_document_id']))
|
||||
|
||||
|
||||
elif (local_session_start_date_added_nb_jour_action == datetime.strptime(str(todays_date).strip(), '%d/%m/%Y')):
|
||||
|
||||
"""
|
||||
Effectuer l'action
|
||||
"""
|
||||
"""
|
||||
Recuperer le type de document concerné
|
||||
"""
|
||||
courrier_template_type_document_data = MYSY_GV.dbname['courrier_template_type_document'].find_one(
|
||||
{'_id':ObjectId(data_automatic_traitement['courrier_template_type_document_id']),
|
||||
'valide':'1',
|
||||
'locked':'0'})
|
||||
|
||||
if( courrier_template_type_document_data and 'ref_interne' in courrier_template_type_document_data.keys() ):
|
||||
print(" ### Action à faire : Envoyer le document de type ", courrier_template_type_document_data['ref_interne'])
|
||||
else:
|
||||
mycommon.myprint(str(
|
||||
inspect.stack()[0][
|
||||
3]) + " CRON WARNING * Cron_Daily_Document_Sending: Impossible de trouver le type de document concerné "
|
||||
" Session Formation = " + str(
|
||||
my_session['_id']) + " Id du CRON courrier_template_type_document_id = " + str(
|
||||
data_automatic_traitement['courrier_template_type_document_id']))
|
||||
|
||||
continue
|
||||
|
||||
print(" ### avant action 1 courrier_template_type_document_data = ", courrier_template_type_document_data)
|
||||
print(" ## data_automatic_traitement = ", data_automatic_traitement)
|
||||
|
||||
local_diction = {}
|
||||
local_diction['session_id'] = str(my_session['_id'])
|
||||
local_diction['document_ref_intern'] = str(courrier_template_type_document_data['ref_interne'])
|
||||
local_diction['partner_owner_recid'] = str(my_session['partner_owner_recid'])
|
||||
local_diction['courrier_template_type_document_ref_interne'] = str(data_automatic_traitement['courrier_template_type_document_ref_interne'])
|
||||
local_diction['courrier_template_type_document_id'] = str( data_automatic_traitement['courrier_template_type_document_id'])
|
||||
|
||||
print( " ### local_diction for Send_document_from_base_document_automatic_setup = ", local_diction)
|
||||
local_status, local_retval = Send_document_from_base_document_automatic_setup(local_diction)
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Mettre à jour le document
|
||||
"" "
|
||||
|
||||
local_update = MYSY_GV.dbname['session_formation'].update_many(
|
||||
{'_id': ObjectId(str(my_session['_id'])),
|
||||
'partner_owner_recid':str(my_session['partner_owner_recid']),
|
||||
'valide': '1',
|
||||
'automatic_traitement.courrier_template_type_document_id': str(data_automatic_traitement['courrier_template_type_document_id'])
|
||||
},
|
||||
{'$set':
|
||||
{
|
||||
'automatic_traitement.$[xxx].actif': "-1",
|
||||
'automatic_traitement.$[xxx].statut': "2",
|
||||
'automatic_traitement.$[xxx].date_traitement_cron': str(datetime.now()),
|
||||
'automatic_traitement.$[xxx].date_update': str(datetime.now()),
|
||||
'automatic_traitement.$[xxx].update_by': "Automatic Cron",
|
||||
}
|
||||
},
|
||||
upsert=False,
|
||||
array_filters=[
|
||||
{"xxx.courrier_template_type_document_id": str(data_automatic_traitement['courrier_template_type_document_id'])}
|
||||
]
|
||||
|
||||
)
|
||||
if( local_update.matched_count < 1 ):
|
||||
print(" #### local_update.matched_count = ", local_update.matched_count)
|
||||
mycommon.myprint(str(
|
||||
inspect.stack()[0][
|
||||
3]) + " CRON WARNING * Cron_Daily_Document_Sending: La mise à jour du statut (actif = -1) du cron ne s'est "
|
||||
" PAS bien passé : Session Formation = "+ str(my_session['_id'])+
|
||||
" Id du CRON courrier_template_type_document_id = "+
|
||||
str(data_automatic_traitement['courrier_template_type_document_id']))
|
||||
"""
|
||||
return True, ""
|
||||
|
||||
|
||||
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, str(inspect.stack()[0][3]) + " -" + str(e) + " - Line : " + str(exc_tb.tb_lineno)
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Cette fonction prend en argument :
|
||||
- L'_id de la session de formation
|
||||
- Le type de document (ref_interne)
|
||||
- Le partner_owner_recid (ceci pour aller choisir les documents qu'il a configurés)
|
||||
|
||||
puis procede à l'envoie des document
|
||||
"""
|
||||
def Send_document_from_base_document_automatic_setup(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = [ 'session_id', 'document_ref_intern','partner_owner_recid',
|
||||
'courrier_template_type_document_ref_interne', 'courrier_template_type_document_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 = [ 'session_id', 'document_ref_intern', 'partner_owner_recid']
|
||||
|
||||
for val in field_list_obligatoire:
|
||||
if val not in diction:
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " - La valeur '" + val + "' n'est pas presente dans liste ")
|
||||
return False, " Les informations fournies sont incorrectes"
|
||||
|
||||
|
||||
"""
|
||||
On va aller recuperer le courrier configuré par default
|
||||
"""
|
||||
|
||||
local_status, my_partner = mycommon.Get_Connected_User_Partner_Data_From_RecID(
|
||||
str(diction['partner_owner_recid']))
|
||||
if (local_status is not True):
|
||||
return local_status, my_partner
|
||||
|
||||
|
||||
print(" ### diction['document_ref_intern'] = ", diction['document_ref_intern'])
|
||||
|
||||
if( str(diction['document_ref_intern']) == 'CONVENTION_STAGIAIRE_ENTREPRISE' or str(diction['document_ref_intern']) == 'CONVENTION_STAGIAIRE_INDIVIDUELLE' ):
|
||||
|
||||
local_diction = {}
|
||||
local_diction['token'] = my_partner['token']
|
||||
local_diction['session_id'] = diction['session_id']
|
||||
local_diction['courrier_template_id'] = ""
|
||||
|
||||
print(" ### local_diction for Prepare_and_Send_Default_Convention_From_Session_By_PDF= ", local_diction)
|
||||
|
||||
#local_status, local_retval = Session_Formation.Prepare_and_Send_Default_Convention_From_Session_By_PDF(local_diction)
|
||||
|
||||
local_diction_by_email = {}
|
||||
local_diction_by_email['token'] = my_partner['token']
|
||||
local_diction_by_email['session_id'] = diction['session_id']
|
||||
local_diction_by_email['courrier_template_id'] = ""
|
||||
local_diction_by_email['email_test'] = ""
|
||||
local_diction_by_email['email_production'] = ""
|
||||
local_diction_by_email['request_digital_signature'] = "1"
|
||||
|
||||
|
||||
tab_files = []
|
||||
Folder = ""
|
||||
#local_status, local_retval = Session_Formation.Prepare_and_Send_Default_Convention_From_Session_By_Email(tab_files,
|
||||
# Folder, local_diction_by_email)
|
||||
|
||||
elif ( str(diction['document_ref_intern']) == 'CONVOCATION_STAGIAIRE' ):
|
||||
print(" ### Envoyer les convocations aux participants ")
|
||||
local_diction_convocation_by_email = {}
|
||||
local_diction_convocation_by_email = diction
|
||||
local_diction_convocation_by_email['token'] = my_partner['token']
|
||||
|
||||
|
||||
local_convoc_status, local_convoc_retval = Cron_Session_Convocation_Sending(local_diction_convocation_by_email)
|
||||
|
||||
|
||||
|
||||
elif ( str(diction['document_ref_intern']) == 'QUESTION_POSITIONNEMENT' ):
|
||||
print(" ### Initialiser le questionnaire de positionnement ")
|
||||
print(" ### Envoyer le questionnaire de positionnement ")
|
||||
|
||||
elif ( str(diction['document_ref_intern']) == 'ATTESTATION_FORMATION' ):
|
||||
print(" ### Initialiser les attestations de formation ")
|
||||
print(" ### Envoyer les attestations de formation ")
|
||||
|
||||
|
||||
return True, "OK Documents "
|
||||
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 automatiquement les documents "
|
||||
|
||||
|
||||
"""
|
||||
Cette fonction permet d'envoyer les convocation par defaut avec les cron
|
||||
Algo :
|
||||
1 - Recuperer le modele de document par defaut pour les convocations
|
||||
2 - Envoyer les convocations
|
||||
"""
|
||||
def Cron_Session_Convocation_Sending(diction):
|
||||
try:
|
||||
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = [ 'token', 'session_id', 'document_ref_intern','partner_owner_recid',
|
||||
'courrier_template_type_document_ref_interne', 'courrier_template_type_document_id']
|
||||
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
if val not in field_list and val.startswith('my_') is False:
|
||||
mycommon.myprint(str(
|
||||
inspect.stack()[0][3]) + " Le champ '" + val + "' n'est pas autorisé")
|
||||
return False, " Les informations fournies sont incorrectes"
|
||||
|
||||
"""
|
||||
Verification des champs obligatoires
|
||||
"""
|
||||
field_list_obligatoire = [ 'token', 'session_id', 'document_ref_intern','partner_owner_recid',
|
||||
'courrier_template_type_document_ref_interne', 'courrier_template_type_document_id']
|
||||
|
||||
for val in field_list_obligatoire:
|
||||
if val not in diction:
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " - La valeur '" + val + "' n'est pas presente dans liste ")
|
||||
return False, " Les informations fournies sont incorrectes"
|
||||
|
||||
local_status, my_partner = mycommon.Check_Connexion_And_Return_Partner_Data({'token': str(diction['token'])})
|
||||
if (local_status is not True):
|
||||
return local_status, my_partner
|
||||
|
||||
|
||||
local_diction = {}
|
||||
local_diction['ref_interne'] = "CONVOCATION_STAGIAIRE"
|
||||
local_diction['type_doc'] = "email"
|
||||
local_diction['partner_owner_recid'] = str(diction['partner_owner_recid'])
|
||||
local_diction['default'] = "1"
|
||||
|
||||
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 'CONVOCATION_STAGIAIRE', (type : Email) ")
|
||||
return False, " Impossible de récuperer le modèle de courrier 'CONVOCATION_STAGIAIRE', (type : Email) "
|
||||
|
||||
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 'CONVOCATION_STAGIAIRE', (type : Email) n'est pas correctement configuré ")
|
||||
return False, " Le modèle de courrier 'CONVOCATION_STAGIAIRE', (type : Email) n'est pas correctement configuré"
|
||||
|
||||
|
||||
print(" ### On a trouver un modele de convocation (type EMAIL) par defaut OKK")
|
||||
|
||||
local_diction_convocation_by_email = {}
|
||||
local_diction_convocation_by_email['token'] = my_partner['token']
|
||||
local_diction_convocation_by_email['session_id'] = diction['session_id']
|
||||
local_diction_convocation_by_email['courrier_template_id'] = str(courrier_data_retval['_id'])
|
||||
local_diction_convocation_by_email['email_test'] = ""
|
||||
local_diction_convocation_by_email['email_production'] = ""
|
||||
|
||||
|
||||
tab_files = []
|
||||
Folder = ""
|
||||
#local_status, local_retval = Job_Cron_Common.Prepare_and_Send_Convocation_From_Session_By_Email(tab_files,
|
||||
# Folder, local_diction_convocation_by_email)
|
||||
|
||||
|
||||
"""
|
||||
Aller chercher le modele de courrier de type PDF
|
||||
"""
|
||||
|
||||
local_diction = {}
|
||||
local_diction['ref_interne'] = "CONVOCATION_STAGIAIRE"
|
||||
local_diction['type_doc'] = "pdf"
|
||||
local_diction['partner_owner_recid'] = str(diction['partner_owner_recid'])
|
||||
local_diction['default'] = "1"
|
||||
|
||||
courrier_data_status, courrier_data_retval_pdf = 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 'CONVOCATION_STAGIAIRE', (type : PDF) ")
|
||||
return False, " Impossible de récuperer le modèle de courrier 'CONVOCATION_STAGIAIRE', (type : PDF) "
|
||||
|
||||
if ("contenu_doc" not in courrier_data_retval_pdf.keys() or str(courrier_data_retval_pdf['contenu_doc']) == ""):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " Le modèle de courrier 'CONVOCATION_STAGIAIRE', (type : PDF) n'est pas correctement configuré ")
|
||||
return False, " Le modèle de courrier 'CONVOCATION_STAGIAIRE', (type : PDF) n'est pas correctement configuré"
|
||||
|
||||
print(" ### On a trouver un modele de convocation (Type : PDF) par defaut OKK")
|
||||
|
||||
|
||||
local_diction_convocation_by_PDF = {}
|
||||
local_diction_convocation_by_PDF['token'] = my_partner['token']
|
||||
local_diction_convocation_by_PDF['session_id'] = diction['session_id']
|
||||
local_diction_convocation_by_PDF['courrier_template_id'] = str(courrier_data_retval_pdf['_id'])
|
||||
local_status, local_retval = Job_Cron_Common.Prepare_and_Send_Convocation_From_Session_By_PDF(local_diction_convocation_by_PDF)
|
||||
|
||||
return True, "Les convocations ont été envoyées (CRON) "
|
||||
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 convocations (CRON) "
|
File diff suppressed because it is too large
Load Diff
11704
Log/log_file.log
11704
Log/log_file.log
File diff suppressed because one or more lines are too long
|
@ -107,7 +107,6 @@ def Add_Update_SessionFormation(diction):
|
|||
session_id = diction['session_id']
|
||||
|
||||
|
||||
|
||||
code_session = ""
|
||||
if ("code_session" in diction.keys()):
|
||||
mydata['code_session'] = diction['code_session']
|
||||
|
@ -521,6 +520,25 @@ def Add_Update_SessionFormation(diction):
|
|||
if (len(str(session_id)) <= 0):
|
||||
# La session n'existe pas, on fait une simple creation
|
||||
|
||||
mydata['date_created'] = str(datetime.now())
|
||||
|
||||
"""
|
||||
21/02/2025
|
||||
Il faut aller chercher la configuration des envois automatic de document.
|
||||
Il faut regarder dans la collection - base_document_automatic_setup -
|
||||
|
||||
"""
|
||||
mydata['automatic_traitement'] = []
|
||||
|
||||
qry_automatic_setup = {'collection_target':'session_formation',
|
||||
'valide':'1',
|
||||
'locked':'0',
|
||||
"actif": "1",
|
||||
'partner_owner_recid':str(my_partner['recid'])}
|
||||
|
||||
for base_document_automatic_setup_for_partner in MYSY_GV.dbname['base_document_automatic_setup'].find(qry_automatic_setup):
|
||||
mydata['automatic_traitement'].append(base_document_automatic_setup_for_partner)
|
||||
|
||||
#print(" ### mydata = ", mydata)
|
||||
coll_name = MYSY_GV.dbname['session_formation']
|
||||
ret_val = coll_name.insert_one(mydata)
|
||||
|
@ -783,6 +801,8 @@ def GetSessionFormation(diction):
|
|||
class_external_code = ""
|
||||
class_ispublished = "0"
|
||||
class_lms_class_code = ""
|
||||
if ("automatic_traitement" not in user.keys() ):
|
||||
user['automatic_traitement'] = []
|
||||
|
||||
if ('myclass' in retval.keys() and len(retval['myclass']) > 0):
|
||||
|
||||
|
@ -5311,7 +5331,7 @@ def Prepare_and_Send_Default_Convention_From_Session_By_Email(tab_files, Folder,
|
|||
if( default_courrier_template_client_count <= 0 ):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " Aucune convention d'entreprise n'est configurée ")
|
||||
3]) + " Aucune convention d'entreprise n'est configurée - 1 ")
|
||||
return False, " Aucune convention d'entreprise n'est configurée "
|
||||
|
||||
if (default_courrier_template_client_count > 1):
|
||||
|
@ -5641,7 +5661,7 @@ def Prepare_and_Send_Convention_From_Session_By_PDF(diction):
|
|||
local_diction['courrier_template_id'] = diction['courrier_template_id']
|
||||
local_diction['client_id'] = str(val)
|
||||
|
||||
|
||||
print(" ### UUU 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
|
||||
|
@ -5833,7 +5853,7 @@ def Prepare_and_Send_Convention_From_Session_For_Selected_Inscrit_By_PDF(diction
|
|||
local_diction['courrier_template_id'] = diction['courrier_template_id']
|
||||
local_diction['client_id'] = str(val)
|
||||
|
||||
|
||||
print(" ## ZZZ1 client_id PRRRR = ", 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
|
||||
|
@ -5841,8 +5861,6 @@ def Prepare_and_Send_Convention_From_Session_For_Selected_Inscrit_By_PDF(diction
|
|||
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']),
|
||||
|
@ -5979,7 +5997,7 @@ def Prepare_and_Send_Default_Convention_From_Session_By_PDF(diction):
|
|||
if (default_courrier_template_client_count <= 0):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " Aucune convention d'entreprise n'est configurée ")
|
||||
3]) + " Aucune convention d'entreprise n'est configurée - 2")
|
||||
return False, " Aucune convention d'entreprise n'est configurée "
|
||||
|
||||
if (default_courrier_template_client_count > 1):
|
||||
|
@ -6293,7 +6311,7 @@ def Create_Convention_By_Client_PDF(diction):
|
|||
for val in inscription_data:
|
||||
tab_participant.append(val['_id'])
|
||||
|
||||
print(" ### tab_participant = ", tab_participant)
|
||||
#print(" ### tab_participant 1 = ", tab_participant)
|
||||
# Creation du dictionnaire d'information à utiliser pour la creation du doc
|
||||
convention_dictionnary_data = {}
|
||||
new_diction = {}
|
||||
|
@ -6318,6 +6336,8 @@ def Create_Convention_By_Client_PDF(diction):
|
|||
Creation du ficier PDF
|
||||
"""
|
||||
|
||||
#print(" ### body = ", body)
|
||||
|
||||
contenu_doc_Template = jinja2.Template(str(template_courrier_data['contenu_doc']))
|
||||
|
||||
sourceHtml = contenu_doc_Template.render(params=body["params"])
|
||||
|
@ -6619,7 +6639,7 @@ def Prepare_and_Send_Convocation_From_Session_By_PDF(diction):
|
|||
local_diction['courrier_template_id'] = diction['courrier_template_id']
|
||||
local_diction['inscription_id'] = str(val['_id'])
|
||||
|
||||
print(" #### Traitemnt de local_diction bb = ", local_diction)
|
||||
#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
|
||||
|
@ -6740,7 +6760,7 @@ def Prepare_and_Send_Convocation_From_Session_For_Selected_Inscrit_By_PDF(dictio
|
|||
local_diction['courrier_template_id'] = diction['courrier_template_id']
|
||||
local_diction['inscription_id'] = str(val['_id'])
|
||||
|
||||
print(" #### Traitemnt de local_diction bb = ", local_diction)
|
||||
#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
|
||||
|
@ -6809,7 +6829,7 @@ def Create_Convocation_By_Stagiaire_PDF(diction):
|
|||
'ref_interne': 'CONVOCATION_STAGIAIRE',
|
||||
'partner_owner_recid':str(my_partner['recid'])}
|
||||
|
||||
print(" ##### qry = ", qry)
|
||||
#print(" ##### qry = ", qry)
|
||||
|
||||
# 1 - Verifier que le modele de courrier est bien editable par individu
|
||||
template_courrier_data = MYSY_GV.dbname['courrier_template'].find_one({'_id':ObjectId(str(diction['courrier_template_id'])),
|
||||
|
@ -7005,7 +7025,7 @@ def Prepare_and_Send_Convocation_From_Session_By_Email(tab_files, Folder, dictio
|
|||
)
|
||||
|
||||
|
||||
print(" ### la liste des liste_participants = ", liste_participants)
|
||||
#print(" ### la liste des liste_participants = ", liste_participants)
|
||||
|
||||
|
||||
# Sauvegarde des fichiers joints depuis le front
|
||||
|
@ -7018,7 +7038,7 @@ def Prepare_and_Send_Convocation_From_Session_By_Email(tab_files, Folder, dictio
|
|||
|
||||
tab_saved_file_full_path.append(saved_file_full_path)
|
||||
|
||||
print(" #### tab_saved_file_full_path = ", tab_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"
|
||||
|
@ -7040,11 +7060,11 @@ def Prepare_and_Send_Convocation_From_Session_By_Email(tab_files, Folder, dictio
|
|||
}
|
||||
)
|
||||
|
||||
print(" ### LIST liste_inscription: ", liste_inscription)
|
||||
#print(" ### LIST liste_inscription: ", liste_inscription)
|
||||
|
||||
|
||||
for single_inscrit in liste_inscription :
|
||||
print(" ### convocation traitement de l'inscrit : ",single_inscrit )
|
||||
#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'])
|
||||
|
@ -7055,7 +7075,7 @@ def Prepare_and_Send_Convocation_From_Session_By_Email(tab_files, Folder, dictio
|
|||
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)
|
||||
#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):
|
||||
|
@ -7144,7 +7164,7 @@ def Prepare_and_Send_Convocation_From_Session_For_Selected_Inscrit_By_Email(tab_
|
|||
)
|
||||
|
||||
|
||||
print(" ### la liste des liste_participants = ", liste_participants)
|
||||
#print(" ### la liste des liste_participants = ", liste_participants)
|
||||
|
||||
|
||||
# Sauvegarde des fichiers joints depuis le front
|
||||
|
@ -7157,7 +7177,7 @@ def Prepare_and_Send_Convocation_From_Session_For_Selected_Inscrit_By_Email(tab_
|
|||
|
||||
tab_saved_file_full_path.append(saved_file_full_path)
|
||||
|
||||
print(" #### tab_saved_file_full_path = ", tab_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"
|
||||
|
@ -7180,11 +7200,11 @@ def Prepare_and_Send_Convocation_From_Session_For_Selected_Inscrit_By_Email(tab_
|
|||
}
|
||||
)
|
||||
|
||||
print(" ### LIST liste_inscription: ", liste_inscription)
|
||||
#print(" ### LIST liste_inscription: ", liste_inscription)
|
||||
|
||||
|
||||
for single_inscrit in liste_inscription :
|
||||
print(" ### convocation traitement de l'inscrit : ",single_inscrit )
|
||||
#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'])
|
||||
|
@ -7195,7 +7215,7 @@ def Prepare_and_Send_Convocation_From_Session_For_Selected_Inscrit_By_Email(tab_
|
|||
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)
|
||||
#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):
|
||||
|
@ -7411,11 +7431,11 @@ def Sent_Convocation_Stagiaire_By_Email(tab_files, Folder, diction):
|
|||
stagiaire_client_id = str(inscription_data['client_rattachement_id'])
|
||||
local_diction = {"token":str(diction['token']), "_id":stagiaire_client_id }
|
||||
|
||||
print(" ##### local_diction pr Get_Partner_Client_Communication_Contact= ", local_diction)
|
||||
#print(" ##### local_diction pr Get_Partner_Client_Communication_Contact= ", local_diction)
|
||||
local_status, partner_client_contact_communication = partner_client.Get_Partner_Client_Communication_Contact(local_diction)
|
||||
|
||||
if (local_status is True):
|
||||
print(" ### partner_client_contact_communication = ", partner_client_contact_communication)
|
||||
#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)
|
||||
|
@ -7780,7 +7800,7 @@ def Prepare_and_Send_Attestation_From_Session_By_Email(tab_files, Folder, dictio
|
|||
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)
|
||||
#print(" ##### new_diction_no_client = ", new_diction_no_client)
|
||||
tab_saved_file_full_path = []
|
||||
local_status, local_retval = Sent_Attestation_Stagiaire_By_Email(tab_saved_file_full_path, Folder, new_diction_no_client)
|
||||
|
||||
|
@ -9176,7 +9196,7 @@ def Invoice_Partner_From_Session( diction):
|
|||
tab_apprenant.append(ObjectId(str(val['apprenant_id'])))
|
||||
|
||||
|
||||
print(" ### tab_participant = ", tab_participant)
|
||||
print(" ### tab_participant 2 = ", tab_participant)
|
||||
|
||||
# Recuperations des info de la session de formation
|
||||
session_data = MYSY_GV.dbname['session_formation'].find_one({'_id': ObjectId(str(diction['session_id']))})
|
||||
|
@ -9673,7 +9693,7 @@ def Sent_Facture_Stagiaire_By_Email_By_Partner_client(tab_files_name_full_path,
|
|||
tab_apprenant.append(ObjectId(str(val['apprenant_id'])))
|
||||
|
||||
|
||||
print(" ### tab_participant = ", tab_participant)
|
||||
print(" ### tab_participant 3 = ", tab_participant)
|
||||
|
||||
# Recuperations des info de la session de formation
|
||||
session_data = MYSY_GV.dbname['session_formation'].find_one({'_id': ObjectId(str(diction['session_id']))})
|
||||
|
@ -13931,3 +13951,230 @@ def Add_SessionFormation_From_Quotation_Line(diction):
|
|||
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 créer la session de formation"
|
||||
|
||||
|
||||
"""
|
||||
Cette fonction permet de mettre à jour le paramettrage
|
||||
d'envoie automatique des documents d'une session de formation.
|
||||
Par exemple :
|
||||
- Envoyer les convention X avant le début de la session de formation
|
||||
"""
|
||||
def Update_SessionFormation_Doc_Automatic_Setup(diction):
|
||||
try:
|
||||
|
||||
'''
|
||||
# Verification que les champs reçus dans l'API sont bien dans la liste des champs autorisés
|
||||
# Cela evite le cas ou une entité tierce ajouter les valeurs inconnu dans l'API
|
||||
# Ici on doit mettre tous les champs possible (obligatoire ou non) de la BDD dans la liste
|
||||
# field_list.
|
||||
'''
|
||||
field_list = ['token', '_id', 'nb_jour_action', 'actif', 'courrier_template_type_document_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, " Toutes les informations fournies ne sont pas valables"
|
||||
|
||||
"""
|
||||
Verification de la liste des champs obligatoires
|
||||
"""
|
||||
field_list_obligatoire = ['token', '_id', 'nb_jour_action', 'actif', 'courrier_template_type_document_id']
|
||||
|
||||
for val in field_list_obligatoire:
|
||||
if val not in diction:
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " - : La valeur '" + val + "' n'est pas presente dans liste ")
|
||||
return False, "Toutes les informations necessaires n'ont pas été fournies"
|
||||
|
||||
mydata = {}
|
||||
query_key = {}
|
||||
|
||||
my_token = ""
|
||||
if ("token" in diction.keys()):
|
||||
if diction['token']:
|
||||
my_token = diction['token']
|
||||
|
||||
nb_jour_action = diction['nb_jour_action']
|
||||
local_status, local_retval = mycommon.IsInt(str(nb_jour_action))
|
||||
if (local_status is False):
|
||||
mycommon.myprint(str(
|
||||
inspect.stack()[0][
|
||||
3]) + " Le nombre de jours est invalide ")
|
||||
return False, " Le nombre de jours est invalide "
|
||||
|
||||
actif = diction['actif']
|
||||
if (actif not in ['0', '1']):
|
||||
mycommon.myprint(str(
|
||||
inspect.stack()[0][
|
||||
3]) + " Le status (actif/inactif) est invalide ")
|
||||
return False, " Le status (actif/inactif) est invalide "
|
||||
|
||||
data_for_check_connexion = {'token': my_token}
|
||||
local_status, my_partner = mycommon.Check_Connexion_And_Return_Partner_Data(data_for_check_connexion)
|
||||
if (local_status is not True):
|
||||
return local_status, my_partner
|
||||
|
||||
|
||||
"""
|
||||
Verifier la valididé de la session de formation
|
||||
"""
|
||||
is_valide_session = MYSY_GV.dbname['session_formation'].count_documents({'_id':ObjectId(str(diction['_id'])),
|
||||
'valide':'1', 'partner_owner_recid':str(my_partner['recid'])})
|
||||
|
||||
if( is_valide_session != 1 ):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " - L'identifiant de la session de formation est invalide ")
|
||||
return False, "L'identifiant de la session de formation est invalide"
|
||||
|
||||
|
||||
is_valide_session_data = MYSY_GV.dbname['session_formation'].find_one({'_id': ObjectId(str(diction['_id'])),
|
||||
'valide': '1',
|
||||
'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 ")
|
||||
return False, "Cette session est partiellement facturée. Modification impossible"
|
||||
|
||||
if ("invoiced_statut" in is_valide_session_data.keys() and is_valide_session_data['invoiced_statut'] == '2'):
|
||||
mycommon.myprint(
|
||||
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_id'
|
||||
"""
|
||||
|
||||
is_courrier_template_type_document_id_valide = MYSY_GV.dbname['courrier_template_type_document'].count_documents(
|
||||
{'_id':ObjectId(str(diction['courrier_template_type_document_id'])),
|
||||
'valide':'1',
|
||||
'locked':'0'})
|
||||
|
||||
if( is_courrier_template_type_document_id_valide != 1):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " Le type de modèle de courrier est invalide ")
|
||||
return False, " Le type de modèle de courrier est invalide "
|
||||
|
||||
is_courrier_template_type_document_data = MYSY_GV.dbname[
|
||||
'courrier_template_type_document'].find_one(
|
||||
{'_id': ObjectId(str(diction['courrier_template_type_document_id'])),
|
||||
'valide': '1',
|
||||
'locked': '0'})
|
||||
|
||||
|
||||
update = MYSY_GV.dbname['session_formation'].update_one({'_id': ObjectId(str(diction['_id'])),
|
||||
'valide': '1',
|
||||
'partner_owner_recid': str(my_partner['recid']),
|
||||
'automatic_traitement.courrier_template_type_document_id': str(diction['courrier_template_type_document_id'])},
|
||||
{'$set':
|
||||
{
|
||||
'automatic_traitement.$[xxx].actif': str(actif),
|
||||
'automatic_traitement.$[xxx].nb_jour_action': str(nb_jour_action),
|
||||
'automatic_traitement.$[xxx].date_update': str(datetime.now()),
|
||||
'automatic_traitement.$[xxx].update_by': str(my_partner['_id']),
|
||||
}
|
||||
},
|
||||
upsert=False,
|
||||
array_filters=[
|
||||
{"xxx.courrier_template_type_document_id": str(diction['courrier_template_type_document_id'])}
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
|
||||
"""
|
||||
# Ajout de l'evenement dans l'historique
|
||||
"""
|
||||
|
||||
|
||||
now = str(datetime.now().strftime("%d/%m/%Y %H:%M:%S"))
|
||||
history_event_dict = {}
|
||||
history_event_dict['token'] = diction['token']
|
||||
history_event_dict['related_collection'] = "session_formation"
|
||||
history_event_dict['related_collection_recid'] = str(diction['_id'])
|
||||
history_event_dict['action_date'] = str(now)
|
||||
history_event_dict['action_description'] = "Modif. automatisation d'envoi des documents. " \
|
||||
" Type Doc "+str(is_courrier_template_type_document_data['nom'])+". " \
|
||||
" Nouveau : actif = "+str(actif)+" - nb_jour_action = "+str(nb_jour_action)
|
||||
|
||||
|
||||
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, " La session de 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 session de formation"
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Recuperation la list des : "automatic_traitement"
|
||||
d'une session de formation
|
||||
"""
|
||||
def Get_Given_SessionFormation_List_Automatic_Traitement_From(diction):
|
||||
try:
|
||||
|
||||
field_list = ['token', 'session_id', ]
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
if val not in field_list and val.startswith('my_') is False:
|
||||
mycommon.myprint(str(inspect.stack()[0][
|
||||
3]) + " - Le champ '" + val + "' n'est pas autorisé, Creation partenaire annulée")
|
||||
return False, "de récupérer la liste des stagiaires . Toutes les informations fournies ne sont pas valables"
|
||||
|
||||
"""
|
||||
Verification de la liste des champs obligatoires
|
||||
"""
|
||||
field_list_obligatoire = ['token', 'session_id', ]
|
||||
for val in field_list_obligatoire:
|
||||
if val not in diction:
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " - : La valeur '" + val + "' n'est pas presente dans liste ")
|
||||
return False, "Impossible de récupérer la liste des stagiaires, Toutes les informations necessaires n'ont pas été fournies"
|
||||
|
||||
# Recuperation du recid du partner
|
||||
mydata = {}
|
||||
mytoken = ""
|
||||
if ("token" in diction.keys()):
|
||||
if diction['token']:
|
||||
mytoken = diction['token']
|
||||
|
||||
local_status, my_partner = mycommon.Check_Connexion_And_Return_Partner_Data({'token':str(diction['token'])})
|
||||
if (local_status is not True):
|
||||
return local_status, my_partner
|
||||
|
||||
partner_recid = my_partner['recid']
|
||||
|
||||
session_id = ""
|
||||
if ("session_id" in diction.keys()):
|
||||
if diction['session_id']:
|
||||
session_id = diction['session_id']
|
||||
|
||||
if(str(session_id).strip() == ""):
|
||||
return True, []
|
||||
|
||||
coll_session = MYSY_GV.dbname['session_formation']
|
||||
RetObject = []
|
||||
|
||||
local_session_data = coll_session.find_one({'_id':ObjectId(str(session_id)), 'partner_owner_recid':str(partner_recid)}, {'automatic_traitement':1})
|
||||
if( local_session_data and "automatic_traitement" in local_session_data.keys() ):
|
||||
RetObject.append(mycommon.JSONEncoder().encode(local_session_data['automatic_traitement']))
|
||||
|
||||
return True, RetObject
|
||||
|
||||
except Exception as e:
|
||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
|
||||
return False, "Impossible de récupérer la session de formation"
|
||||
|
|
|
@ -793,7 +793,7 @@ def incription_training_cancelled_mail(diction):
|
|||
'valide': '1', 'locked': '0',
|
||||
'ref_interne': 'ANNULE_INSCRIPTION'}
|
||||
|
||||
print(" ### partner_document_PRE_INSCRIPTION_data_qry = ", partner_document_ANNULE_INSCRIPTION_data_qry)
|
||||
print(" ### partner_document_PRE_INSCRIPTION_data_qry (cancellation) = ", partner_document_ANNULE_INSCRIPTION_data_qry)
|
||||
partner_document_ANNULE_INSCRIPTION_data = MYSY_GV.dbname['courrier_template'].find_one(
|
||||
{'partner_owner_recid': str(diction['partner_owner_recid']),
|
||||
'valide': '1', 'locked': '0', 'ref_interne': 'ANNULE_INSCRIPTION'})
|
||||
|
@ -905,7 +905,7 @@ def incription_training_cancelled_mail(diction):
|
|||
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 confirlation (cancellation) envoyé " + str(val))
|
||||
|
||||
|
||||
return True, " Email d'annulation de l'inscritpion bien envoyé"
|
||||
|
|
38
main.py
38
main.py
|
@ -2233,6 +2233,32 @@ def Update_SessionFormation_Only_Step():
|
|||
return jsonify(status=localStatus, message=message )
|
||||
|
||||
|
||||
"""
|
||||
API de mise à jour du parametrage d'automatisation d'envoi des documents
|
||||
/!\ : Une session est modifiable tanque la facturation n'a pas demarré. Apres tous est bloqué
|
||||
"""
|
||||
@app.route('/myclass/api/Update_SessionFormation_Doc_Automatic_Setup/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Update_SessionFormation_Doc_Automatic_Setup():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Update_SessionFormation_Doc_Automatic_Setup : payload = ",str(payload))
|
||||
localStatus, message= SF.Update_SessionFormation_Doc_Automatic_Setup(payload)
|
||||
return jsonify(status=localStatus, message=message )
|
||||
|
||||
|
||||
"""
|
||||
API qui permet de recuperer la liste des '' d'une session de formation
|
||||
en partant de l'_id de la session
|
||||
"""
|
||||
@app.route('/myclass/api/Get_Given_SessionFormation_List_Automatic_Traitement_From/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Get_Given_SessionFormation_List_Automatic_Traitement_From():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Get_Given_SessionFormation_List_Automatic_Traitement_From : payload = ",str(payload))
|
||||
localStatus, message= SF.Get_Given_SessionFormation_List_Automatic_Traitement_From(payload)
|
||||
return jsonify(status=localStatus, message=message )
|
||||
|
||||
|
||||
|
||||
|
@ -11937,7 +11963,17 @@ def Get_Given_base_document_automatic_setup():
|
|||
localStatus, message= base_document_automatic_setup.Get_Given_base_document_automatic_setup(payload)
|
||||
return jsonify(status=localStatus, message=message )
|
||||
|
||||
|
||||
"""
|
||||
API de test du cron qui va traiter automatiquement les documents à envoyer
|
||||
"""
|
||||
@app.route('/myclass/api/Cron_Daily_Document_Sending/', methods=['POST', 'GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Cron_Daily_Document_Sending():
|
||||
mycommon.myprint(" ### CRONNN Cron_Daily_Document_Sending : payload = ")
|
||||
print(" ### CRONNN Cron_Daily_Document_Sending : payload = ")
|
||||
status, retval = Job_Cron.Cron_Daily_Document_Sending()
|
||||
print(" FIN traitement Cron_Daily_Document_Sending localStatus = ")
|
||||
return jsonify(status=status, message="OK" )
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
@ -199,9 +199,6 @@ def Get_Editable_Document_By_Partner_By_Collection(diction):
|
|||
return local_status, my_partner
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
RetObject = []
|
||||
val_tmp = 0
|
||||
|
||||
|
@ -242,7 +239,7 @@ def Get_Editable_Document_By_Partner_By_Collection(diction):
|
|||
])
|
||||
|
||||
#print(" #### Get_Editable_Document_By_Partner_By_Collection pipe_qry_Get_Editable_Document_By_Partner = ", pipe_qry)
|
||||
json_formatted_str = json.dumps(pipe_qry, indent=2)
|
||||
#json_formatted_str = json.dumps(pipe_qry, indent=2)
|
||||
#print(" #### Get_Editable_Document_By_Partner_By_Collection pipe_qry_Get_Editable_Document_By_Partner = ", json_formatted_str)
|
||||
|
||||
|
||||
|
@ -431,8 +428,6 @@ def Get_Editable_Document_By_Partner_By_Collection(diction):
|
|||
RetObject.append(mycommon.JSONEncoder().encode(user))
|
||||
|
||||
|
||||
|
||||
|
||||
#print(" #### rrrr RetObject = ", RetObject)
|
||||
|
||||
return True, RetObject
|
||||
|
|
|
@ -934,6 +934,7 @@ La modification ne s'effectue que si le compte n'est pas verrouillé.
|
|||
|
||||
/!\ : Juste apres la validation, le compte de payement est créé dans Stripe
|
||||
|
||||
cette fontion initialise / initialisation des paramettre par defaut de chaque partenaire
|
||||
'''
|
||||
def valide_partnair_account(value):
|
||||
try:
|
||||
|
|
224
prj_common.py
224
prj_common.py
|
@ -5239,6 +5239,7 @@ def Get_Partner_Currency(partner_owner_recid):
|
|||
|
||||
"""
|
||||
12/03/2024 :
|
||||
** initialiser / initialisation / **
|
||||
Cette fonction permette d'initialiser les configuration par defaut d'un nouveau partenaire de MySy.
|
||||
|
||||
C'est une fonction qui doit etre utilisé à l'activation du compte partenaire. Cela ne l'empechera pas de
|
||||
|
@ -5280,6 +5281,8 @@ Mais ca permet d'envoir un systeme pleinement operationnel des l'activation du c
|
|||
-> 0JF
|
||||
-> 30JF
|
||||
-> 15JFDM
|
||||
|
||||
- initialiser aussi les document envoyé automatiquement (en mode no automatic, pour que le client l'active lui meme)
|
||||
"""
|
||||
def Configure_Partner_Init_Setup_No_Token(diction):
|
||||
try:
|
||||
|
@ -5355,6 +5358,7 @@ def Configure_Partner_Init_Setup_No_Token(diction):
|
|||
|
||||
myprint(" #### FIN CONFIGURATION DE "+str(cpt)+" DOCUMENT(S) ")
|
||||
|
||||
|
||||
"""
|
||||
2 - Configuration du modele de journée de travail
|
||||
"""
|
||||
|
@ -5503,6 +5507,28 @@ def Configure_Partner_Init_Setup_No_Token(diction):
|
|||
|
||||
myprint(" #### FIN CONFIGURATION DE " + str(cpt) + " SITE DE FORMATION ")
|
||||
|
||||
"""
|
||||
7 - Creation du paramettrage pour l'automatisation de l'envoi de certains courrier
|
||||
(ex : activer et decider d'envoyer les convention X jour avant le début de la session
|
||||
"""
|
||||
cpt = 0
|
||||
for my_courrier_data in MYSY_GV.dbname['base_document_automatic_setup'].find(
|
||||
{
|
||||
'partner_owner_recid': 'default', 'valide': '1',
|
||||
'locked': '0'}, ):
|
||||
new_courrier_for_automation = my_courrier_data
|
||||
new_courrier_for_automation['date_created'] = str(datetime.now())
|
||||
new_courrier_for_automation['update_by'] = str(my_partner_data['_id'])
|
||||
new_courrier_for_automation['partner_owner_recid'] = str(my_partner_data['recid'])
|
||||
|
||||
if ("_id" in new_courrier_for_automation.keys()):
|
||||
del new_courrier_for_automation['_id']
|
||||
|
||||
MYSY_GV.dbname['base_document_automatic_setup'].insert_one(new_courrier)
|
||||
cpt = cpt + 1
|
||||
|
||||
myprint(" #### FIN CONFIGURATION DE " + str(cpt) + " AUTOMATISATION DOCUMENT(S) ")
|
||||
|
||||
|
||||
return True, "La configuration fonctionnelle a été correctement faite"
|
||||
|
||||
|
@ -5585,6 +5611,156 @@ def Is_Partnair_Has_Digital_Signature(diction):
|
|||
return False, " Impossible de verifier si le partenaire dispose de la signature digitale "
|
||||
|
||||
|
||||
"""
|
||||
Cette fonction verifie si le paramettre de notification automatique des inscriptions
|
||||
est actif pour ce partenaire
|
||||
"""
|
||||
def Is_Partnair_Inscription_Notification(diction):
|
||||
try:
|
||||
diction = strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', ]
|
||||
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
if val not in field_list and val.startswith('my_') is False:
|
||||
myprint(str(
|
||||
inspect.stack()[0][3]) + " Le champ '" + val + "' n'existe pas")
|
||||
return False, " Les informations fournies sont incorrectes",
|
||||
|
||||
"""
|
||||
Verification des champs obligatoires
|
||||
"""
|
||||
field_list_obligatoire = ['token', ]
|
||||
for val in field_list_obligatoire:
|
||||
if val not in diction:
|
||||
myprint(
|
||||
str(inspect.stack()[0][3]) + " - La valeur '" + val + "' n'est pas presente dans liste ")
|
||||
return False, " Les informations fournies sont incorrectes",
|
||||
|
||||
"""
|
||||
Verification de l'identité et autorisation de l'entité qui
|
||||
appelle cette API
|
||||
"""
|
||||
token = ""
|
||||
if ("token" in diction.keys()):
|
||||
if diction['token']:
|
||||
token = diction['token']
|
||||
|
||||
local_status, my_partner = Check_Connexion_And_Return_Partner_Data(diction)
|
||||
if (local_status is not True):
|
||||
return local_status, my_partner
|
||||
|
||||
"""
|
||||
Clés de mise à jour
|
||||
"""
|
||||
data_cle = {}
|
||||
data_cle['partner_owner_recid'] = str(my_partner['recid'])
|
||||
data_cle['config_name'] = "inscription_notification_email"
|
||||
data_cle['locked'] = "0"
|
||||
data_cle['valide'] = "1"
|
||||
|
||||
RetObject = []
|
||||
val_tmp = 1
|
||||
|
||||
retval_value = ""
|
||||
for retval in MYSY_GV.dbname['base_partner_setup'].find(data_cle):
|
||||
user = retval
|
||||
user['id'] = str(val_tmp)
|
||||
val_tmp = val_tmp + 1
|
||||
|
||||
RetObject.append(JSONEncoder().encode(user))
|
||||
|
||||
if ("config_value" in retval.keys()):
|
||||
retval_value = retval['config_value']
|
||||
|
||||
return True, str(retval_value)
|
||||
|
||||
|
||||
except Exception as e:
|
||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||
myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - Line : " + str(exc_tb.tb_lineno))
|
||||
return False, " Impossible de verifier si le partenaire dispose de la signature digitale "
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Cette fonction verifie si le paramettre de notification automatique des inscriptions
|
||||
est actif pour ce partenaire
|
||||
"""
|
||||
def Is_Partnair_Prenscription_Notification(diction):
|
||||
try:
|
||||
diction = strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', ]
|
||||
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
if val not in field_list and val.startswith('my_') is False:
|
||||
myprint(str(
|
||||
inspect.stack()[0][3]) + " Le champ '" + val + "' n'existe pas")
|
||||
return False, " Les informations fournies sont incorrectes",
|
||||
|
||||
"""
|
||||
Verification des champs obligatoires
|
||||
"""
|
||||
field_list_obligatoire = ['token', ]
|
||||
for val in field_list_obligatoire:
|
||||
if val not in diction:
|
||||
myprint(
|
||||
str(inspect.stack()[0][3]) + " - La valeur '" + val + "' n'est pas presente dans liste ")
|
||||
return False, " Les informations fournies sont incorrectes",
|
||||
|
||||
"""
|
||||
Verification de l'identité et autorisation de l'entité qui
|
||||
appelle cette API
|
||||
"""
|
||||
token = ""
|
||||
if ("token" in diction.keys()):
|
||||
if diction['token']:
|
||||
token = diction['token']
|
||||
|
||||
local_status, my_partner = Check_Connexion_And_Return_Partner_Data(diction)
|
||||
if (local_status is not True):
|
||||
return local_status, my_partner
|
||||
|
||||
"""
|
||||
Clés de mise à jour
|
||||
"""
|
||||
data_cle = {}
|
||||
data_cle['partner_owner_recid'] = str(my_partner['recid'])
|
||||
data_cle['config_name'] = "preinscription_notification_email"
|
||||
data_cle['locked'] = "0"
|
||||
data_cle['valide'] = "1"
|
||||
|
||||
RetObject = []
|
||||
val_tmp = 1
|
||||
|
||||
retval_value = "0"
|
||||
|
||||
for retval in MYSY_GV.dbname['base_partner_setup'].find(data_cle):
|
||||
user = retval
|
||||
user['id'] = str(val_tmp)
|
||||
val_tmp = val_tmp + 1
|
||||
|
||||
if( "config_value" in retval.keys()):
|
||||
retval_value = retval['config_value']
|
||||
|
||||
RetObject.append(JSONEncoder().encode(user))
|
||||
|
||||
return True, str(retval_value)
|
||||
|
||||
|
||||
except Exception as e:
|
||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||
myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - Line : " + str(exc_tb.tb_lineno))
|
||||
return False, " Impossible de verifier si le partenaire dispose de la signature digitale "
|
||||
|
||||
"""
|
||||
Recuperation des differents niveaux de compétence
|
||||
|
@ -5627,6 +5803,7 @@ def Get_Partner_SMTP_Param(partner_recid):
|
|||
|
||||
|
||||
|
||||
|
||||
partner_own_smtp = MYSY_GV.dbname['base_partner_setup'].find_one(
|
||||
{'partner_owner_recid': str(partner_recid),
|
||||
'config_name': 'partner_smtp',
|
||||
|
@ -6347,7 +6524,7 @@ def Get_Courrier_Template_Include_Default_Data(diction):
|
|||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['partner_owner_recid', 'ref_interne', 'type_doc']
|
||||
field_list = ['partner_owner_recid', 'ref_interne', 'type_doc', 'default']
|
||||
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
|
@ -6366,34 +6543,47 @@ def Get_Courrier_Template_Include_Default_Data(diction):
|
|||
str(inspect.stack()[0][3]) + " - La valeur '" + val + "' n'est pas presente dans liste ")
|
||||
return False, " Les informations fournies sont incorrectes"
|
||||
|
||||
courrier_template_data_count = MYSY_GV.dbname['courrier_template'].count_documents({'partner_owner_recid':diction['partner_owner_recid'],
|
||||
Qry_courrier_template = {'partner_owner_recid':diction['partner_owner_recid'],
|
||||
'valide':'1',
|
||||
'locked':'0',
|
||||
'type_doc':str(diction['type_doc']),
|
||||
'ref_interne':str(diction['ref_interne'])})
|
||||
'ref_interne':str(diction['ref_interne'])}
|
||||
|
||||
if( "default_version" in diction.keys() and diction['default_version'] == "1"):
|
||||
Qry_courrier_template = {'partner_owner_recid': diction['partner_owner_recid'],
|
||||
'valide': '1',
|
||||
'locked': '0',
|
||||
'type_doc': str(diction['type_doc']).lower(),
|
||||
'ref_interne': str(diction['ref_interne']),
|
||||
'default_version':'1'}
|
||||
|
||||
|
||||
courrier_template_data_count = MYSY_GV.dbname['courrier_template'].count_documents(Qry_courrier_template)
|
||||
|
||||
if( courrier_template_data_count > 0 ):
|
||||
courrier_template_data_data = MYSY_GV.dbname['courrier_template'].find_one({'partner_owner_recid':diction['partner_owner_recid'],
|
||||
'valide':'1',
|
||||
'locked':'0',
|
||||
'type_doc':str(diction['type_doc']),
|
||||
'ref_interne':str(diction['ref_interne'])})
|
||||
courrier_template_data_data = MYSY_GV.dbname['courrier_template'].find_one(Qry_courrier_template)
|
||||
|
||||
return True, courrier_template_data_data
|
||||
else:
|
||||
courrier_template_data_count = MYSY_GV.dbname['courrier_template'].count_documents(
|
||||
{'partner_owner_recid': 'default',
|
||||
|
||||
Qry_courrier_template = {'partner_owner_recid': 'default',
|
||||
'valide': '1',
|
||||
'locked': '0',
|
||||
'type_doc': str(diction['type_doc']),
|
||||
'ref_interne': str(diction['ref_interne'])})
|
||||
'ref_interne': str(diction['ref_interne'])}
|
||||
|
||||
if ("default_version" in diction.keys() and diction['default_version'] == "1"):
|
||||
Qry_courrier_template = {'partner_owner_recid': 'default',
|
||||
'valide': '1',
|
||||
'locked': '0',
|
||||
'type_doc': str(diction['type_doc']),
|
||||
'ref_interne': str(diction['ref_interne']),
|
||||
'default_version': '1'}
|
||||
|
||||
courrier_template_data_count = MYSY_GV.dbname['courrier_template'].count_documents(Qry_courrier_template)
|
||||
|
||||
if (courrier_template_data_count > 0):
|
||||
courrier_template_data_data = MYSY_GV.dbname['courrier_template'].find_one(
|
||||
{'partner_owner_recid': 'default',
|
||||
'valide': '1',
|
||||
'locked': '0',
|
||||
'type_doc': str(diction['type_doc']),
|
||||
'ref_interne': str(diction['ref_interne'])})
|
||||
courrier_template_data_data = MYSY_GV.dbname['courrier_template'].find_one(Qry_courrier_template)
|
||||
|
||||
return True, courrier_template_data_data
|
||||
else:
|
||||
|
|
Loading…
Reference in New Issue