21/07/2024 - 12h
parent
a0ac2664b3
commit
abd8f3b7bb
|
@ -1,11 +1,13 @@
|
|||
<?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="17/07/2024 - 11h30">
|
||||
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="17/07/2024 - 11h30sdf">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" 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$/ressources_humaines.py" beforeDir="false" afterPath="$PROJECT_DIR$/ressources_humaines.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/user_access_right.py" beforeDir="false" afterPath="$PROJECT_DIR$/user_access_right.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Session_Formation.py" beforeDir="false" afterPath="$PROJECT_DIR$/Session_Formation.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/ela_user_account.py" beforeDir="false" afterPath="$PROJECT_DIR$/ela_user_account.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.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" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
|
@ -75,13 +77,6 @@
|
|||
<option name="presentableId" value="Default" />
|
||||
<updated>1680804787304</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00306" summary="19/05/2024 - 22h15">
|
||||
<created>1716149736394</created>
|
||||
<option name="number" value="00306" />
|
||||
<option name="presentableId" value="LOCAL-00306" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1716149736394</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00307" summary="20/05/2024 - 14h00">
|
||||
<created>1716206194944</created>
|
||||
<option name="number" value="00307" />
|
||||
|
@ -418,7 +413,14 @@
|
|||
<option name="project" value="LOCAL" />
|
||||
<updated>1721207839114</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="355" />
|
||||
<task id="LOCAL-00355" summary="17/07/2024 - 11h30sdf">
|
||||
<created>1721461819238</created>
|
||||
<option name="number" value="00355" />
|
||||
<option name="presentableId" value="LOCAL-00355" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1721461819239</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="356" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="Vcs.Log.Tabs.Properties">
|
||||
|
@ -460,7 +462,6 @@
|
|||
</option>
|
||||
</component>
|
||||
<component name="VcsManagerConfiguration">
|
||||
<MESSAGE value="07/06/2024 - 22h30" />
|
||||
<MESSAGE value="ssq" />
|
||||
<MESSAGE value="qqsd" />
|
||||
<MESSAGE value="11/06/2024 - 23h30" />
|
||||
|
@ -485,6 +486,7 @@
|
|||
<MESSAGE value="dqsdqs" />
|
||||
<MESSAGE value="dqsdqss" />
|
||||
<MESSAGE value="17/07/2024 - 11h30" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="17/07/2024 - 11h30" />
|
||||
<MESSAGE value="17/07/2024 - 11h30sdf" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="17/07/2024 - 11h30sdf" />
|
||||
</component>
|
||||
</project>
|
10857
Log/log_file.log
10857
Log/log_file.log
File diff suppressed because one or more lines are too long
|
@ -6148,7 +6148,7 @@ def Create_Convocation_By_Stagiaire_PDF(diction):
|
|||
"""
|
||||
25/01/2024 : pour loger une action dans la collection ==> courrier_template_tracking_history
|
||||
"""
|
||||
print(" str(diction['inscription_id']) == ", str(diction['inscription_id']))
|
||||
#print(" str(diction['inscription_id']) == ", str(diction['inscription_id']))
|
||||
""" local_status, local_retval = module_editique.Editic_Log_History_Action(my_partner, template_courrier_data,
|
||||
str(diction['session_id']), 'inscription', str(diction['inscription_id']))
|
||||
"""
|
||||
|
|
|
@ -1131,8 +1131,7 @@ def Reset_user_pwd_by_token(diction):
|
|||
return True, "Le mot de passe a bien été mise à jour "
|
||||
else:
|
||||
mycommon.myprint(str(
|
||||
inspect.stack()[0][3]) + " Impossible de mettre à jour le password du user : recid = " + str(
|
||||
user_recid))
|
||||
inspect.stack()[0][3]) + " Impossible de mettre à jour le password du user : recid ")
|
||||
return False, "Impossible de mettre à jour le mot de passe"
|
||||
|
||||
except Exception as e:
|
||||
|
|
19
main.py
19
main.py
|
@ -10304,6 +10304,25 @@ def Delete_Inscription_Split_Invoice():
|
|||
|
||||
|
||||
|
||||
"""
|
||||
API qui recuperer les reponses d'un survey donné dans une fichier pdf
|
||||
"""
|
||||
@app.route('/myclass/api/Export_To_Excel_Survey_with_filter_Tab_Survey_Id/<token>/<tab_ids>', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Export_To_Excel_Survey_with_filter_Tab_Survey_Id(token, tab_ids):
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary(request.form.to_dict())
|
||||
payload = {}
|
||||
payload['token'] = str(token)
|
||||
payload['tab_ids'] = str(tab_ids)
|
||||
|
||||
print(" ### Export_To_Excel_Survey_with_filter_Tab_Survey_Id payload = ",payload)
|
||||
localStatus, response = survey_mgt.Export_To_Excel_Survey_with_filter_Tab_Survey_Id(payload)
|
||||
if (localStatus):
|
||||
return response
|
||||
else:
|
||||
return False
|
||||
|
||||
"""
|
||||
API permet de faire des statistiques ou de projections graphiques sur
|
||||
sur des reponses, par exemple la moyenne de satisfaction par rapport
|
||||
|
|
451
survey_mgt.py
451
survey_mgt.py
|
@ -3,6 +3,7 @@ Ce document permet de gerer les "enquetes" avec utilisation des formulaires
|
|||
|
||||
"""
|
||||
import ast
|
||||
from zipfile import ZipFile
|
||||
|
||||
import bson
|
||||
import pymongo
|
||||
|
@ -1092,6 +1093,8 @@ def Create_One_Survey_To_Except_Inscrit(diction):
|
|||
|
||||
"""
|
||||
Cette fonction permet d'envoyer la demande d'enquete à la personne concerné
|
||||
|
||||
|
||||
/!\ : Cette fontion permet d'envoyer toutes les demande d'enquete, que soit :
|
||||
un questionnaire de positionnement, une demande d'evaluation a chaud,
|
||||
une demande d'evaluation à froid, ou tout autre.
|
||||
|
@ -1106,6 +1109,8 @@ par exemple :
|
|||
- si survey.survey_type == 'hot_eval' ==> courrier_template_type_document_ref_interne = "EVAL_FORMATION" et
|
||||
courrier_template.ref_interne = EVAL_FORMATION.
|
||||
|
||||
/!\ : 21/07/2024 : Dans le cas d'un Renvoi, on va desactiver la question precedenmment envoyée.
|
||||
|
||||
"""
|
||||
|
||||
def Send_Survey_TabIds(diction):
|
||||
|
@ -1433,11 +1438,18 @@ def Send_Survey_TabIds(diction):
|
|||
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}}
|
||||
{
|
||||
'$unset': {
|
||||
'user_response' : "",
|
||||
'date_reponse' : ""
|
||||
},
|
||||
'$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"
|
||||
|
@ -1471,20 +1483,19 @@ def Send_Survey_TabIds(diction):
|
|||
|
||||
#print(" ### qry 010101 = ", qry)
|
||||
|
||||
print(" #### str(local_survey_retval['related_collection']) = ", str(local_survey_retval['related_collection']))
|
||||
#print(" #### str(local_survey_retval['related_collection']) = ", str(local_survey_retval['related_collection']))
|
||||
|
||||
|
||||
partner_owner_recid = "partner_owner_recid"
|
||||
if( str(local_survey_retval['related_collection']) == "ressource_humaine"):
|
||||
partner_owner_recid = "partner_recid"
|
||||
|
||||
print(" #### str(local_survey_retval['related_collection']) = ",
|
||||
str(local_survey_retval['related_collection']))
|
||||
|
||||
print(" #### qry = ",
|
||||
""" print(" #### str(local_survey_retval['related_collection']) = ", str(local_survey_retval['related_collection']))
|
||||
"""
|
||||
"""print(" #### qry = ",
|
||||
{'_id': ObjectId(str(local_inscription_id)),
|
||||
'valide': '1',
|
||||
str(partner_owner_recid): str(my_partner['recid'])})
|
||||
str(partner_owner_recid): str(my_partner['recid'])})"""
|
||||
|
||||
inscription_data = MYSY_GV.dbname[str(local_survey_retval['related_collection'])].find_one({'_id': ObjectId(str(local_inscription_id)),
|
||||
'valide': '1',
|
||||
|
@ -2343,6 +2354,428 @@ def Export_To_Excel_Survey_with_filter(diction):
|
|||
return False, " Impossible de générer l'export "
|
||||
|
||||
|
||||
"""
|
||||
Cette fonction pour exporter les resultat d'une enquete dans une fichier excel :
|
||||
POUR UNE LISTE _ID
|
||||
"""
|
||||
def Export_To_Excel_Survey_with_filter_Tab_Survey_Id(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', 'tab_ids' ]
|
||||
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
if val not in field_list and val.startswith('my_') is False:
|
||||
mycommon.myprint(str(
|
||||
inspect.stack()[0][3]) + " Le champ '" + val + "' n'est pas autorisé")
|
||||
return False, " Les informations fournies sont incorrectes"
|
||||
|
||||
"""
|
||||
Verification des champs obligatoires
|
||||
"""
|
||||
field_list_obligatoire = ['token', 'tab_ids']
|
||||
|
||||
for val in field_list_obligatoire:
|
||||
if val not in diction:
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " - La valeur '" + val + "' n'est pas presente dans liste ")
|
||||
return False, " Les informations fournies sont incorrectes"
|
||||
|
||||
"""
|
||||
Verification de l'identité et autorisation de l'entité qui
|
||||
appelle cette API
|
||||
"""
|
||||
token = ""
|
||||
if ("token" in diction.keys()):
|
||||
if diction['token']:
|
||||
token = diction['token']
|
||||
|
||||
local_status, my_partner = mycommon.Check_Connexion_And_Return_Partner_Data(diction)
|
||||
if (local_status is not True):
|
||||
return local_status, my_partner
|
||||
|
||||
my_survey_ids = ""
|
||||
if ("tab_ids" in diction.keys()):
|
||||
if diction['tab_ids']:
|
||||
my_survey_ids = diction['tab_ids']
|
||||
|
||||
|
||||
|
||||
my_survey_ids = my_survey_ids.replace(".", ",")
|
||||
tab_my_survey_ids = str(my_survey_ids).split(",")
|
||||
tab_my_survey_ids = [s.strip() for s in tab_my_survey_ids]
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Verifier la validité des survey
|
||||
"""
|
||||
for my_survey_id in tab_my_survey_ids:
|
||||
|
||||
# Verifier qui la formation n'a pas deja été evaluée
|
||||
tmp_count = MYSY_GV.dbname['survey'].count_documents({'_id':ObjectId(str(my_survey_id)),
|
||||
'partner_owner_recid': str(my_partner['recid']),
|
||||
'valide':'1',
|
||||
'locked':'0'
|
||||
})
|
||||
|
||||
|
||||
|
||||
if (tmp_count != 1):
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " L'identifiant de l'enquête "+str(my_survey_id) +" est invalide ")
|
||||
return False, " L'identifiant de l'enquête "+str(my_survey_id) +" est invalide "
|
||||
|
||||
|
||||
|
||||
|
||||
filt_session_id = {}
|
||||
if ("session_id" in diction.keys()):
|
||||
filt_session_id = {'session_id': str(diction['session_id'])}
|
||||
|
||||
filt_related_collection = {}
|
||||
if ("related_collection" in diction.keys()):
|
||||
filt_related_collection = {'related_collection': str(diction['related_collection'])}
|
||||
|
||||
filt_related_collection_id = {}
|
||||
if ("related_collection_id" in diction.keys()):
|
||||
related_collection_id = {'related_collection_id': str(diction['related_collection_id'])}
|
||||
|
||||
RetObject = []
|
||||
val_tmp = 0
|
||||
|
||||
|
||||
ts = datetime.now().timestamp()
|
||||
ts = str(ts).replace(".", "").replace(",", "")[-5:]
|
||||
|
||||
orig_file_name = "Export_Reponse_" + str(ts) + ".xlsx"
|
||||
outputFilename = str(MYSY_GV.TEMPORARY_DIRECTORY) + "/" + str(orig_file_name)
|
||||
|
||||
tab_exported_fields_header = ["formation", "code_session", "date_debut_session",
|
||||
"date_fin_session", "email", "nom", "prenom", "type questionnaire", "date_envoi",
|
||||
"date_reponse", "question", "reponse"]
|
||||
|
||||
tab_exported_fields = ["formation", "code_session", "date_debut_session",
|
||||
"date_fin_session", "email", "nom", "prenom", "date_envoi",
|
||||
"date_reponse", "question", "reponse"]
|
||||
|
||||
""""
|
||||
Pour créer le document PDF, on va recuperer les données du Get_Dictionnary_data_For_Template
|
||||
"""
|
||||
new_diction = {}
|
||||
new_diction['token'] = diction['token']
|
||||
new_diction['list_stagiaire_id'] = []
|
||||
new_diction['list_session_id'] = []
|
||||
new_diction['list_class_id'] = []
|
||||
new_diction['list_client_id'] = []
|
||||
|
||||
local_status, local_retval = mycommon.Get_Dictionnary_data_For_Template(new_diction)
|
||||
|
||||
if (local_status is False):
|
||||
return local_status, local_retval
|
||||
|
||||
convention_dictionnary_data = local_retval
|
||||
|
||||
|
||||
"""
|
||||
Recuperer le modèle de document
|
||||
"""
|
||||
local_diction = {}
|
||||
local_diction['ref_interne'] = "EVALUATION_MODEL_PDF"
|
||||
local_diction['type_doc'] = "pdf"
|
||||
local_diction['partner_owner_recid'] = str(my_partner['recid'])
|
||||
|
||||
courrier_data_status, courrier_data_retval = mycommon.Get_Courrier_Template_Include_Default_Data(local_diction)
|
||||
if (courrier_data_status is False):
|
||||
return courrier_data_status, courrier_data_retval
|
||||
|
||||
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 'EVALUATION_MODEL_PDF' n'est pas correctement configuré ")
|
||||
return False, " Le modèle de courrier 'EVALUATION_MODEL_PDF' n'est pas correctement configuré "
|
||||
|
||||
# Stokage des nom de fichier à zipper
|
||||
list_file_name_to_zip = []
|
||||
|
||||
"""
|
||||
Creation des data du fichier excel
|
||||
"""
|
||||
for my_survey_id in tab_my_survey_ids:
|
||||
qry = {"partner_owner_recid": str(my_partner['recid']), 'valide': '1', 'locked': '0',
|
||||
'_id':ObjectId(str(my_survey_id))}
|
||||
query_with_filter = {'$and': [qry, filt_session_id, filt_related_collection, filt_related_collection_id]}
|
||||
|
||||
#print(" ## qry = ", qry)
|
||||
#print(" ## my_survey_id = ", my_survey_id)
|
||||
|
||||
pipe_qry = ([
|
||||
{'$match': query_with_filter},
|
||||
{'$project': {'valide': 0, 'locked': 0, }},
|
||||
{'$lookup': {
|
||||
'from': 'formulaire',
|
||||
"let": {'formulaire_id': "$formulaire_id",
|
||||
'partner_owner_recid': '$partner_owner_recid'},
|
||||
'pipeline': [
|
||||
{'$match':
|
||||
{'$expr':
|
||||
{'$and':
|
||||
[
|
||||
|
||||
{'$eq': ["$_id", {'$convert': {
|
||||
'input': "$$formulaire_id",
|
||||
'to': "objectId",
|
||||
'onError': {'error': 'true'},
|
||||
'onNull': {'isnull': 'true'}
|
||||
}}]},
|
||||
|
||||
{'$eq': ["$valide", "1"]},
|
||||
|
||||
{'$eq': ["$partner_owner_recid", '$$partner_owner_recid']}
|
||||
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
],
|
||||
'as': 'formulaire'
|
||||
}
|
||||
},
|
||||
{
|
||||
'$unwind': '$formulaire'
|
||||
}
|
||||
])
|
||||
|
||||
#print(" ### Export_To_Excel_Survey_with_filter_Tab_Survey_Id pipe_qry = ", pipe_qry)
|
||||
|
||||
for Survey_Data in MYSY_GV.dbname['survey'].aggregate(pipe_qry):
|
||||
|
||||
param_survey_data = {}
|
||||
|
||||
|
||||
"""
|
||||
Recuperer les données de la session
|
||||
"""
|
||||
my_session_data = MYSY_GV.dbname['session_formation'].find_one(
|
||||
{'_id': ObjectId(str(Survey_Data['session_id'])),
|
||||
'valide': '1',
|
||||
'partner_owner_recid': str(my_partner['recid'])})
|
||||
|
||||
if (my_session_data is None):
|
||||
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 "
|
||||
|
||||
|
||||
"""
|
||||
Recuperer les données de la formation
|
||||
"""
|
||||
my_class_data = MYSY_GV.dbname['myclass'].find_one(
|
||||
{'_id': ObjectId(str(Survey_Data['class_id'])),
|
||||
'valide': '1',
|
||||
'partner_owner_recid': str(
|
||||
my_partner['recid'])}, {'title': 1})
|
||||
|
||||
if (my_class_data is None):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " L'identifiant de la formation est invalide ")
|
||||
return False, " L'identifiant de la formation est invalide "
|
||||
|
||||
|
||||
# Champ : Titre de la formation
|
||||
no_html_title = ""
|
||||
if ("title" in my_class_data.keys()):
|
||||
no_html_title = my_class_data['title']
|
||||
param_survey_data['class_title'] = my_class_data['title']
|
||||
|
||||
|
||||
# Champ : Code session
|
||||
code_session = ""
|
||||
if ("code_session" in my_session_data.keys()):
|
||||
code_session = my_session_data['code_session']
|
||||
param_survey_data['code_session'] = my_session_data['code_session']
|
||||
|
||||
|
||||
|
||||
# Champ : Date debut session
|
||||
date_debut_session = ""
|
||||
if ("code_session" in my_session_data.keys()):
|
||||
date_debut_session = my_session_data['date_debut']
|
||||
param_survey_data['session_date_debut'] = my_session_data['date_debut']
|
||||
|
||||
|
||||
|
||||
# Champ : Date fin session
|
||||
date_fin_session = ""
|
||||
if ("date_fin" in my_session_data.keys()):
|
||||
date_fin_session = my_session_data['date_fin']
|
||||
param_survey_data['session_date_fin'] = my_session_data['date_fin']
|
||||
|
||||
|
||||
|
||||
# Champ : Email
|
||||
email = ""
|
||||
if ("email" in Survey_Data.keys()):
|
||||
email = Survey_Data['email']
|
||||
param_survey_data['email'] = Survey_Data['email']
|
||||
|
||||
|
||||
# Champ : nom
|
||||
nom = ""
|
||||
if ("nom" in Survey_Data.keys()):
|
||||
nom = Survey_Data['nom']
|
||||
param_survey_data['nom'] = Survey_Data['nom']
|
||||
|
||||
|
||||
|
||||
# Champ : prenom
|
||||
prenom = ""
|
||||
if ("prenom" in Survey_Data.keys()):
|
||||
prenom = Survey_Data['prenom']
|
||||
param_survey_data['prenom'] = Survey_Data['prenom']
|
||||
|
||||
|
||||
# Champ : date_envoi
|
||||
date_envoi = ""
|
||||
if ("date_envoi" in Survey_Data.keys()):
|
||||
date_envoi = str(Survey_Data['date_envoi'])[0:16]
|
||||
|
||||
param_survey_data['date_envoi'] = str(date_envoi)
|
||||
|
||||
|
||||
# Champ : date_reponse
|
||||
date_reponse = ""
|
||||
if ("date_reponse" in Survey_Data.keys()):
|
||||
date_reponse = str(Survey_Data['date_reponse'])[0:16]
|
||||
|
||||
|
||||
param_survey_data['date_reponse'] = str(date_reponse)
|
||||
|
||||
|
||||
# Gestion des question et reponse
|
||||
param_survey_data['question_reponse'] = []
|
||||
|
||||
if( "user_response" in Survey_Data.keys() ):
|
||||
|
||||
question_num = 1
|
||||
for user_response in Survey_Data['user_response']:
|
||||
node_question_reponse = {}
|
||||
|
||||
question = ""
|
||||
if ("question" in user_response.keys()):
|
||||
question = str(user_response['question'])
|
||||
|
||||
|
||||
|
||||
node_question_reponse['question'] = question
|
||||
|
||||
response = ""
|
||||
if ("response" in user_response.keys()):
|
||||
response = str(user_response['response'])
|
||||
|
||||
|
||||
node_question_reponse['response'] = response
|
||||
question_num += 1
|
||||
|
||||
# recup type de question pr pdf
|
||||
question_type = ""
|
||||
if ("type" in user_response.keys()):
|
||||
question_type = str(user_response['type'])
|
||||
node_question_reponse['question_type'] = question_type
|
||||
|
||||
param_survey_data['question_reponse'].append(node_question_reponse)
|
||||
else:
|
||||
|
||||
node_question_reponse = {}
|
||||
node_question_reponse['response'] = "---"
|
||||
|
||||
response = "---"
|
||||
|
||||
node_question_reponse['response'] = response
|
||||
|
||||
|
||||
# recup type de question pr pdf
|
||||
question_type = "---"
|
||||
|
||||
node_question_reponse['question_type'] = question_type
|
||||
|
||||
param_survey_data['question_reponse'].append(node_question_reponse)
|
||||
|
||||
convention_dictionnary_data['param_survey_data'] = param_survey_data
|
||||
body = {
|
||||
"params": convention_dictionnary_data,
|
||||
}
|
||||
|
||||
#print(" ### param_survey_data - body = ", body)
|
||||
|
||||
"""
|
||||
Creation du fichier PDF
|
||||
"""
|
||||
|
||||
|
||||
contenu_doc_Template = jinja2.Template(str(courrier_data_retval['contenu_doc']))
|
||||
|
||||
sourceHtml = contenu_doc_Template.render(params=body["params"])
|
||||
|
||||
todays_date = str(date.today().strftime("%d/%m/%Y"))
|
||||
ts = datetime.now().timestamp()
|
||||
ts = str(ts).replace(".", "").replace(",", "")[-3:]
|
||||
|
||||
tmp_file_name = str(param_survey_data['code_session'])+"_"+str(param_survey_data['nom'])
|
||||
|
||||
if(len(str(tmp_file_name)) > 30 ):
|
||||
tmp_file_name = str(tmp_file_name)[0:30]
|
||||
|
||||
orig_file_name = "Evaluation_" + str(tmp_file_name)+ "_" + str(ts) + ".pdf"
|
||||
outputFilename = str(MYSY_GV.TEMPORARY_DIRECTORY) + "/" + str(orig_file_name)
|
||||
|
||||
# open output file for writing (truncated binary)
|
||||
resultFile = open(outputFilename, "w+b")
|
||||
|
||||
# convert HTML to PDF
|
||||
pisaStatus = pisa.CreatePDF(
|
||||
src=sourceHtml, # the HTML to convert
|
||||
dest=resultFile) # file handle to receive result
|
||||
|
||||
# close output file
|
||||
resultFile.close()
|
||||
list_file_name_to_zip.append(outputFilename)
|
||||
|
||||
|
||||
# Create a ZipFile Object
|
||||
|
||||
todays_date = str(date.today().strftime("%d/%m/%Y"))
|
||||
ts = datetime.now().timestamp()
|
||||
ts = str(ts).replace(".", "").replace(",", "")[-5:]
|
||||
|
||||
todays_date = str(date.today().strftime("%d/%m/%Y"))
|
||||
ts = datetime.now().timestamp()
|
||||
ts = str(ts).replace(".", "").replace(",", "")[-3:]
|
||||
zip_file_name = str(MYSY_GV.TEMPORARY_DIRECTORY_V2)+"List_Evaluation_"+str(ts)+".zip"
|
||||
|
||||
with ZipFile(zip_file_name, 'w') as zip_object:
|
||||
for pdf_files in list_file_name_to_zip :
|
||||
#print(" ### fichier a zipper = ", pdf_files)
|
||||
zip_object.write(str(pdf_files))
|
||||
|
||||
|
||||
if os.path.exists(zip_file_name):
|
||||
return True, send_file(zip_file_name, as_attachment=True)
|
||||
|
||||
return False, "Impossible de générer l'export (2) "
|
||||
|
||||
|
||||
except Exception as e:
|
||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - Line : " + str(exc_tb.tb_lineno))
|
||||
return False, " Impossible de générer l'export "
|
||||
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Cette fonction permet de faire des statistiques ou de projections graphiques sur
|
||||
sur des reponses, par exemple la moyenne de satisfaction par rapport
|
||||
|
|
Loading…
Reference in New Issue