parent
4fb7d85cbd
commit
98b7f7c771
|
@ -4,14 +4,10 @@
|
|||
<option name="autoReloadType" value="SELECTIVE" />
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="19/06/2025 -18h">
|
||||
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="20/06/2025 -18h">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" 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$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/partner_base_setup.py" beforeDir="false" afterPath="$PROJECT_DIR$/partner_base_setup.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/survey_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/survey_mgt.py" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
|
@ -454,7 +450,7 @@
|
|||
<option name="project" value="LOCAL" />
|
||||
<updated>1747251650255</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="477" />
|
||||
<option name="localTasksCounter" value="478" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="Vcs.Log.Tabs.Properties">
|
||||
|
@ -496,7 +492,6 @@
|
|||
</option>
|
||||
</component>
|
||||
<component name="VcsManagerConfiguration">
|
||||
<MESSAGE value="30/04/2025 - 15h" />
|
||||
<MESSAGE value="02/05/2025 - 20h" />
|
||||
<MESSAGE value="03/05/2025 - 20h" />
|
||||
<MESSAGE value="05/05/2025 - 20h" />
|
||||
|
@ -521,6 +516,7 @@
|
|||
<MESSAGE value="11/06/2025 - 16h30" />
|
||||
<MESSAGE value="qsd" />
|
||||
<MESSAGE value="19/06/2025 -18h" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="19/06/2025 -18h" />
|
||||
<MESSAGE value="20/06/2025 -18h" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="20/06/2025 -18h" />
|
||||
</component>
|
||||
</project>
|
27
Job_Cron.py
27
Job_Cron.py
|
@ -145,7 +145,9 @@ def Global_MySy_Cron_Traitement():
|
|||
|
||||
|
||||
"""
|
||||
CRON fonction qui envoie les demandes d'enquete
|
||||
CRON fonction qui envoie les demandes d'enquete, qui sont envoi automatique (cas des questionnaire a froid).
|
||||
|
||||
Attention : A ne pas confondre avec 'Cron_Survey_Questionnaires_Relance' qui relance les questionnaire dont on pas la réponse
|
||||
"""
|
||||
def Cron_Send_Survey():
|
||||
try:
|
||||
|
@ -1913,7 +1915,7 @@ def Cron_Survey_Questionnaires_Relance():
|
|||
print(" ## pipe_qry Cron_Survey_Questionnaires_Relance = ", pipe_qry)
|
||||
for local_questionnaire in MYSY_GV.dbname['survey'].aggregate(pipe_qry):
|
||||
|
||||
print("### local_questionnaire a traiter = ", local_questionnaire)
|
||||
#print("### local_questionnaire a traiter = ", local_questionnaire)
|
||||
|
||||
relance_done = 0
|
||||
|
||||
|
@ -1931,11 +1933,11 @@ def Cron_Survey_Questionnaires_Relance():
|
|||
days=frequence_relance_auto)
|
||||
|
||||
|
||||
print(" ### LA frequence_relance_auto ", frequence_relance_auto)
|
||||
"""print(" ### LA frequence_relance_auto ", frequence_relance_auto)
|
||||
|
||||
print(" ### LA dernière relance date de ", date_derniere_relance_auto)
|
||||
|
||||
print(" ### LA PROCHAINE RELANCE EST ", new_relance_date_ISODATE)
|
||||
print(" ### LA PROCHAINE RELANCE EST ", new_relance_date_ISODATE)"""
|
||||
|
||||
|
||||
new_relance_date_no_ISODATE = str(new_relance_date_ISODATE.strftime("%d/%m/%Y"))
|
||||
|
@ -1944,14 +1946,14 @@ def Cron_Survey_Questionnaires_Relance():
|
|||
datetime.strptime(str(todays_date), '%d/%m/%Y')
|
||||
|
||||
|
||||
print(" ### relance_done = ",relance_done)
|
||||
"""print(" ### relance_done = ",relance_done)
|
||||
print(" ### nb_limite_relance = ", nb_limite_relance)
|
||||
|
||||
print(" ### datetime.strptime( str(todays_date), '%d/%m/%Y') = ", datetime.strptime(
|
||||
str(todays_date), '%d/%m/%Y'))
|
||||
|
||||
print(" ### datetime.strptime(str(new_relance_date_no_ISODATE).strip(), '%d/%m/%Y') = ", datetime.strptime(str(new_relance_date_no_ISODATE).strip(),
|
||||
'%d/%m/%Y'))
|
||||
'%d/%m/%Y'))"""
|
||||
|
||||
if ( relance_done <= nb_limite_relance and datetime.strptime(
|
||||
str(todays_date), '%d/%m/%Y') >= datetime.strptime(str(new_relance_date_no_ISODATE).strip(),
|
||||
|
@ -1971,14 +1973,11 @@ def Cron_Survey_Questionnaires_Relance():
|
|||
local_dicton['partner_owner_recid'] = str(local_questionnaire['partner_owner_recid'])
|
||||
local_dicton['tab_ids'] = str(local_questionnaire['_id'])
|
||||
|
||||
print(" ### local_dicton = ", local_dicton)
|
||||
#print(" ### local_dicton = ", local_dicton)
|
||||
|
||||
"""
|
||||
ICICI : comme j'ai supprimé de formation et des session, m'assurer d'avoir de bonnes date
|
||||
"""
|
||||
local_status, local_retval = survey_mgt.Automatic_Send_Survey_TabIds(local_dicton)
|
||||
|
||||
print(" relance return local_send_remind_status = ", local_status)
|
||||
#print(" relance return local_send_remind_status = ", local_status)
|
||||
|
||||
if (local_status is True):
|
||||
|
||||
|
@ -2027,12 +2026,6 @@ def Cron_Survey_Questionnaires_Relance():
|
|||
)
|
||||
|
||||
|
||||
else:
|
||||
print(" ### NoNNNNNNNNNN on NEEEE fait la relanceeeeeeeeeeeee")
|
||||
print(" limite relance atteint : ")
|
||||
print(" limite relance_done : ", relance_done)
|
||||
print(" limite nb_limite_relance : ", nb_limite_relance)
|
||||
|
||||
|
||||
return True, "Relance Questionnaires OK"
|
||||
|
||||
|
|
1114
Log/log_file.log
1114
Log/log_file.log
File diff suppressed because it is too large
Load Diff
582
survey_mgt.py
582
survey_mgt.py
|
@ -1726,7 +1726,8 @@ def Send_Survey_TabIds(diction):
|
|||
},
|
||||
'$set':{'statut':'1', 'date_update':str(now),
|
||||
'update_by':str(my_partner['_id']),
|
||||
'date_envoi':now}
|
||||
'date_envoi':now,
|
||||
'date_dernier_relance_auto':str(datetime.now().strftime("%d/%m/%Y"))}
|
||||
}
|
||||
)
|
||||
|
||||
|
@ -1832,6 +1833,10 @@ def Automatic_Send_Survey_TabIds(diction):
|
|||
return local_status, my_partner
|
||||
|
||||
my_survey_ids = ""
|
||||
survey_inscription_is_ok = "0"
|
||||
survey_session_is_ok = "0"
|
||||
survey_class_is_ok = "0"
|
||||
|
||||
if ("tab_ids" in diction.keys()):
|
||||
if diction['tab_ids']:
|
||||
my_survey_ids = diction['tab_ids']
|
||||
|
@ -1839,312 +1844,343 @@ def Automatic_Send_Survey_TabIds(diction):
|
|||
tab_my_survey_ids = str(my_survey_ids).split(",")
|
||||
for my_survey_id in tab_my_survey_ids:
|
||||
|
||||
# Verifier que les survey sont valides
|
||||
# Verifier que les survey sont valides ainsi que la session et l'inscription concerné
|
||||
qry = { '_id':ObjectId(str(my_survey_id)), 'partner_owner_recid': str(my_partner['recid']),'valide':'1', 'locked':'0'}
|
||||
|
||||
print(" qry2 === ", qry)
|
||||
#print(" qry2 === ", qry)
|
||||
tmp_count = MYSY_GV.dbname['survey'].count_documents(qry)
|
||||
|
||||
if (tmp_count <= 0):
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " L'identifiant de l'enquete "+str(my_survey_id)+" invalide ")
|
||||
return False, " L'identifiant de l'enquete "+str(my_survey_id)+" invalide "
|
||||
|
||||
survey_data = MYSY_GV.dbname['survey'].find_one(qry)
|
||||
|
||||
if("inscription_id" in survey_data.keys() and survey_data['inscription_id']):
|
||||
local_is_inscription_count = MYSY_GV.dbname['inscription'].count_documents({"partner_owner_recid":str(my_partner['recid']),
|
||||
'valide':'1',
|
||||
'locked':'0',
|
||||
'_id':ObjectId(str(survey_data['inscription_id']))})
|
||||
|
||||
if(local_is_inscription_count == 1 ):
|
||||
survey_inscription_is_ok = "1"
|
||||
|
||||
if ("session_id" in survey_data.keys() and survey_data['session_id']):
|
||||
local_is_session_count = MYSY_GV.dbname['session_formation'].count_documents(
|
||||
{"partner_owner_recid": str(my_partner['recid']),
|
||||
'valide': '1',
|
||||
'_id': ObjectId(str(survey_data['session_id']))})
|
||||
|
||||
if (local_is_session_count == 1):
|
||||
survey_session_is_ok = "1"
|
||||
|
||||
if ("class_id" in survey_data.keys() and survey_data['class_id']):
|
||||
local_is_class_count = MYSY_GV.dbname['myclass'].count_documents(
|
||||
{"partner_owner_recid": str(my_partner['recid']),
|
||||
'valide': '1',
|
||||
'locked':'0',
|
||||
'_id': ObjectId(str(survey_data['class_id']))})
|
||||
|
||||
if (local_is_class_count == 1):
|
||||
survey_class_is_ok = "1"
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Les enquete etant toutes valides, on va preceder à l'envoie des email de demande
|
||||
21/06/2025 : on envoie de mail que la session, l'inscription et la formation sont valides
|
||||
"""
|
||||
"""
|
||||
Recuperation des parametre SMTP du partner si le client a decidé d'utiliser son propre smpt
|
||||
"""
|
||||
partner_own_smtp_value = "0"
|
||||
partner_own_smtp = MYSY_GV.dbname['base_partner_setup'].find_one(
|
||||
{'partner_owner_recid': str(my_partner['recid']),
|
||||
'config_name': 'partner_smtp',
|
||||
'valide': '1',
|
||||
'locked': '0'})
|
||||
if( survey_class_is_ok == "1" and survey_session_is_ok == "1" and survey_inscription_is_ok == "1"):
|
||||
|
||||
if (partner_own_smtp and "config_value" in partner_own_smtp.keys()):
|
||||
partner_own_smtp_value = partner_own_smtp['config_value']
|
||||
|
||||
if (str(partner_own_smtp_value) == "1"):
|
||||
partner_SMTP_COUNT_password = str(MYSY_GV.dbname['base_partner_setup'].find_one(
|
||||
{'partner_owner_recid': str(my_partner['recid']),
|
||||
'config_name': 'smtp_user_pwd',
|
||||
'valide': '1',
|
||||
'locked': '0'}, {'config_value': 1})['config_value'])
|
||||
|
||||
partner_SMTP_COUNT_smtpsrv = str(MYSY_GV.dbname['base_partner_setup'].find_one(
|
||||
{'partner_owner_recid': str(my_partner['recid']),
|
||||
'config_name': 'smtp_server',
|
||||
'valide': '1',
|
||||
'locked': '0'}, {'config_value': 1})['config_value'])
|
||||
|
||||
partner_SMTP_COUNT_user = str(MYSY_GV.dbname['base_partner_setup'].find_one(
|
||||
{'partner_owner_recid': str(my_partner['recid']),
|
||||
'config_name': 'smtp_user',
|
||||
'valide': '1',
|
||||
'locked': '0'}, {'config_value': 1})['config_value'])
|
||||
|
||||
partner_SMTP_COUNT_From_User = str(MYSY_GV.dbname['base_partner_setup'].find_one(
|
||||
{'partner_owner_recid': str(my_partner['recid']),
|
||||
'config_name': 'smtp_count_from_name',
|
||||
'valide': '1',
|
||||
'locked': '0'}, {'config_value': 1})['config_value'])
|
||||
|
||||
partner_SMTP_COUNT_port = str(MYSY_GV.dbname['base_partner_setup'].find_one(
|
||||
{'partner_owner_recid': str(my_partner['recid']),
|
||||
'config_name': 'smtp_count_port',
|
||||
'valide': '1',
|
||||
'locked': '0'}, {'config_value': 1})['config_value'])
|
||||
|
||||
|
||||
for my_survey_id in tab_my_survey_ids:
|
||||
# Recuperation des données de l'inscript
|
||||
|
||||
qry = { '_id':ObjectId(str(my_survey_id)), 'partner_owner_recid': str(my_partner['recid']),'valide':'1', 'locked':'0'}
|
||||
|
||||
local_survey_retval = MYSY_GV.dbname['survey'].find_one(qry)
|
||||
|
||||
if(local_survey_retval is None ):
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " L'identifiant de l'inscrit est invalide ")
|
||||
return False, " L'identifiant de l'inscrit est invalide "
|
||||
|
||||
|
||||
courrier_ref_interne = ""
|
||||
if ( "survey_type" in local_survey_retval.keys() and local_survey_retval['survey_type'] == "pos"):
|
||||
courrier_ref_interne = "QUESTION_POSITIONNEMENT"
|
||||
|
||||
elif ( "survey_type" in local_survey_retval.keys() and local_survey_retval['survey_type'] == "hot_eval"):
|
||||
courrier_ref_interne = "EVAL_FORMATION"
|
||||
|
||||
elif ("survey_type" in local_survey_retval.keys() and local_survey_retval['survey_type'] == "cold_eval"):
|
||||
courrier_ref_interne = "EVAL_FORMATION"
|
||||
|
||||
elif ("survey_type" in local_survey_retval.keys() and local_survey_retval['survey_type'] == "human_eval"):
|
||||
courrier_ref_interne = "EVAL_RESSOURCE_HUMAINE"
|
||||
|
||||
elif ("survey_type" in local_survey_retval.keys() and local_survey_retval['survey_type'] == "autre_eval"):
|
||||
courrier_ref_interne = "EVAL_AUTRE"
|
||||
|
||||
else :
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " Le type d'enquete est invalide ")
|
||||
return False, " Le type d'enquete est invalide "
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Recuperation du modele de courrier (unique) associé à l'envoie des questions de positionnement
|
||||
le principe est de prendre le module du partenaire. si pas de modele du partenaire on
|
||||
prend le modele par default
|
||||
"""
|
||||
|
||||
courrier_template_model = MYSY_GV.dbname['courrier_template'].count_documents(
|
||||
{'ref_interne': str(courrier_ref_interne),
|
||||
partner_own_smtp_value = "0"
|
||||
partner_own_smtp = MYSY_GV.dbname['base_partner_setup'].find_one(
|
||||
{'partner_owner_recid': str(my_partner['recid']),
|
||||
'config_name': 'partner_smtp',
|
||||
'valide': '1',
|
||||
'locked': '0',
|
||||
'type_doc': 'email',
|
||||
'partner_owner_recid': str(my_partner['recid'])}
|
||||
)
|
||||
if (courrier_template_model == 1):
|
||||
courrier_template_data = MYSY_GV.dbname['courrier_template'].find_one(
|
||||
{'ref_interne': str(courrier_ref_interne),
|
||||
'valide': '1',
|
||||
'locked': '0',
|
||||
'type_doc': 'email',
|
||||
'partner_owner_recid': str(my_partner['recid'])}
|
||||
)
|
||||
'locked': '0'})
|
||||
|
||||
if (partner_own_smtp and "config_value" in partner_own_smtp.keys()):
|
||||
partner_own_smtp_value = partner_own_smtp['config_value']
|
||||
|
||||
if (str(partner_own_smtp_value) == "1"):
|
||||
partner_SMTP_COUNT_password = str(MYSY_GV.dbname['base_partner_setup'].find_one(
|
||||
{'partner_owner_recid': str(my_partner['recid']),
|
||||
'config_name': 'smtp_user_pwd',
|
||||
'valide': '1',
|
||||
'locked': '0'}, {'config_value': 1})['config_value'])
|
||||
|
||||
partner_SMTP_COUNT_smtpsrv = str(MYSY_GV.dbname['base_partner_setup'].find_one(
|
||||
{'partner_owner_recid': str(my_partner['recid']),
|
||||
'config_name': 'smtp_server',
|
||||
'valide': '1',
|
||||
'locked': '0'}, {'config_value': 1})['config_value'])
|
||||
|
||||
partner_SMTP_COUNT_user = str(MYSY_GV.dbname['base_partner_setup'].find_one(
|
||||
{'partner_owner_recid': str(my_partner['recid']),
|
||||
'config_name': 'smtp_user',
|
||||
'valide': '1',
|
||||
'locked': '0'}, {'config_value': 1})['config_value'])
|
||||
|
||||
partner_SMTP_COUNT_From_User = str(MYSY_GV.dbname['base_partner_setup'].find_one(
|
||||
{'partner_owner_recid': str(my_partner['recid']),
|
||||
'config_name': 'smtp_count_from_name',
|
||||
'valide': '1',
|
||||
'locked': '0'}, {'config_value': 1})['config_value'])
|
||||
|
||||
partner_SMTP_COUNT_port = str(MYSY_GV.dbname['base_partner_setup'].find_one(
|
||||
{'partner_owner_recid': str(my_partner['recid']),
|
||||
'config_name': 'smtp_count_port',
|
||||
'valide': '1',
|
||||
'locked': '0'}, {'config_value': 1})['config_value'])
|
||||
|
||||
|
||||
for my_survey_id in tab_my_survey_ids:
|
||||
# Recuperation des données de l'inscript
|
||||
|
||||
qry = { '_id':ObjectId(str(my_survey_id)), 'partner_owner_recid': str(my_partner['recid']),'valide':'1', 'locked':'0'}
|
||||
|
||||
local_survey_retval = MYSY_GV.dbname['survey'].find_one(qry)
|
||||
|
||||
if(local_survey_retval is None ):
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " L'identifiant de l'inscrit est invalide ")
|
||||
return False, " L'identifiant de l'inscrit est invalide "
|
||||
|
||||
|
||||
courrier_ref_interne = ""
|
||||
if ( "survey_type" in local_survey_retval.keys() and local_survey_retval['survey_type'] == "pos"):
|
||||
courrier_ref_interne = "QUESTION_POSITIONNEMENT"
|
||||
|
||||
elif ( "survey_type" in local_survey_retval.keys() and local_survey_retval['survey_type'] == "hot_eval"):
|
||||
courrier_ref_interne = "EVAL_FORMATION"
|
||||
|
||||
elif ("survey_type" in local_survey_retval.keys() and local_survey_retval['survey_type'] == "cold_eval"):
|
||||
courrier_ref_interne = "EVAL_FORMATION"
|
||||
|
||||
elif ("survey_type" in local_survey_retval.keys() and local_survey_retval['survey_type'] == "human_eval"):
|
||||
courrier_ref_interne = "EVAL_RESSOURCE_HUMAINE"
|
||||
|
||||
elif ("survey_type" in local_survey_retval.keys() and local_survey_retval['survey_type'] == "autre_eval"):
|
||||
courrier_ref_interne = "EVAL_AUTRE"
|
||||
|
||||
else :
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " Le type d'enquete est invalide ")
|
||||
return False, " Le type d'enquete est invalide "
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Recuperation du modele de courrier (unique) associé à l'envoie des questions de positionnement
|
||||
le principe est de prendre le module du partenaire. si pas de modele du partenaire on
|
||||
prend le modele par default
|
||||
"""
|
||||
|
||||
else:
|
||||
courrier_template_model = MYSY_GV.dbname['courrier_template'].count_documents(
|
||||
{'ref_interne': str(courrier_ref_interne),
|
||||
'valide': '1',
|
||||
'locked': '0',
|
||||
'type_doc': 'email',
|
||||
'partner_owner_recid': "default"}
|
||||
'partner_owner_recid': str(my_partner['recid'])}
|
||||
)
|
||||
if (courrier_template_model == 1):
|
||||
courrier_template_data = MYSY_GV.dbname['courrier_template'].find_one(
|
||||
{'ref_interne': str(courrier_ref_interne),
|
||||
'valide': '1',
|
||||
'locked': '0',
|
||||
'type_doc': 'email',
|
||||
'partner_owner_recid': str(my_partner['recid'])}
|
||||
)
|
||||
|
||||
else:
|
||||
courrier_template_model = MYSY_GV.dbname['courrier_template'].count_documents(
|
||||
{'ref_interne': str(courrier_ref_interne),
|
||||
'valide': '1',
|
||||
'locked': '0',
|
||||
'type_doc': 'email',
|
||||
'partner_owner_recid': "default"}
|
||||
)
|
||||
else:
|
||||
mycommon.myprint(str(
|
||||
inspect.stack()[0][
|
||||
3]) + " Aucun modèle de document configuré pour envoyer les demandes pour les questionnaires ")
|
||||
return False, " Aucun modèle de document configuré pour envoyer les demandes pour les questionnaires "
|
||||
if (courrier_template_model == 1):
|
||||
courrier_template_data = MYSY_GV.dbname['courrier_template'].find_one(
|
||||
{'ref_interne': str(courrier_ref_interne),
|
||||
'valide': '1',
|
||||
'locked': '0',
|
||||
'type_doc': 'email',
|
||||
'partner_owner_recid': "default"}
|
||||
)
|
||||
else:
|
||||
mycommon.myprint(str(
|
||||
inspect.stack()[0][
|
||||
3]) + " Aucun modèle de document configuré pour envoyer les demandes pour les questionnaires ")
|
||||
return False, " Aucun modèle de document configuré pour envoyer les demandes pour les questionnaires "
|
||||
|
||||
if ("contenu_doc" not in courrier_template_data.keys() or str(
|
||||
courrier_template_data['contenu_doc']).strip() == ""):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " Le modèle de document ne contient pas de valeur 'contenu_doc' ")
|
||||
return False, " Le modèle de document ne contient pas de valeur 'contenu_doc' "
|
||||
|
||||
"""print(" ### courrier_ref_interne = ", courrier_ref_interne)
|
||||
print(" ### local_survey_retval['survey_type'] = ", local_survey_retval['survey_type'])
|
||||
print(" ### courrier_template_data[id]= ", str(courrier_template_data['_id']))"""
|
||||
|
||||
|
||||
contenu_doc_Template = jinja2.Template(str(courrier_template_data['contenu_doc']))
|
||||
# Creation du dictionnaire d'information à utiliser pour la creation du doc
|
||||
convention_dictionnary_data = {}
|
||||
new_diction = {}
|
||||
new_diction['token'] = my_partner['token']
|
||||
|
||||
is_apprenant = 0
|
||||
new_diction['list_stagiaire_id'] = []
|
||||
if( "inscription_id" in local_survey_retval.keys() and local_survey_retval['inscription_id']):
|
||||
new_diction['list_stagiaire_id'].append(ObjectId(str( local_survey_retval['inscription_id'])))
|
||||
|
||||
|
||||
new_diction['list_session_id'] = []
|
||||
if ("session_id" in local_survey_retval.keys() and local_survey_retval['session_id']):
|
||||
new_diction['list_session_id'].append(ObjectId(str(local_survey_retval['session_id'])))
|
||||
|
||||
new_diction['list_class_id'] = []
|
||||
if ("class_id" in local_survey_retval.keys() and local_survey_retval['class_id']):
|
||||
new_diction['list_class_id'].append(ObjectId(str(local_survey_retval['class_id'])))
|
||||
|
||||
|
||||
new_diction['list_client_id'] = []
|
||||
new_diction['list_apprenant_id'] = []
|
||||
|
||||
|
||||
|
||||
local_status, local_retval = mycommon.Get_Dictionnary_data_For_Template(new_diction)
|
||||
|
||||
if (local_status is False):
|
||||
return local_status, local_retval
|
||||
|
||||
convention_dictionnary_data = local_retval
|
||||
|
||||
servey_url = MYSY_GV.CLIENT_URL_BASE + "Survey/" + str(local_survey_retval['_id'])
|
||||
|
||||
convention_dictionnary_data["servey_url"] = str(servey_url)
|
||||
convention_dictionnary_data["servey_email"] = str(local_survey_retval['email'])
|
||||
convention_dictionnary_data["servey_nom"] = str(local_survey_retval['nom'])
|
||||
convention_dictionnary_data["servey_prenom"] =str(local_survey_retval['prenom'])
|
||||
|
||||
|
||||
body = {
|
||||
"params": convention_dictionnary_data
|
||||
}
|
||||
|
||||
|
||||
|
||||
html = contenu_doc_Template.render(params=body["params"])
|
||||
|
||||
subject_doc_Template = jinja2.Template(str(courrier_template_data['sujet']))
|
||||
subject = subject_doc_Template.render(params=body["params"])
|
||||
|
||||
|
||||
html_mime = MIMEText(html, 'html')
|
||||
|
||||
# Creation de l'email à enoyer
|
||||
msg = MIMEMultipart("alternative")
|
||||
|
||||
if (str(partner_own_smtp_value) == "1"):
|
||||
smtpserver = smtplib.SMTP(partner_SMTP_COUNT_smtpsrv, partner_SMTP_COUNT_port)
|
||||
else:
|
||||
smtpserver = smtplib.SMTP(MYSY_GV.O365_SMTP_COUNT_smtpsrv, MYSY_GV.O365_SMTP_COUNT_port)
|
||||
|
||||
|
||||
if (str(partner_own_smtp_value) == "1"):
|
||||
msg.attach(html_mime)
|
||||
msg['From'] = partner_SMTP_COUNT_From_User
|
||||
msg['Bcc'] = 'contact@mysy-training.com'
|
||||
msg['Subject'] = str(subject)
|
||||
# msg['to'] = "billardman01@hotmail.com"
|
||||
|
||||
msg['to'] = str(local_survey_retval['email'])
|
||||
|
||||
smtpserver.ehlo()
|
||||
smtpserver.starttls()
|
||||
smtpserver.login(partner_SMTP_COUNT_user, partner_SMTP_COUNT_password)
|
||||
|
||||
else:
|
||||
msg.attach(html_mime)
|
||||
msg['From'] = MYSY_GV.O365_SMTP_COUNT_From_User
|
||||
msg['Bcc'] = 'contact@mysy-training.com'
|
||||
msg['Subject'] = str(subject)
|
||||
# msg['to'] = "billardman01@hotmail.com"
|
||||
|
||||
msg['to'] = str(local_survey_retval['email'])
|
||||
|
||||
smtpserver.ehlo()
|
||||
smtpserver.starttls()
|
||||
smtpserver.login(MYSY_GV.O365_SMTP_COUNT_user, MYSY_GV.O365_SMTP_COUNT_password)
|
||||
|
||||
val = smtpserver.send_message(msg)
|
||||
smtpserver.close()
|
||||
print(" Email envoyé " + str(val))
|
||||
|
||||
"""
|
||||
Mettre à jour l'enquete pour dire que c'est envoyé
|
||||
"""
|
||||
now = str(datetime.now())
|
||||
|
||||
qry = {'_id': ObjectId(str(my_survey_id)), 'partner_owner_recid': str(my_partner['recid']),
|
||||
'valide': '1', 'locked': '0'}
|
||||
result = MYSY_GV.dbname['survey'].find_one_and_update(qry,
|
||||
{'$set':{'statut':'1', 'date_update':str(now),
|
||||
'update_by':str(my_partner['_id']),
|
||||
'date_envoi':now}}
|
||||
)
|
||||
|
||||
courrier_ref_interne = ""
|
||||
if ("survey_type" in result.keys() and result['survey_type'] == "pos"):
|
||||
courrier_ref_interne = "QUESTION_POSITIONNEMENT"
|
||||
|
||||
elif ("survey_type" in result.keys() and result['survey_type'] == "hot_eval"):
|
||||
courrier_ref_interne = "EVAL_FORMATION"
|
||||
|
||||
elif ("survey_type" in result.keys() and result['survey_type'] == "cold_eval"):
|
||||
courrier_ref_interne = "EVAL_FORMATION"
|
||||
|
||||
elif ("survey_type" in local_survey_retval.keys() and local_survey_retval['survey_type'] == "human_eval"):
|
||||
courrier_ref_interne = "EVAL_RESSOURCE_HUMAINE"
|
||||
|
||||
elif ("survey_type" in local_survey_retval.keys() and local_survey_retval['survey_type'] == "autre_eval"):
|
||||
courrier_ref_interne = "EVAL_AUTRE"
|
||||
|
||||
else:
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " Le type d'enquete est invalide ")
|
||||
return False, " Le type d'enquete est invalide "
|
||||
|
||||
"""
|
||||
Apres que l'envoie est fait, on va loguer le traitement dans la collection : courrier_template_tracking_history
|
||||
"""
|
||||
if( "inscription_id" in local_survey_retval.keys() ):
|
||||
# Cette demande d'enquete concerne une inscription
|
||||
local_inscription_id = local_survey_retval['inscription_id']
|
||||
|
||||
qry = {'_id': ObjectId(str(local_inscription_id)),
|
||||
'status': '1',
|
||||
'partner_owner_recid': str(my_partner['recid'])}
|
||||
|
||||
#print(" ### qry 010101 = ", qry)
|
||||
|
||||
inscription_data = MYSY_GV.dbname['inscription'].find_one({'_id': ObjectId(str(local_inscription_id)),
|
||||
'status': '1',
|
||||
'partner_owner_recid': str(my_partner['recid'])})
|
||||
|
||||
|
||||
if( inscription_data is None or "session_id" not in inscription_data.keys() ):
|
||||
if ("contenu_doc" not in courrier_template_data.keys() or str(
|
||||
courrier_template_data['contenu_doc']).strip() == ""):
|
||||
mycommon.myprint(
|
||||
" WARNING : Impossible de logguer l'historique pour l'inscrit : " + str(local_inscription_id))
|
||||
str(inspect.stack()[0][3]) + " Le modèle de document ne contient pas de valeur 'contenu_doc' ")
|
||||
return False, " Le modèle de document ne contient pas de valeur 'contenu_doc' "
|
||||
|
||||
#print(" inscription_data = ", inscription_data)
|
||||
"""print(" ### courrier_ref_interne = ", courrier_ref_interne)
|
||||
print(" ### local_survey_retval['survey_type'] = ", local_survey_retval['survey_type'])
|
||||
print(" ### courrier_template_data[id]= ", str(courrier_template_data['_id']))"""
|
||||
|
||||
|
||||
contenu_doc_Template = jinja2.Template(str(courrier_template_data['contenu_doc']))
|
||||
# Creation du dictionnaire d'information à utiliser pour la creation du doc
|
||||
convention_dictionnary_data = {}
|
||||
new_diction = {}
|
||||
new_diction['token'] = my_partner['token']
|
||||
|
||||
is_apprenant = 0
|
||||
new_diction['list_stagiaire_id'] = []
|
||||
if( "inscription_id" in local_survey_retval.keys() and local_survey_retval['inscription_id']):
|
||||
new_diction['list_stagiaire_id'].append(ObjectId(str( local_survey_retval['inscription_id'])))
|
||||
|
||||
|
||||
new_diction['list_session_id'] = []
|
||||
if ("session_id" in local_survey_retval.keys() and local_survey_retval['session_id']):
|
||||
new_diction['list_session_id'].append(ObjectId(str(local_survey_retval['session_id'])))
|
||||
|
||||
new_diction['list_class_id'] = []
|
||||
if ("class_id" in local_survey_retval.keys() and local_survey_retval['class_id']):
|
||||
new_diction['list_class_id'].append(ObjectId(str(local_survey_retval['class_id'])))
|
||||
|
||||
|
||||
new_diction['list_client_id'] = []
|
||||
new_diction['list_apprenant_id'] = []
|
||||
|
||||
|
||||
|
||||
local_status, local_retval = mycommon.Get_Dictionnary_data_For_Template(new_diction)
|
||||
|
||||
local_status, local_retval = module_editique.Editic_Log_History_Action_From_courrier_template_type_document_ref_interne(
|
||||
my_partner, str(courrier_ref_interne), str(inscription_data['session_id']), 'inscription',
|
||||
str(local_inscription_id),"")
|
||||
if (local_status is False):
|
||||
mycommon.myprint(
|
||||
" WARNING : Impossible de logguer l'historique pour l'inscrit (2) : " + str(local_inscription_id))
|
||||
return local_status, local_retval
|
||||
|
||||
convention_dictionnary_data = local_retval
|
||||
|
||||
servey_url = MYSY_GV.CLIENT_URL_BASE + "Survey/" + str(local_survey_retval['_id'])
|
||||
|
||||
convention_dictionnary_data["servey_url"] = str(servey_url)
|
||||
convention_dictionnary_data["servey_email"] = str(local_survey_retval['email'])
|
||||
convention_dictionnary_data["servey_nom"] = str(local_survey_retval['nom'])
|
||||
convention_dictionnary_data["servey_prenom"] =str(local_survey_retval['prenom'])
|
||||
|
||||
|
||||
body = {
|
||||
"params": convention_dictionnary_data
|
||||
}
|
||||
|
||||
|
||||
|
||||
html = contenu_doc_Template.render(params=body["params"])
|
||||
|
||||
subject_doc_Template = jinja2.Template(str(courrier_template_data['sujet']))
|
||||
subject = subject_doc_Template.render(params=body["params"])
|
||||
|
||||
|
||||
html_mime = MIMEText(html, 'html')
|
||||
|
||||
# Creation de l'email à enoyer
|
||||
msg = MIMEMultipart("alternative")
|
||||
|
||||
if (str(partner_own_smtp_value) == "1"):
|
||||
smtpserver = smtplib.SMTP(partner_SMTP_COUNT_smtpsrv, partner_SMTP_COUNT_port)
|
||||
else:
|
||||
smtpserver = smtplib.SMTP(MYSY_GV.O365_SMTP_COUNT_smtpsrv, MYSY_GV.O365_SMTP_COUNT_port)
|
||||
|
||||
|
||||
if (str(partner_own_smtp_value) == "1"):
|
||||
msg.attach(html_mime)
|
||||
msg['From'] = partner_SMTP_COUNT_From_User
|
||||
msg['Bcc'] = 'contact@mysy-training.com'
|
||||
msg['Subject'] = str(subject)
|
||||
# msg['to'] = "billardman01@hotmail.com"
|
||||
|
||||
msg['to'] = str(local_survey_retval['email'])
|
||||
|
||||
smtpserver.ehlo()
|
||||
smtpserver.starttls()
|
||||
smtpserver.login(partner_SMTP_COUNT_user, partner_SMTP_COUNT_password)
|
||||
|
||||
else:
|
||||
msg.attach(html_mime)
|
||||
msg['From'] = MYSY_GV.O365_SMTP_COUNT_From_User
|
||||
msg['Bcc'] = 'contact@mysy-training.com'
|
||||
msg['Subject'] = str(subject)
|
||||
# msg['to'] = "billardman01@hotmail.com"
|
||||
|
||||
msg['to'] = str(local_survey_retval['email'])
|
||||
|
||||
smtpserver.ehlo()
|
||||
smtpserver.starttls()
|
||||
smtpserver.login(MYSY_GV.O365_SMTP_COUNT_user, MYSY_GV.O365_SMTP_COUNT_password)
|
||||
|
||||
val = smtpserver.send_message(msg)
|
||||
smtpserver.close()
|
||||
print(" Email envoyé " + str(val))
|
||||
|
||||
"""
|
||||
Mettre à jour l'enquete pour dire que c'est envoyé
|
||||
"""
|
||||
now = str(datetime.now())
|
||||
|
||||
qry = {'_id': ObjectId(str(my_survey_id)), 'partner_owner_recid': str(my_partner['recid']),
|
||||
'valide': '1', 'locked': '0'}
|
||||
result = MYSY_GV.dbname['survey'].find_one_and_update(qry,
|
||||
{'$set':{'statut':'1', 'date_update':str(now),
|
||||
'update_by':str(my_partner['_id']),
|
||||
'date_envoi':now,
|
||||
'date_dernier_relance_auto':str(datetime.now().strftime("%d/%m/%Y"))}
|
||||
}
|
||||
)
|
||||
|
||||
courrier_ref_interne = ""
|
||||
if ("survey_type" in result.keys() and result['survey_type'] == "pos"):
|
||||
courrier_ref_interne = "QUESTION_POSITIONNEMENT"
|
||||
|
||||
elif ("survey_type" in result.keys() and result['survey_type'] == "hot_eval"):
|
||||
courrier_ref_interne = "EVAL_FORMATION"
|
||||
|
||||
elif ("survey_type" in result.keys() and result['survey_type'] == "cold_eval"):
|
||||
courrier_ref_interne = "EVAL_FORMATION"
|
||||
|
||||
elif ("survey_type" in local_survey_retval.keys() and local_survey_retval['survey_type'] == "human_eval"):
|
||||
courrier_ref_interne = "EVAL_RESSOURCE_HUMAINE"
|
||||
|
||||
elif ("survey_type" in local_survey_retval.keys() and local_survey_retval['survey_type'] == "autre_eval"):
|
||||
courrier_ref_interne = "EVAL_AUTRE"
|
||||
|
||||
else:
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " Le type d'enquete est invalide ")
|
||||
return False, " Le type d'enquete est invalide "
|
||||
|
||||
"""
|
||||
Apres que l'envoie est fait, on va loguer le traitement dans la collection : courrier_template_tracking_history
|
||||
"""
|
||||
if( "inscription_id" in local_survey_retval.keys() ):
|
||||
# Cette demande d'enquete concerne une inscription
|
||||
local_inscription_id = local_survey_retval['inscription_id']
|
||||
|
||||
qry = {'_id': ObjectId(str(local_inscription_id)),
|
||||
'status': '1',
|
||||
'partner_owner_recid': str(my_partner['recid'])}
|
||||
|
||||
#print(" ### qry 010101 = ", qry)
|
||||
|
||||
inscription_data = MYSY_GV.dbname['inscription'].find_one({'_id': ObjectId(str(local_inscription_id)),
|
||||
'status': '1',
|
||||
'partner_owner_recid': str(my_partner['recid'])})
|
||||
|
||||
|
||||
if( inscription_data is None or "session_id" not in inscription_data.keys() ):
|
||||
mycommon.myprint(
|
||||
" WARNING : Impossible de logguer l'historique pour l'inscrit : " + str(local_inscription_id))
|
||||
|
||||
#print(" inscription_data = ", inscription_data)
|
||||
|
||||
local_status, local_retval = module_editique.Editic_Log_History_Action_From_courrier_template_type_document_ref_interne(
|
||||
my_partner, str(courrier_ref_interne), str(inscription_data['session_id']), 'inscription',
|
||||
str(local_inscription_id),"")
|
||||
if (local_status is False):
|
||||
mycommon.myprint(
|
||||
" WARNING : Impossible de logguer l'historique pour l'inscrit (2) : " + str(local_inscription_id))
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue