03/08/23 - 19h

master
cherif 2023-08-03 19:09:03 +02:00
parent e855d8508b
commit ce1e173476
7 changed files with 7907 additions and 37 deletions

View File

@ -1,10 +1,11 @@
<?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="30/07/23 - 17h">
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="01/08/230- 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$/Log/log_file.log" beforeDir="false" afterPath="$PROJECT_DIR$/Log/log_file.log" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Template/fiche_detail_stagiaire_tpl.html" beforeDir="false" afterPath="$PROJECT_DIR$/Template/fiche_detail_stagiaire_tpl.html" afterDir="false" />
<change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/partners.py" beforeDir="false" afterPath="$PROJECT_DIR$/partners.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/prj_common.py" beforeDir="false" afterPath="$PROJECT_DIR$/prj_common.py" afterDir="false" />
@ -71,13 +72,6 @@
<option name="presentableId" value="Default" />
<updated>1680804787304</updated>
</task>
<task id="LOCAL-00008" summary="20/04/23 - 16h">
<created>1681998167874</created>
<option name="number" value="00008" />
<option name="presentableId" value="LOCAL-00008" />
<option name="project" value="LOCAL" />
<updated>1681998167874</updated>
</task>
<task id="LOCAL-00009" summary="20/04/23 - 20h">
<created>1682013957129</created>
<option name="number" value="00009" />
@ -414,7 +408,14 @@
<option name="project" value="LOCAL" />
<updated>1690731459971</updated>
</task>
<option name="localTasksCounter" value="57" />
<task id="LOCAL-00057" summary="01/08/230- 21h">
<created>1690918242182</created>
<option name="number" value="00057" />
<option name="presentableId" value="LOCAL-00057" />
<option name="project" value="LOCAL" />
<updated>1690918242182</updated>
</task>
<option name="localTasksCounter" value="58" />
<servers />
</component>
<component name="Vcs.Log.Tabs.Properties">
@ -429,7 +430,6 @@
</option>
</component>
<component name="VcsManagerConfiguration">
<MESSAGE value="05/06/23 - 15h" />
<MESSAGE value="06/06/23 - 19h" />
<MESSAGE value="08/06/23 - 21h" />
<MESSAGE value="13/06/23 - 16h" />
@ -454,6 +454,7 @@
<MESSAGE value="28/07/23 - 19h" />
<MESSAGE value="29/07/23 - 29h" />
<MESSAGE value="30/07/23 - 17h" />
<option name="LAST_COMMIT_MESSAGE" value="30/07/23 - 17h" />
<MESSAGE value="01/08/230- 21h" />
<option name="LAST_COMMIT_MESSAGE" value="01/08/230- 21h" />
</component>
</project>

View File

