04/03/2025 - 21h
parent
2936a4e17a
commit
e0ec298f25
|
@ -1,18 +1,17 @@
|
|||
<?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="18/02/2025 - 21h">
|
||||
<change afterPath="$PROJECT_DIR$/Job_Cron_Common.py" afterDir="false" />
|
||||
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="27/02/2025 - 21h">
|
||||
<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$/Job_Cron_Common.py" beforeDir="false" afterPath="$PROJECT_DIR$/Job_Cron_Common.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$/email_inscription_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/email_inscription_mgt.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/formulaire_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/formulaire_mgt.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.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$/partner_client.py" beforeDir="false" afterPath="$PROJECT_DIR$/partner_client.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" />
|
||||
|
@ -84,13 +83,6 @@
|
|||
<option name="presentableId" value="Default" />
|
||||
<updated>1680804787304</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00391" summary="qsh">
|
||||
<created>1725630280201</created>
|
||||
<option name="number" value="00391" />
|
||||
<option name="presentableId" value="LOCAL-00391" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1725630280202</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00392" summary="06/09/2024 - 22h">
|
||||
<created>1725652418352</created>
|
||||
<option name="number" value="00392" />
|
||||
|
@ -427,7 +419,14 @@
|
|||
<option name="project" value="LOCAL" />
|
||||
<updated>1739911910804</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="440" />
|
||||
<task id="LOCAL-00440" summary="27/02/2025 - 21h">
|
||||
<created>1740681801060</created>
|
||||
<option name="number" value="00440" />
|
||||
<option name="presentableId" value="LOCAL-00440" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1740681801061</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="441" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="Vcs.Log.Tabs.Properties">
|
||||
|
@ -469,7 +468,6 @@
|
|||
</option>
|
||||
</component>
|
||||
<component name="VcsManagerConfiguration">
|
||||
<MESSAGE value="27/11/2024 : 12h30" />
|
||||
<MESSAGE value="08/12/2024 - 12h" />
|
||||
<MESSAGE value="10/12/2024 - 22h" />
|
||||
<MESSAGE value="14/12/2024 - 14h" />
|
||||
|
@ -494,6 +492,7 @@
|
|||
<MESSAGE value="11/02/2025 - 15h30" />
|
||||
<MESSAGE value="11/02/2025 - 21h" />
|
||||
<MESSAGE value="18/02/2025 - 21h" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="18/02/2025 - 21h" />
|
||||
<MESSAGE value="27/02/2025 - 21h" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="27/02/2025 - 21h" />
|
||||
</component>
|
||||
</project>
|
|
@ -11350,7 +11350,7 @@ def Sent_Convention_Stagiaire_By_Email_By_Partner_client(tab_files_name_full_pat
|
|||
new_e_document_diction['file_cononical_name'] = cononic_name
|
||||
new_e_document_diction['type'] = "convention"
|
||||
|
||||
print(" ### 011 new_e_document_diction = ", new_e_document_diction)
|
||||
#print(" ### 011 new_e_document_diction = ", new_e_document_diction)
|
||||
local_status_e_doc, local_retval_e_doc = E_Sign_Document.Create_E_Document(new_e_document_diction)
|
||||
|
||||
if(local_status_e_doc is False ):
|
||||
|
@ -11362,7 +11362,7 @@ def Sent_Convention_Stagiaire_By_Email_By_Partner_client(tab_files_name_full_pat
|
|||
"""
|
||||
|
||||
for email in tab_emails_destinataire :
|
||||
print(" ### traitement du mail : ", email)
|
||||
#print(" ### traitement du mail : ", email)
|
||||
new_send_e_document_diction = {}
|
||||
new_send_e_document_diction['token'] = diction['token']
|
||||
new_send_e_document_diction['e_doc_id'] = str(local_retval_e_doc)
|
||||
|
|
491
Job_Cron.py
491
Job_Cron.py
|
@ -22,25 +22,10 @@ import prj_common as mycommon
|
|||
import secrets
|
||||
import inspect
|
||||
import sys, os
|
||||
import csv
|
||||
import pandas as pd
|
||||
|
||||
from pymongo import ReturnDocument
|
||||
import GlobalVariable as MYSY_GV
|
||||
from math import isnan
|
||||
import GlobalVariable as MYSY_GV
|
||||
import ela_index_bdd_classes as eibdd
|
||||
import email_mgt as email
|
||||
import jinja2
|
||||
from flask import send_file
|
||||
from xhtml2pdf import pisa
|
||||
from email.message import EmailMessage
|
||||
from email.mime.text import MIMEText
|
||||
from email import encoders
|
||||
import smtplib
|
||||
from email.mime.multipart import MIMEMultipart
|
||||
from email.mime.text import MIMEText
|
||||
from email.mime.base import MIMEBase
|
||||
from email import encoders
|
||||
|
||||
import survey_mgt as survey_mgt
|
||||
import Job_Cron_Common as Job_Cron_Common
|
||||
|
||||
|
@ -1128,6 +1113,7 @@ Dans cette collection
|
|||
|
||||
Alogorithme :
|
||||
|
||||
/!\ Ce cron doit tourner tous les jours à 23h
|
||||
|
||||
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) }
|
||||
|
@ -1145,7 +1131,7 @@ qqtps, deplus ce sont des traitement noctures, donc ca devrait aller.
|
|||
|
||||
"""
|
||||
|
||||
def Cron_Daily_Document_Sending():
|
||||
def Cron_Daily_Automatic_Qualiopi_Documents():
|
||||
try:
|
||||
print(" Cron : In function = Cron_Daily_Document_Sending")
|
||||
|
||||
|
@ -1163,123 +1149,155 @@ def Cron_Daily_Document_Sending():
|
|||
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(" # Code Session = ", my_session['code_session'])
|
||||
print(" # Date Start Session = ", my_session['date_debut'])
|
||||
print(" # Date End Session = ", my_session['date_fin'])
|
||||
|
||||
#print(" # automatic_traitement = ", my_session['automatic_traitement'])
|
||||
diction_for_notification_email = {}
|
||||
diction_for_notification_email['session_id'] = str(my_session['_id'])
|
||||
diction_for_notification_email['tab_message'] = []
|
||||
|
||||
for data_automatic_traitement in my_session['automatic_traitement'] :
|
||||
if (data_automatic_traitement["actif"] == "1" and data_automatic_traitement["valide"] == "1" and data_automatic_traitement["statut"] != "2"):
|
||||
|
||||
print(" # Nb jour action = ", data_automatic_traitement['nb_jour_action'])
|
||||
print(" # Date du jour = ", str(todays_date))
|
||||
print(" # Analyse Document = ", str(data_automatic_traitement['nom_document']))
|
||||
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:
|
||||
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 * Cron_Daily_Document_Sending: Impossible de trouver le type de document concerné "
|
||||
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']))
|
||||
|
||||
continue
|
||||
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'})
|
||||
|
||||
print(" ### avant action 1 courrier_template_type_document_data = ", courrier_template_type_document_data)
|
||||
print(" ## data_automatic_traitement = ", data_automatic_traitement)
|
||||
node_notification = {}
|
||||
node_notification['message'] = "Warning : Il y a une tâche automatique qui n'a pas été exécutée " \
|
||||
" Date Initialement prévue "+str(local_session_start_date_added_nb_jour_action_formated)+ " -- " \
|
||||
" Action : "+str(courrier_template_type_document_data['ref_interne'])
|
||||
node_notification['status'] = "Warning "
|
||||
diction_for_notification_email['tab_message'].append(node_notification)
|
||||
|
||||
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'])
|
||||
elif (local_session_start_date_added_nb_jour_action == datetime.strptime(str(todays_date).strip(), '%d/%m/%Y')):
|
||||
|
||||
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)
|
||||
"""
|
||||
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)
|
||||
|
||||
node_notification = {}
|
||||
node_notification['message'] = str(courrier_template_type_document_data['ref_interne'])
|
||||
node_notification['status'] = str(local_status)
|
||||
diction_for_notification_email['tab_message'].append(node_notification)
|
||||
|
||||
|
||||
"""
|
||||
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']))
|
||||
"""
|
||||
|
||||
"""
|
||||
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'])}
|
||||
]
|
||||
local_status, my_partner = mycommon.Get_Connected_User_Partner_Data_From_RecID(str(my_session['partner_owner_recid']))
|
||||
if (local_status is not True):
|
||||
return local_status, my_partner
|
||||
|
||||
)
|
||||
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, ""
|
||||
diction_for_notification_email['token'] = str(my_partner['token'])
|
||||
|
||||
print("### diction_for_notification_email == ", diction_for_notification_email)
|
||||
|
||||
local_status, local_retval = Job_Cron_Common.Cron_Qualiopi_Automatic_Traitement_Notification(diction_for_notification_email)
|
||||
|
||||
return True, "OK"
|
||||
|
||||
|
||||
except Exception as e:
|
||||
|
@ -1335,8 +1353,6 @@ def Send_document_from_base_document_automatic_setup(diction):
|
|||
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 = {}
|
||||
|
@ -1344,9 +1360,9 @@ def Send_document_from_base_document_automatic_setup(diction):
|
|||
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)
|
||||
#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_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']
|
||||
|
@ -1372,13 +1388,242 @@ def Send_document_from_base_document_automatic_setup(diction):
|
|||
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 ")
|
||||
"""
|
||||
1 - Aller chercher le formulaire (type = questionnaire de positionnement ) par defaut
|
||||
2 - Initialiser l'enquete
|
||||
3 - Envoyer l'enquete
|
||||
"""
|
||||
print(" ### DEBUT Initialiser le questionnaire de positionnement ")
|
||||
|
||||
local_default_form_count = MYSY_GV.dbname['formulaire'].count_documents(
|
||||
{'type':'pos',
|
||||
'valide': '1',
|
||||
'locked': '0',
|
||||
'default': '1',
|
||||
'partner_owner_recid': str(my_partner['recid'])})
|
||||
|
||||
if(local_default_form_count != 1 ):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " La configuration du questionnaire de positionnement par défaut est invalide. Nb formulaire = ", local_default_form_count)
|
||||
return False, " La configuration du questionnaire de positionnement par défaut est invalide"
|
||||
|
||||
local_default_form_data = MYSY_GV.dbname['formulaire'].find_one(
|
||||
{'type': 'pos',
|
||||
'valide': '1',
|
||||
'locked': '0',
|
||||
'default': '1',
|
||||
'partner_owner_recid': str(my_partner['recid'])}, {'_id':1})
|
||||
|
||||
init_diction = {}
|
||||
init_diction['token']= my_partner['token']
|
||||
init_diction['session_id'] = diction['session_id']
|
||||
init_diction['formulaire_id'] = local_default_form_data['_id']
|
||||
init_diction['survey_type'] = "pos"
|
||||
init_diction['sending_date'] = ""
|
||||
|
||||
local_status_init, local_retval_init = Job_Cron_Common.Cron_Init_Survey_Tab_For_Inscrit_Not_Init(init_diction)
|
||||
|
||||
if( local_status_init is False ):
|
||||
return local_status_init, local_retval_init
|
||||
|
||||
|
||||
print(" ### DEBUT Envoyer le questionnaire de positionnement ")
|
||||
local_status_send, local_retval_send = Job_Cron_Common.Cron_Send_Survey_TabIds(init_diction)
|
||||
|
||||
if (local_status_send is False):
|
||||
return local_status_send, local_retval_send
|
||||
|
||||
|
||||
elif ( str(diction['document_ref_intern']) == 'EVAL_FORMATION' ):
|
||||
|
||||
"""
|
||||
Evaluation à chaud
|
||||
"""
|
||||
print(" ### DEBUT Initialiser le questionnaire d'evaluation à chaud ")
|
||||
|
||||
local_default_form_count = MYSY_GV.dbname['formulaire'].count_documents(
|
||||
{'type': 'hot_eval',
|
||||
'valide': '1',
|
||||
'locked': '0',
|
||||
'default': '1',
|
||||
'partner_owner_recid': str(my_partner['recid'])})
|
||||
|
||||
if (local_default_form_count != 1):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " La configuration du questionnaire de positionnement par défaut est invalide. Nb formulaire = ",
|
||||
local_default_form_count)
|
||||
return False, " La configuration du questionnaire d'évaluation à chaud par défaut est invalide"
|
||||
|
||||
local_default_form_data = MYSY_GV.dbname['formulaire'].find_one(
|
||||
{'type': 'hot_eval',
|
||||
'valide': '1',
|
||||
'locked': '0',
|
||||
'default': '1',
|
||||
'partner_owner_recid': str(my_partner['recid'])}, {'_id': 1})
|
||||
|
||||
init_diction = {}
|
||||
init_diction['token'] = my_partner['token']
|
||||
init_diction['session_id'] = diction['session_id']
|
||||
init_diction['formulaire_id'] = local_default_form_data['_id']
|
||||
init_diction['survey_type'] = "hot_eval"
|
||||
init_diction['sending_date'] = ""
|
||||
|
||||
local_status_init, local_retval_init = Job_Cron_Common.Cron_Init_Survey_Tab_For_Inscrit_Not_Init(
|
||||
init_diction)
|
||||
|
||||
if (local_status_init is False):
|
||||
return local_status_init, local_retval_init
|
||||
|
||||
|
||||
print(" ### DEBUT Envoyer le questionnaire de Evaluation à Chaud ")
|
||||
local_status_send, local_retval_send = Job_Cron_Common.Cron_Send_Survey_TabIds(init_diction)
|
||||
|
||||
if (local_status_send is False):
|
||||
return local_status_send, local_retval_send
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Evaluation du formateur mis que la session de formation, si formateur
|
||||
"""
|
||||
print(" ### DEBUT Initialiser le questionnaire d'évaluation du formation mis sur la session ")
|
||||
|
||||
#1 - Verifier s'il y a un formateur valide sur la session
|
||||
session_data = MYSY_GV.dbname['session_formation'].find_one({'_id':ObjectId(str(diction['session_id']))}, {'_id':1, 'formateur_id':1})
|
||||
|
||||
if( session_data and "formateur_id" in session_data.keys() and session_data['formateur_id']):
|
||||
# Aller chercher le formulaire par défaut pour l'evaluation des enseignants
|
||||
local_default_form_count = MYSY_GV.dbname['formulaire'].count_documents(
|
||||
{'type': 'human_eval',
|
||||
'valide': '1',
|
||||
'locked': '0',
|
||||
'default': '1',
|
||||
'partner_owner_recid': str(my_partner['recid'])})
|
||||
|
||||
if (local_default_form_count != 1):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " La configuration du questionnaire d'évaluation du formateur par défaut est invalide. Nb formulaire = " + str(
|
||||
local_default_form_count))
|
||||
return False, " La configuration du questionnaire d'évaluation du formateur par défaut est invalide"
|
||||
|
||||
local_default_form_data = MYSY_GV.dbname['formulaire'].find_one(
|
||||
{'type': 'human_eval',
|
||||
'valide': '1',
|
||||
'locked': '0',
|
||||
'default': '1',
|
||||
'partner_owner_recid': str(my_partner['recid'])}, {'_id': 1})
|
||||
|
||||
init_diction = {}
|
||||
init_diction['token'] = my_partner['token']
|
||||
init_diction['session_id'] = diction['session_id']
|
||||
init_diction['formulaire_id'] = local_default_form_data['_id']
|
||||
init_diction['survey_type'] = "human_eval"
|
||||
init_diction['sending_date'] = ""
|
||||
|
||||
init_diction['related_collection'] = "ressource_humaine"
|
||||
init_diction['related_collection_id'] = str(session_data['formateur_id'])
|
||||
|
||||
|
||||
local_status_init, local_retval_init = Job_Cron_Common.Cron_Init_Survey_Tab_For_Inscrit_Not_Init(
|
||||
init_diction)
|
||||
|
||||
if (local_status_init is False):
|
||||
return local_status_init, local_retval_init
|
||||
|
||||
print(" ### DEBUT Envoyer le questionnaire de Evaluation du formateur ")
|
||||
local_status_send, local_retval_send = Job_Cron_Common.Cron_Send_Survey_TabIds(init_diction)
|
||||
|
||||
if (local_status_send is False):
|
||||
return local_status_send, local_retval_send
|
||||
|
||||
|
||||
"""
|
||||
Evaluation à froid à envoyer 3 mois plus tard
|
||||
"""
|
||||
|
||||
print(" ### DEBUT Initialiser le questionnaire d'evaluation à froid à faire 3 mois plus tard ")
|
||||
|
||||
local_default_form_count = MYSY_GV.dbname['formulaire'].count_documents(
|
||||
{'type': 'cold_eval',
|
||||
'valide': '1',
|
||||
'locked': '0',
|
||||
'default': '1',
|
||||
'partner_owner_recid': str(my_partner['recid'])})
|
||||
|
||||
if (local_default_form_count != 1):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " La configuration du questionnaire d'évaluation à froid par défaut est invalide. Nb formulaire = "+str(
|
||||
local_default_form_count))
|
||||
return False, "La configuration du questionnaire d'évaluation à froid par défaut est invalide"
|
||||
|
||||
local_default_form_data = MYSY_GV.dbname['formulaire'].find_one(
|
||||
{'type': 'cold_eval',
|
||||
'valide': '1',
|
||||
'locked': '0',
|
||||
'default': '1',
|
||||
'partner_owner_recid': str(my_partner['recid'])}, {'_id': 1})
|
||||
|
||||
today_plus_90_jours = date.today() + timedelta(days=90)
|
||||
today_plus_90_jours_string = str(today_plus_90_jours.strftime("%d/%m/%Y"))
|
||||
|
||||
init_diction = {}
|
||||
init_diction['token'] = my_partner['token']
|
||||
init_diction['session_id'] = diction['session_id']
|
||||
init_diction['formulaire_id'] = local_default_form_data['_id']
|
||||
init_diction['survey_type'] = "cold_eval"
|
||||
init_diction['sending_date'] = str(today_plus_90_jours_string)
|
||||
|
||||
print(" ### à 90 j = ", init_diction)
|
||||
|
||||
|
||||
local_status_init, local_retval_init = Job_Cron_Common.Cron_Init_Survey_Tab_For_Inscrit_Not_Init(
|
||||
init_diction)
|
||||
|
||||
if (local_status_init is False):
|
||||
return local_status_init, local_retval_init
|
||||
|
||||
|
||||
elif ( str(diction['document_ref_intern']) == 'ATTESTATION_FORMATION' ):
|
||||
print(" ### Initialiser les attestations de formation ")
|
||||
print(" ### Debut Initialisation les attestations de formation ")
|
||||
# 1 Recuperer le modele d'attestation par défaut
|
||||
|
||||
local_diction = {}
|
||||
local_diction['ref_interne'] = "ATTESTATION_FORMATION"
|
||||
local_diction['type_doc'] = "email"
|
||||
local_diction['partner_owner_recid'] = str(diction['partner_owner_recid'])
|
||||
local_diction['default_version'] = "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 'ATTESTATION_FORMATION', (type : Email) ")
|
||||
return False, " Impossible de récuperer le modèle de courrier 'ATTESTATION_FORMATION', (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 'ATTESTATION_FORMATION', (type : Email) n'est pas correctement configuré ")
|
||||
return False, " Le modèle de courrier 'ATTESTATION_FORMATION', (type : Email) n'est pas correctement configuré"
|
||||
|
||||
|
||||
|
||||
init_diction = {}
|
||||
init_diction['token'] = my_partner['token']
|
||||
init_diction['session_id'] = diction['session_id']
|
||||
init_diction['courrier_template_id'] = courrier_data_retval['_id']
|
||||
|
||||
local_status_init, local_retval_init = Job_Cron_Common.Cron_Init_Attestation_Formation_With_Template(init_diction)
|
||||
|
||||
if (local_status_init is False):
|
||||
return local_status_init, local_retval_init
|
||||
|
||||
|
||||
print(" ### Envoyer les attestations de formation ")
|
||||
|
||||
|
||||
|
|
1621
Job_Cron_Common.py
1621
Job_Cron_Common.py
File diff suppressed because it is too large
Load Diff
9537
Log/log_file.log
9537
Log/log_file.log
File diff suppressed because one or more lines are too long
|
@ -533,11 +533,15 @@ def Add_Update_SessionFormation(diction):
|
|||
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)
|
||||
new_local_data = base_document_automatic_setup_for_partner
|
||||
new_local_data['statut'] = "0"
|
||||
new_local_data['created_date'] = str(datetime.now())
|
||||
new_local_data['created_by'] = str(my_partner['_id'])
|
||||
|
||||
mydata['automatic_traitement'].append(new_local_data)
|
||||
|
||||
#print(" ### mydata = ", mydata)
|
||||
coll_name = MYSY_GV.dbname['session_formation']
|
||||
|
@ -6135,7 +6139,7 @@ def Prepare_and_Send_Default_Convention_From_Session_By_PDF(diction):
|
|||
local_diction['courrier_template_id'] = default_courrier_template_client_data['_id']
|
||||
local_diction['client_id'] = str(val)
|
||||
|
||||
print(" #### Traitemnt de local_diction aaa = ", local_diction)
|
||||
#print(" #### Traitemnt de local_diction aaa = ", local_diction)
|
||||
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
|
||||
|
@ -8303,7 +8307,7 @@ def Sent_Attestation_Stagiaire_By_Email(tab_files, Folder, diction):
|
|||
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 la convention par email "
|
||||
return False, " Impossible d'envoyer l'attestation de formation par email "
|
||||
|
||||
|
||||
"""
|
||||
|
|
|
@ -55,7 +55,8 @@ def Add_Formulaire(diction):
|
|||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', 'code', 'nom', 'description', 'commentaire', 'message_introduction', 'type' ]
|
||||
field_list = ['token', 'code', 'nom', 'description', 'commentaire', 'message_introduction',
|
||||
'type', 'default' ]
|
||||
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
|
@ -115,7 +116,7 @@ def Add_Formulaire(diction):
|
|||
mycommon.myprint(" Un formulaire avec le même code existe déjà ")
|
||||
return False, " Un formulaire avec le même code existe déjà "
|
||||
|
||||
mydata['date_update'] = str(datetime.now())
|
||||
mydata['date_created'] = str(datetime.now())
|
||||
mydata['update_by'] = str(my_partner['_id'])
|
||||
mydata['partner_owner_recid'] = str(my_partner['recid'])
|
||||
mydata['valide'] = "1"
|
||||
|
@ -665,6 +666,8 @@ def Get_List_Formulaire(diction):
|
|||
user = New_retVal
|
||||
user['id'] = str(val_tmp)
|
||||
val_tmp = val_tmp + 1
|
||||
if( "default" not in user.keys()):
|
||||
user['default'] = "0"
|
||||
|
||||
RetObject.append(mycommon.JSONEncoder().encode(user))
|
||||
|
||||
|
@ -749,6 +752,8 @@ def Get_List_Formulaire_with_filter(diction):
|
|||
user['id'] = str(val_tmp)
|
||||
val_tmp = val_tmp + 1
|
||||
|
||||
if ("default" not in user.keys()):
|
||||
user['default'] = "0"
|
||||
RetObject.append(mycommon.JSONEncoder().encode(user))
|
||||
|
||||
return True, RetObject
|
||||
|
@ -814,6 +819,8 @@ def Get_Given_Formulaire(diction):
|
|||
user = New_retVal
|
||||
user['id'] = str(val_tmp)
|
||||
val_tmp = val_tmp + 1
|
||||
if ("default" not in user.keys()):
|
||||
user['default'] = "0"
|
||||
|
||||
RetObject.append(mycommon.JSONEncoder().encode(user))
|
||||
|
||||
|
@ -838,7 +845,8 @@ def Update_Formulaire(diction):
|
|||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', 'code', 'nom', 'description', 'commentaire', 'form_id', 'message_introduction', 'type']
|
||||
field_list = ['token', 'code', 'nom', 'description', 'commentaire', 'form_id', 'message_introduction',
|
||||
'type', 'default']
|
||||
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
|
|
12
main.py
12
main.py
|
@ -11966,13 +11966,13 @@ def Get_Given_base_document_automatic_setup():
|
|||
"""
|
||||
API de test du cron qui va traiter automatiquement les documents à envoyer
|
||||
"""
|
||||
@app.route('/myclass/api/Cron_Daily_Document_Sending/', methods=['POST', 'GET'])
|
||||
@app.route('/myclass/api/Cron_Daily_Automatic_Qualiopi_Documents/', 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 = ")
|
||||
def Cron_Daily_Automatic_Qualiopi_Documents():
|
||||
mycommon.myprint(" ### CRONNN Cron_Daily_Automatic_Qualiopi_Documents : payload = ")
|
||||
print(" ### CRONNN Cron_Daily_Automatic_Qualiopi_Documents : payload = ")
|
||||
status, retval = Job_Cron.Cron_Daily_Automatic_Qualiopi_Documents()
|
||||
print(" FIN traitement Cron_Daily_Automatic_Qualiopi_Documents localStatus = ", status)
|
||||
return jsonify(status=status, message="OK" )
|
||||
|
||||
|
||||
|
|
|
@ -1228,7 +1228,7 @@ def Editic_Log_History_Action_From_courrier_template_type_document_ref_interne(m
|
|||
history_data_to_log['target_collection_recid'] = local_target_collection_recid
|
||||
|
||||
|
||||
print( "#### history_data_to_log = ", history_data_to_log)
|
||||
#print( "#### history_data_to_log = ", history_data_to_log)
|
||||
MYSY_GV.dbname['courrier_template_tracking_history'].insert_one(history_data_to_log)
|
||||
|
||||
return True, " L'évènement Editique a été correctement enregistré "
|
||||
|
|
|
@ -2729,7 +2729,6 @@ def Create_Partner_Client_Intranet_Account(diction):
|
|||
return True, " WARNING : Le compte intranet du client a été mais impossible d'envoyer l'email de notification au client (2) "
|
||||
|
||||
|
||||
|
||||
body = {
|
||||
"params": dictionnary_data,
|
||||
}
|
||||
|
@ -2752,7 +2751,7 @@ def Create_Partner_Client_Intranet_Account(diction):
|
|||
sourceHtml = contenu_doc_Template.render(params=body["params"])
|
||||
html_mime = MIMEText(sourceHtml, 'html')
|
||||
|
||||
# Creation de l'email à enoyer
|
||||
# Creation de l'email à envoyer
|
||||
msg = MIMEMultipart("alternative")
|
||||
|
||||
if (str(partner_own_smtp_value) == "1"):
|
||||
|
|
|
@ -4727,7 +4727,8 @@ def Get_Dictionnary_data_For_Template(diction):
|
|||
local_company_data = local_retval
|
||||
company_data = {}
|
||||
|
||||
company_liste_champ = ['nom', 'email', 'telephone', 'num_nda', 'website', 'adr_street', 'adr_zip', 'adr_city', 'adr_country', 'siret']
|
||||
company_liste_champ = ['nom', 'email', 'telephone', 'num_nda', 'website', 'adr_street', 'adr_zip', 'adr_city',
|
||||
'adr_country', 'siret', 'contact_nom', 'contact_prenom', 'contact_tel', 'contact_mail']
|
||||
for champ in company_liste_champ:
|
||||
if (champ in local_company_data):
|
||||
new_champ_name = "societe_" + str(champ)
|
||||
|
@ -6524,7 +6525,7 @@ def Get_Courrier_Template_Include_Default_Data(diction):
|
|||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['partner_owner_recid', 'ref_interne', 'type_doc', 'default']
|
||||
field_list = ['partner_owner_recid', 'ref_interne', 'type_doc', 'default', 'default_version']
|
||||
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
|
|
Loading…
Reference in New Issue