06/04/2024 - 21h19
parent
5021ce2a80
commit
d4fc6a3227
|
@ -1,9 +1,12 @@
|
|||
<?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="04/04/24 - 19h30">
|
||||
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="04/04/24 - 21h30">
|
||||
<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$/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$/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$/survey_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/survey_mgt.py" afterDir="false" />
|
||||
</list>
|
||||
|
@ -75,13 +78,6 @@
|
|||
<option name="presentableId" value="Default" />
|
||||
<updated>1680804787304</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00208" summary="31/01/2024 - 20h">
|
||||
<created>1706727057687</created>
|
||||
<option name="number" value="00208" />
|
||||
<option name="presentableId" value="LOCAL-00208" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1706727057688</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00209" summary="02/02/2024 - 17h">
|
||||
<created>1706890019271</created>
|
||||
<option name="number" value="00209" />
|
||||
|
@ -418,7 +414,14 @@
|
|||
<option name="project" value="LOCAL" />
|
||||
<updated>1712250957207</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="257" />
|
||||
<task id="LOCAL-00257" summary="04/04/24 - 21h30">
|
||||
<created>1712258561441</created>
|
||||
<option name="number" value="00257" />
|
||||
<option name="presentableId" value="LOCAL-00257" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1712258561443</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="258" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="Vcs.Log.Tabs.Properties">
|
||||
|
@ -460,7 +463,6 @@
|
|||
</option>
|
||||
</component>
|
||||
<component name="VcsManagerConfiguration">
|
||||
<MESSAGE value="29/02/2024 - 21h30" />
|
||||
<MESSAGE value="01/03/2024 - 23h30" />
|
||||
<MESSAGE value="02/03/2024 - 23h20" />
|
||||
<MESSAGE value="sss" />
|
||||
|
@ -485,6 +487,7 @@
|
|||
<MESSAGE value="2/04/24 - 20h30" />
|
||||
<MESSAGE value="03/04/24 - 21h30" />
|
||||
<MESSAGE value="04/04/24 - 19h30" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="04/04/24 - 19h30" />
|
||||
<MESSAGE value="04/04/24 - 21h30" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="04/04/24 - 21h30" />
|
||||
</component>
|
||||
</project>
|
|
@ -674,6 +674,13 @@ Taille maximale des nom de fichier
|
|||
"""
|
||||
FILE_NAME_MAX_SIZE = 250
|
||||
|
||||
"""
|
||||
Les types de formulaire
|
||||
- pos = Formulaire pour questionnaire de positionnement
|
||||
- hot_eval = Formulaire pour evaluation à chaud
|
||||
- cool_eval = Formulaire pour evaluation à froid
|
||||
"""
|
||||
FORM_TYPE = ['pos', 'hot_eval', 'cool_eval']
|
||||
|
||||
|
||||
"""
|
||||
|
@ -689,8 +696,9 @@ FORM_QUESTION_TYPE = ['qcm', 'text', 'note', 'entier', 'bool']
|
|||
"""
|
||||
Survey Statut :
|
||||
Une enquete a les statuts suivants :
|
||||
0 - envoyé
|
||||
1 - repondu
|
||||
0 - initialisé
|
||||
1 - envoyé
|
||||
2 - repondu
|
||||
-1 - annulé
|
||||
"""
|
||||
SURVEY_STATUS = ['-1', '0', '1']
|
||||
SURVEY_STATUS = ['-1', '0', '1', '2']
|
3029
Log/log_file.log
3029
Log/log_file.log
File diff suppressed because it is too large
Load Diff
|
@ -238,6 +238,9 @@ def Add_Update_SessionFormation(diction):
|
|||
|
||||
mydata['formateur_id'] = formateur_id
|
||||
|
||||
|
||||
|
||||
|
||||
if ("adresse" in diction.keys()):
|
||||
if diction['adresse']:
|
||||
mydata['adresse'] = diction['adresse']
|
||||
|
|
|
@ -55,7 +55,7 @@ def Add_Formulaire(diction):
|
|||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', 'code', 'nom', 'description', 'commentaire', ]
|
||||
field_list = ['token', 'code', 'nom', 'description', 'commentaire', 'message_introduction', 'type' ]
|
||||
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
|
@ -67,7 +67,7 @@ def Add_Formulaire(diction):
|
|||
"""
|
||||
Verification des champs obligatoires
|
||||
"""
|
||||
field_list_obligatoire = ['token', 'code', 'nom', 'description', ]
|
||||
field_list_obligatoire = ['token', 'code', 'nom', 'description', 'type' ]
|
||||
|
||||
for val in field_list_obligatoire:
|
||||
if val not in diction:
|
||||
|
@ -99,6 +99,12 @@ def Add_Formulaire(diction):
|
|||
mydata[str(val)] = ""
|
||||
|
||||
|
||||
if( str(diction['type']) not in MYSY_GV.FORM_TYPE ):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " Le type de formulaire n'est pas valide. Les valeurs autorisée sont "+str(MYSY_GV.FORM_TYPE))
|
||||
return False, " Le type de formulaire n'est pas valide. Les valeurs autorisée sont "+str(MYSY_GV.FORM_TYPE)
|
||||
|
||||
|
||||
"""
|
||||
Verifier que le formulaire n'existe pas (code en minuscule)
|
||||
"""
|
||||
|
@ -593,7 +599,7 @@ def Get_List_Formulaire_with_filter(diction):
|
|||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', 'code', 'nom', 'description' ]
|
||||
field_list = ['token', 'code', 'nom', 'description', 'type' ]
|
||||
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
|
@ -626,6 +632,10 @@ def Get_List_Formulaire_with_filter(diction):
|
|||
if (local_status is not True):
|
||||
return local_status, my_partner
|
||||
|
||||
filt_type = {}
|
||||
if ("type" in diction.keys()):
|
||||
filt_type = {'type': {'$regex': str(diction['type']), "$options": "i"}}
|
||||
|
||||
filt_code = {}
|
||||
if ("code" in diction.keys()):
|
||||
filt_code = {'code': {'$regex': str(diction['code']), "$options": "i"}}
|
||||
|
@ -643,7 +653,7 @@ def Get_List_Formulaire_with_filter(diction):
|
|||
val_tmp = 0
|
||||
|
||||
qry = {"partner_owner_recid": str(my_partner['recid']), 'valide': '1', 'locked': '0'}
|
||||
query_with_filter = {'$and': [qry, filt_code, filt_nom, filt_description]}
|
||||
query_with_filter = {'$and': [qry, filt_code, filt_nom, filt_description, filt_type]}
|
||||
|
||||
for New_retVal in MYSY_GV.dbname['formulaire'].find(query_with_filter).sort([("_id", pymongo.DESCENDING), ]):
|
||||
user = New_retVal
|
||||
|
@ -739,7 +749,7 @@ def Update_Formulaire(diction):
|
|||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', 'code', 'nom', 'description', 'commentaire', 'form_id']
|
||||
field_list = ['token', 'code', 'nom', 'description', 'commentaire', 'form_id', 'message_introduction', 'type']
|
||||
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
|
@ -751,7 +761,7 @@ def Update_Formulaire(diction):
|
|||
"""
|
||||
Verification des champs obligatoires
|
||||
"""
|
||||
field_list_obligatoire = ['token', 'code', 'nom', 'description', 'form_id' ]
|
||||
field_list_obligatoire = ['token', 'code', 'nom', 'description', 'form_id', 'type' ]
|
||||
|
||||
for val in field_list_obligatoire:
|
||||
if val not in diction:
|
||||
|
@ -788,6 +798,14 @@ def Update_Formulaire(diction):
|
|||
mydata = diction
|
||||
del mydata['token']
|
||||
|
||||
if (str(diction['type']) not in MYSY_GV.FORM_TYPE):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " Le type de formulaire n'est pas valide. Les valeurs autorisée sont " + str(
|
||||
MYSY_GV.FORM_TYPE))
|
||||
return False, " Le type de formulaire n'est pas valide. Les valeurs autorisée sont " + str(
|
||||
MYSY_GV.FORM_TYPE)
|
||||
|
||||
|
||||
mydata['date_update'] = str(datetime.now())
|
||||
mydata['update_by'] = str(my_partner['_id'])
|
||||
|
|
43
main.py
43
main.py
|
@ -8324,6 +8324,49 @@ def Add_Survey_Tab_Inscrit():
|
|||
status, retval = survey_mgt.Add_Survey_Tab_Inscrit(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
"""
|
||||
API pour initialiset (suppression et creation ) d'une enquete pour tous
|
||||
les inscrits d'un session.
|
||||
algorithm :
|
||||
On supprime tous enregistrements avec le clé :
|
||||
- session_id,
|
||||
"""
|
||||
@app.route('/myclass/api/Init_Survey_Tab_For_All_Session_Inscrit/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Init_Survey_Tab_For_All_Session_Inscrit():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Init_Survey_Tab_For_All_Session_Inscrit payload = ",payload)
|
||||
status, retval = survey_mgt.Init_Survey_Tab_For_All_Session_Inscrit(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
"""
|
||||
API pour recuperer la liste des survey avec des filtre sur
|
||||
- sesson_id,
|
||||
- formulaire_type - ['pos', 'hot_eval', 'cool_eval']
|
||||
"""
|
||||
@app.route('/myclass/api/Get_List_Survey_with_filter/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Get_List_Survey_with_filter():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Get_List_Survey_with_filter payload = ",payload)
|
||||
status, retval = survey_mgt.Get_List_Survey_with_filter(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
"""
|
||||
API qui envoyer le mail de demande d'enquete
|
||||
"""
|
||||
@app.route('/myclass/api/Send_Survey_TabIds/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Send_Survey_TabIds():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Send_Survey_TabIds payload = ",payload)
|
||||
status, retval = survey_mgt.Send_Survey_TabIds(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
|
||||
|
|
453
survey_mgt.py
453
survey_mgt.py
|
@ -81,9 +81,9 @@ def Get_Given_Survey_Data_No_Token(diction):
|
|||
RetObject = []
|
||||
val_tmp = 0
|
||||
|
||||
qry = { 'statut':'0', 'valide': '1', 'locked': '0', '_id':ObjectId(str(diction['survey_id']))}
|
||||
|
||||
qry = { 'statut':'1', 'valide': '1', 'locked': '0', '_id':ObjectId(str(diction['survey_id']))}
|
||||
|
||||
print(" qry == ", qry)
|
||||
for New_retVal in MYSY_GV.dbname['survey'].find(qry).sort([("_id", pymongo.DESCENDING), ]):
|
||||
user = New_retVal
|
||||
user['id'] = str(val_tmp)
|
||||
|
@ -133,6 +133,7 @@ def Get_Given_Survey_Data_No_Token(diction):
|
|||
|
||||
RetObject.append(mycommon.JSONEncoder().encode(user))
|
||||
|
||||
print(" ### RetObject = ", RetObject)
|
||||
return True, RetObject
|
||||
|
||||
|
||||
|
@ -186,7 +187,7 @@ def Record_Survey_Data_No_Token(diction):
|
|||
"""
|
||||
Verifier que l'enquete est valide
|
||||
"""
|
||||
qry = {'statut': '0', 'valide': '1', 'locked': '0', '_id': ObjectId(str(diction['survey_id']))}
|
||||
qry = {'statut': '1', 'valide': '1', 'locked': '0', '_id': ObjectId(str(diction['survey_id']))}
|
||||
|
||||
is_valide_survey = MYSY_GV.dbname['survey'].count_documents(qry)
|
||||
|
||||
|
@ -212,12 +213,12 @@ def Record_Survey_Data_No_Token(diction):
|
|||
"""
|
||||
mydata = {}
|
||||
mydata['date_update'] = str(datetime.now())
|
||||
mydata['update_by'] = ""
|
||||
mydata['statut'] = "1"
|
||||
mydata['date_reponse'] = str(datetime.now())
|
||||
mydata['statut'] = "2"
|
||||
mydata['user_response'] = global_response
|
||||
|
||||
result = MYSY_GV.dbname['survey'].find_one_and_update(
|
||||
{'statut': '0', 'valide': '1', 'locked': '0', '_id': ObjectId(str(diction['survey_id']))},
|
||||
{'statut': '1', 'valide': '1', 'locked': '0', '_id': ObjectId(str(diction['survey_id']))},
|
||||
{"$set": mydata},
|
||||
upsert=False,
|
||||
return_document=ReturnDocument.AFTER
|
||||
|
@ -239,8 +240,9 @@ def Record_Survey_Data_No_Token(diction):
|
|||
|
||||
|
||||
"""
|
||||
Survey for enduser : Cette fonction créer une enquete en prenant à partir d'une liste d'inscri
|
||||
Survey for enduser : Cette fonction créer une enquete en prenant à partir d'une liste d'inscrit
|
||||
"""
|
||||
|
||||
def Add_Survey_Tab_Inscrit(diction):
|
||||
try:
|
||||
field_list_obligatoire = ['session_id', 'token', 'tab_ids', 'formulaire_id']
|
||||
|
@ -331,7 +333,7 @@ def Add_Survey_Tab_Inscrit(diction):
|
|||
server_diction['inscrit_id'] = str(local_Insc_retval['_id'])
|
||||
server_diction['formulaire_id'] = diction['formulaire_id']
|
||||
|
||||
local_status, local_retval = Send_One_Survey_To_Inscrit(server_diction)
|
||||
local_status, local_retval = Create_One_Survey_To_Inscrit(server_diction)
|
||||
if( local_status is False):
|
||||
return local_status, local_retval
|
||||
|
||||
|
@ -344,12 +346,135 @@ def Add_Survey_Tab_Inscrit(diction):
|
|||
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - Line : " + str(exc_tb.tb_lineno))
|
||||
return False, " Impossible de créer le formulaire "
|
||||
|
||||
|
||||
"""
|
||||
Cette fonction initialise (suppression et creation ) d'une enquete pour tous
|
||||
les inscrits d'un session.
|
||||
algorithm :
|
||||
On supprime tous enregistrements avec le clé :
|
||||
- session_id,
|
||||
"""
|
||||
def Init_Survey_Tab_For_All_Session_Inscrit(diction):
|
||||
try:
|
||||
field_list_obligatoire = ['session_id', 'token', 'formulaire_id', 'survey_type']
|
||||
|
||||
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"
|
||||
|
||||
my_token = ""
|
||||
if ("token" in diction.keys()):
|
||||
if diction['token']:
|
||||
my_token = diction['token']
|
||||
|
||||
local_status, my_partner = mycommon.Check_Connexion_And_Return_Partner_Data(diction)
|
||||
if (local_status is not True):
|
||||
return local_status, my_partner
|
||||
|
||||
"""
|
||||
Verifier que la session est valide
|
||||
"""
|
||||
is_valide_session = MYSY_GV.dbname['session_formation'].count_documents({'_id':ObjectId(str(diction['session_id'])),
|
||||
'valide':'1',
|
||||
'partner_owner_recid':str(my_partner['recid'])})
|
||||
|
||||
if( is_valide_session <= 0 ):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " L'identifiant de la session est invalide ")
|
||||
return False, " L'identifiant de la session est invalide "
|
||||
|
||||
tab_my_inscription_ids = []
|
||||
|
||||
for my_inscription_id in MYSY_GV.dbname['inscription'].find({'session_id': str(diction['session_id']),
|
||||
'partner_owner_recid': str(my_partner['recid']),
|
||||
'valide':'1'}):
|
||||
|
||||
tab_my_inscription_ids.append(str(my_inscription_id['_id']))
|
||||
|
||||
|
||||
"""
|
||||
Verifier la valididé du formulaire
|
||||
"""
|
||||
is_valide_form = MYSY_GV.dbname['formulaire'].count_documents({'_id':ObjectId(str(diction['formulaire_id'])),
|
||||
'valide':'1',
|
||||
'locked':'0',
|
||||
'partner_owner_recid':str(my_partner['recid'])})
|
||||
|
||||
if( is_valide_form <= 0 ):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " L'identifiant du formulaire est invalide ")
|
||||
return False, " L'identifiant du formulaire est invalide "
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Les inscriptions etant toutes valides, on va proceder à
|
||||
1 - suppression des data existate et
|
||||
2 - la creation de l'enquete
|
||||
"""
|
||||
|
||||
MYSY_GV.dbname['survey'].delete_many({'partner_owner_recid':str(my_partner['recid']),
|
||||
'session_id':str(diction['session_id']),
|
||||
'survey_type':str(diction['survey_type'])})
|
||||
|
||||
|
||||
|
||||
for my_inscription_id in tab_my_inscription_ids:
|
||||
# Recuperation des données de l'inscript
|
||||
|
||||
req = {'session_id': str(diction['session_id']),
|
||||
'_id':ObjectId(str(my_inscription_id)),
|
||||
'partner_owner_recid': str(my_partner['recid']),
|
||||
'valide': '1'
|
||||
}
|
||||
|
||||
|
||||
local_Insc_retval = MYSY_GV.dbname['inscription'].find_one({'session_id': str(diction['session_id']),
|
||||
'_id':ObjectId(str(my_inscription_id)),
|
||||
'partner_owner_recid': str(my_partner['recid']),
|
||||
'valide': '1'
|
||||
})
|
||||
|
||||
if(local_Insc_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 "
|
||||
|
||||
server_diction = {}
|
||||
server_diction['token'] = diction['token']
|
||||
server_diction['session_id'] = diction['session_id']
|
||||
server_diction['inscrit_id'] = str(local_Insc_retval['_id'])
|
||||
server_diction['formulaire_id'] = diction['formulaire_id']
|
||||
server_diction['survey_type'] = diction['survey_type']
|
||||
|
||||
|
||||
local_status, local_retval = Create_One_Survey_To_Inscrit(server_diction)
|
||||
if( local_status is False):
|
||||
return local_status, local_retval
|
||||
|
||||
|
||||
return True, " La demande d'enquete a été créée "
|
||||
|
||||
|
||||
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 créer le formulaire "
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Cette fonction envoi un formulaire pour inscrit
|
||||
"""
|
||||
def Send_One_Survey_To_Inscrit(diction):
|
||||
def Create_One_Survey_To_Inscrit(diction):
|
||||
try:
|
||||
field_list_obligatoire = ['session_id', 'token', 'inscrit_id', 'formulaire_id']
|
||||
field_list_obligatoire = ['session_id', 'token', 'inscrit_id', 'formulaire_id', 'survey_type']
|
||||
|
||||
for val in field_list_obligatoire:
|
||||
if val not in diction:
|
||||
|
@ -415,9 +540,13 @@ def Send_One_Survey_To_Inscrit(diction):
|
|||
|
||||
new_survey_data = {}
|
||||
new_survey_data['email'] = my_inscrit_data['email']
|
||||
new_survey_data['nom'] = my_inscrit_data['nom']
|
||||
new_survey_data['prenom'] = my_inscrit_data['prenom']
|
||||
new_survey_data['formulaire_id'] = str(diction['formulaire_id'])
|
||||
new_survey_data['partner_owner_recid'] = str(my_partner['recid'])
|
||||
new_survey_data['session_id'] = str(diction['session_id'])
|
||||
new_survey_data['survey_type'] = str(diction['survey_type'])
|
||||
new_survey_data['date_envoi'] = ""
|
||||
|
||||
new_survey_data['locked'] = "0"
|
||||
new_survey_data['valide'] = "1"
|
||||
|
@ -434,16 +563,66 @@ def Send_One_Survey_To_Inscrit(diction):
|
|||
mycommon.myprint(" Impossible de créer l'enquete (2) ")
|
||||
return False, " Impossible de créer l'enquete (2) "
|
||||
|
||||
servey_url = MYSY_GV.CLIENT_URL_BASE+"Survey/"+str(inserted_id)
|
||||
|
||||
return True, " L'enquete a été créée"
|
||||
|
||||
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 créer l'enquete unitaire "
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Cette fonction permet d'envoyer la demande d'enquete à la personne concerné
|
||||
"""
|
||||
|
||||
def Send_Survey_TabIds(diction):
|
||||
try:
|
||||
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"
|
||||
|
||||
my_token = ""
|
||||
if ("token" in diction.keys()):
|
||||
if diction['token']:
|
||||
my_token = diction['token']
|
||||
|
||||
local_status, my_partner = mycommon.Check_Connexion_And_Return_Partner_Data(diction)
|
||||
if (local_status is not True):
|
||||
return local_status, my_partner
|
||||
|
||||
my_survey_ids = ""
|
||||
if ("tab_ids" in diction.keys()):
|
||||
if diction['tab_ids']:
|
||||
my_survey_ids = diction['tab_ids']
|
||||
|
||||
tab_my_survey_ids = str(my_survey_ids).split(",")
|
||||
for my_survey_id in tab_my_survey_ids:
|
||||
|
||||
# Verifier que les survey sont valides
|
||||
qry = { '_id':ObjectId(str(my_survey_id)), 'partner_owner_recid': str(my_partner['recid']),'valide':'1', 'locked':'0'}
|
||||
|
||||
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 "
|
||||
|
||||
|
||||
|
||||
"""
|
||||
A présent l'enquete est créée, il faut donc envoyer
|
||||
le mail avec l'url à la personne qui doit remplir l'enquete
|
||||
Les enquete etant toutes valides, on va preceder à l'envoie des email de demande
|
||||
"""
|
||||
|
||||
"""
|
||||
Recuperation des parametre SMTP du partner si le client a decidé d'utiliser son propre smpt
|
||||
"""
|
||||
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']),
|
||||
|
@ -485,65 +664,207 @@ def Send_One_Survey_To_Inscrit(diction):
|
|||
'valide': '1',
|
||||
'locked': '0'}, {'config_value': 1})['config_value'])
|
||||
|
||||
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)
|
||||
|
||||
html = """\
|
||||
<html>
|
||||
<body>
|
||||
<p>Hi,<br>
|
||||
Merci de suivre l'enquete :"""+str(servey_url)+""" </p>
|
||||
<p><a href="https://blog.mailtrap.io/2018/09/27/cloud-or-local-smtp-server">SMTP Server for Testing: Cloud-based or Local?</a></p>
|
||||
<p> Feel free to <strong>let us</strong> know what content would be useful for you!</p>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
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 "
|
||||
|
||||
servey_url = MYSY_GV.CLIENT_URL_BASE + "Survey/" + str(local_survey_retval['_id'])
|
||||
|
||||
html = """\
|
||||
<html>
|
||||
<body>
|
||||
<p>Hi,<br>
|
||||
Merci de suivre l'enquete :""" + str(servey_url) + """ </p>
|
||||
<p><a href="https://blog.mailtrap.io/2018/09/27/cloud-or-local-smtp-server">SMTP Server for Testing: Cloud-based or Local?</a></p>
|
||||
<p> Feel free to <strong>let us</strong> know what content would be useful for you!</p>
|
||||
</body>
|
||||
</html>
|
||||
"""
|
||||
|
||||
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'] = " Demande d'enquete "
|
||||
# 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'] = " Demande d'enquete "
|
||||
# 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())
|
||||
|
||||
html_mime = MIMEText(html, 'html')
|
||||
|
||||
# Creation de l'email à enoyer
|
||||
msg = MIMEMultipart("alternative")
|
||||
|
||||
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'] = " Demande d'enquete "
|
||||
# msg['to'] = "billardman01@hotmail.com"
|
||||
|
||||
msg['to'] = str(my_inscrit_data['email'])
|
||||
qry = {'_id': ObjectId(str(my_survey_id)), 'partner_owner_recid': str(my_partner['recid']),
|
||||
'valide': '1', 'locked': '0'}
|
||||
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}}
|
||||
)
|
||||
|
||||
|
||||
smtpserver.ehlo()
|
||||
smtpserver.starttls()
|
||||
smtpserver.login(partner_SMTP_COUNT_user, partner_SMTP_COUNT_password)
|
||||
return True, " Les demandes d'enquete ont été envoyées "
|
||||
|
||||
else:
|
||||
msg.attach(html_mime)
|
||||
msg['From'] = MYSY_GV.O365_SMTP_COUNT_From_User
|
||||
msg['Bcc'] = 'contact@mysy-training.com'
|
||||
msg['Subject'] = " Demande d'enquete "
|
||||
# msg['to'] = "billardman01@hotmail.com"
|
||||
|
||||
msg['to'] = str(my_inscrit_data['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))
|
||||
|
||||
return True, "OK"
|
||||
|
||||
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 l'enquete unitaire "
|
||||
return False, " Impossible d'envoyer les demande "
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Survey for customer : Cette fonction créer une enquete en prenant à partir d'une liste d'inscri
|
||||
"""
|
||||
Fonction pour Recuperer la liste des enquete avec les filtre suivant :
|
||||
- session_id,
|
||||
- formulaire_type - ['pos', 'hot_eval', 'cool_eval']
|
||||
"""
|
||||
def Get_List_Survey_with_filter(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', 'session_id', 'formulaire_type' ]
|
||||
|
||||
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',]
|
||||
|
||||
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
|
||||
|
||||
|
||||
filt_session_id = {}
|
||||
if ("session_id" in diction.keys()):
|
||||
filt_session_id = {'session_id': str(diction['session_id'])}
|
||||
|
||||
|
||||
|
||||
RetObject = []
|
||||
val_tmp = 0
|
||||
|
||||
qry = {"partner_owner_recid": str(my_partner['recid']), 'valide': '1', 'locked': '0'}
|
||||
query_with_filter = {'$and': [qry, filt_session_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': ["$type", str(diction['formulaire_type'])]},
|
||||
{'$eq': ["$partner_owner_recid", '$$partner_owner_recid']}
|
||||
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
],
|
||||
'as': 'formulaire'
|
||||
}
|
||||
},
|
||||
{
|
||||
'$unwind': '$formulaire'
|
||||
}
|
||||
])
|
||||
|
||||
#print(" ### pipe_qry = ", pipe_qry)
|
||||
|
||||
for New_retVal in MYSY_GV.dbname['survey'].aggregate(pipe_qry):
|
||||
user = New_retVal
|
||||
user['id'] = str(val_tmp)
|
||||
val_tmp = val_tmp + 1
|
||||
|
||||
RetObject.append(mycommon.JSONEncoder().encode(user))
|
||||
|
||||
return True, RetObject
|
||||
|
||||
|
||||
except Exception as e:
|
||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - Line : " + str(exc_tb.tb_lineno))
|
||||
return False, " Impossible de récupérer la liste des formulaires "
|
||||
|
|
Loading…
Reference in New Issue