@ -1643,6 +1643,11 @@ def PrintAttendeeDetail_perSession(diction):
mycommon.myprint(str(inspect.stack()[0][3]) + " - Impossible d'imprimer la fiche detaillée")
return False, " Les informations d'identification sont invalides"
local_status, my_partner_data = mycommon.Check_Connexion_And_Return_Partner_Data(diction)
if (local_status is not True):
return local_status, my_partner_data
RetObject = []
# Recuperation des infos de la formation
local_Insc_retval = MYSY_GV.dbname['inscription'].find_one({'session_id': str(diction['session_id']),
@ -1834,7 +1839,35 @@ def PrintAttendeeDetail_perSession(diction):
tab_presences.append(local_tmp)
#print(" ### tab_presences =",tab_presences)
# Recuperation image logo du partenaire en base de donnée
qery_images = {'locked': '0', 'valide': '1', 'related_collection': 'partnair_account',
'related_collection_recid': str(my_partner_data['recid']), 'type_img':'logo'}
partner_media_logo = MYSY_GV.dbname['mysy_images'].find_one(qery_images)
is_partner_logo = True
is_partner_logo_img = ""
if( partner_media_logo is None or "img" not in partner_media_logo.keys()):
mycommon.myprint(
str(inspect.stack()[0][
3]) + " La partner n'a pas de logo, le logo par defaut sera utilisé")
is_partner_logo = False
else:
is_partner_logo_img = "data:image/png;base64," + str(partner_media_logo['img'])
if( is_partner_logo is False ):
# Recuperer l'image logo par default
default_qery_images = {'locked': '0', 'valide': '1', 'related_collection': 'partnair_account', 'type_img': 'logo_default'}
partner_media_logo = MYSY_GV.dbname['mysy_images'].find_one(default_qery_images)
is_partner_logo_img = "data:image/png;base64," + str(partner_media_logo['img'])
my_retrun_dict['default_logo_partner'] = is_partner_logo_img
#print(" ### my_retrun_dict =",my_retrun_dict)
templateLoader = jinja2.FileSystemLoader(searchpath="./")
templateEnv = jinja2.Environment(loader=templateLoader)
@ -1881,6 +1914,8 @@ def PrintAttendeeDetail_perSession(diction):
return False, " Impossible d'imprimer la fiche detaillée"
""" Creation d'un evaluation sur une formation
Les infos d'evaluation sont rattachées à la collection inscription.

File diff suppressed because one or more lines are too long

View File

@ -5,9 +5,11 @@
<div style="padding:0px;text-align:right;width:100%">
<img src="http://88.170.110.220/img/MYSY-LOGO-BLUE.png" alt="Mysy Training Logo" width="80px" /> </h2>
</div>
{% if json_data.img_url %}
{% if json_data.default_logo_partner %}
<div style="padding:0px;text-align:center;width:100%">
<img src={{ json_data.img_url }} alt="Mysy Training Logo" width="100px" /> </h2>
<img src={{ json_data.default_logo_partner }} alt="Logo Compagnie" width="100px" /> </h2>
</div>
{% endif %}
<div

26
main.py
View File

@ -663,13 +663,35 @@ def update_partner_account():
if request.method == 'POST':
# Create variable for uploaded file
file_logo = request.files['file_logo']
file_cachet = request.files['file_cachet']
if( 'file_logo' in request.files.keys() ):
file_logo = request.files['file_logo']
else:
file_logo = None
if ('file_cachet' in request.files.keys()):
file_cachet = request.files['file_cachet']
else:
file_cachet = None
status, retval = pa.update_partner_account(file_logo,file_cachet, app.config['UPLOAD_FOLDER'], payload)
return jsonify(status=status, message=retval)
"""
API de suppression d'une image enregistrer dans la collection 'mysy_images"
en input, on prend le recid
"""
@app.route('/myclass/api/DeleteClassImage_v2/', methods=['POST','GET'])
@crossdomain(origin='*')
def DeleteClassImage_v2():
# On recupere le corps (payload) de la requete
payload = mycommon.strip_dictionary (request.form.to_dict())
print(" ### DeleteClassImage_v2 payload = ",payload)
status, retval = mycommon.DeleteClassImage_v2(payload)
return jsonify(status=status, message=retval)
'''

View File

@ -752,27 +752,29 @@ def update_partner_account(file_logo=None, file_cachet=None, Folder=None, dictio
"""
A present que le partenaire est mis à jour / créé, on va mettre à jour les image logo et image cachet s'il y en a
"""
recordimage_diction = {}
recordimage_diction['token'] = diction['token']
recordimage_diction['related_collection'] = "partnair_account"
recordimage_diction['type_img'] = "logo"
recordimage_diction['related_collection_recid'] = str(partner_recid)
recordimage_diction['image_recid'] = diction['file_logo_recid']
#print(" ### recordimage_diction 1 = ", recordimage_diction)
local_status, local_message = mycommon.recordClassImage_v2(file_logo, MYSY_GV.upload_folder, recordimage_diction)
if( local_status is False):
return local_status, local_message
if( file_logo ):
recordimage_diction = {}
recordimage_diction['token'] = diction['token']
recordimage_diction['related_collection'] = "partnair_account"
recordimage_diction['type_img'] = "logo"
recordimage_diction['related_collection_recid'] = str(partner_recid)
recordimage_diction['image_recid'] = diction['file_logo_recid']
#print(" ### recordimage_diction 1 = ", recordimage_diction)
local_status, local_message = mycommon.recordClassImage_v2(file_logo, MYSY_GV.upload_folder, recordimage_diction)
if( local_status is False):
return local_status, local_message
recordimage_diction = {}
recordimage_diction['token'] = diction['token']
recordimage_diction['related_collection'] = "partnair_account"
recordimage_diction['type_img'] = "cachet"
recordimage_diction['related_collection_recid'] = str(partner_recid)
recordimage_diction['image_recid'] = diction['file_cachet_recid']
#print(" ### recordimage_diction 2 = ", recordimage_diction)
local_status, local_message = mycommon.recordClassImage_v2(file_cachet, MYSY_GV.upload_folder, recordimage_diction)
if (local_status is False):
return local_status, local_message
if( file_cachet ):
recordimage_diction = {}
recordimage_diction['token'] = diction['token']
recordimage_diction['related_collection'] = "partnair_account"
recordimage_diction['type_img'] = "cachet"
recordimage_diction['related_collection_recid'] = str(partner_recid)
recordimage_diction['image_recid'] = diction['file_cachet_recid']
#print(" ### recordimage_diction 2 = ", recordimage_diction)
local_status, local_message = mycommon.recordClassImage_v2(file_cachet, MYSY_GV.upload_folder, recordimage_diction)
if (local_status is False):
return local_status, local_message
return True, "Le partenaire a bien ete mise à jour"

View File

@ -1830,6 +1830,84 @@ def recordClassImage_v2(file=None, Folder=None, diction=None):
return False,"IMPOSSIBLE D'ENREGISTRER L'IMAGE "
"""
Suppression d'une image
"""
def DeleteClassImage_v2(diction=None):
try:
# Dictionnaire des champs utilisables
field_list = ['token', 'image_recid', ]
incom_keys = diction.keys()
'''
# Verification que les champs reçus dans l'API sont bien dans la liste des champs autorisés
# Cela evite le cas ou une entité tierce ajouter les valeurs inconnu dans l'API
# Ici on doit mettre tous les champs possible (obligatoire ou non) de la BDD dans la liste
# field_list.
'''
for val in incom_keys:
if str(val).lower() not in str(field_list).lower():
myprint(
str(inspect.stack()[0][3]) + " Le champ '" + val + "' n'est pas accepté dans cette API")
return False, " Impossible de se connecter"
'''
Une fois qu'on a controlé que toutes les clés mise dans l'API sont correcte. etape precedente,
On controle que les champs obligatoires sont presents dans la liste
'''
field_list_obligatoire = ['token', 'image_recid']
for val in field_list_obligatoire:
if str(val).lower() not in diction:
myprint(
str(inspect.stack()[0][3]) + " La valeur '" + val + "' n'est pas presente dans liste des champs")
return False, "Impossible de se connecter"
mydata = {}
mytoken = ""
# recuperation des paramettre
if ("token" in diction.keys()):
if diction['token']:
mytoken = diction['token']
image_recid = ""
if ("image_recid" in diction.keys()):
if diction['image_recid']:
image_recid = diction['image_recid']
local_status, my_partner = Check_Connexion_And_Return_Partner_Data(diction)
if (local_status is not True):
return local_status, my_partner
if(len(str(image_recid)) <= 0 ):
# cette image n'a jamais ete enregistrée
# Creation du RecId
image_recid = create_user_recid()
# " Lecture du fichier "
#print(" Lecture du fichier : " + saved_file + ". le token est :" + str(mytoken))
nb_line = 0
coll_name = MYSY_GV.dbname['mysy_images']
ret_val = coll_name.delete_one({"recid":image_recid,
'related_collection_recid': str(my_partner['recid']) },)
print(" ### detelete ret_val = ", ret_val)
print(" ### recordClassImage_v2 :L'image a été correctement suppriméz ")
return True, "L'image a été correctement supprimée"
except Exception as e:
exc_type, exc_obj, exc_tb = sys.exc_info()
print(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
return False,"IMPOSSIBLE D'ENREGISTRER L'IMAGE "
'''
Recuperation d'une image de profils
'''