12/06/2024 - 21h30

master
cherif 2024-06-12 21:27:24 +02:00
parent adb336147f
commit 9bc46cc073
5 changed files with 10616 additions and 43 deletions

View File

@ -1,13 +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="qqsd">
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="11/06/2024 - 23h30">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" 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$/Session_Formation.py" beforeDir="false" afterPath="$PROJECT_DIR$/Session_Formation.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/emargement.py" beforeDir="false" afterPath="$PROJECT_DIR$/emargement.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/partner_invoice.py" beforeDir="false" afterPath="$PROJECT_DIR$/partner_invoice.py" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -77,13 +76,6 @@
<option name="presentableId" value="Default" />
<updated>1680804787304</updated>
</task>
<task id="LOCAL-00281" summary="02/05/2024 - 22h">
<created>1714678394239</created>
<option name="number" value="00281" />
<option name="presentableId" value="LOCAL-00281" />
<option name="project" value="LOCAL" />
<updated>1714678394240</updated>
</task>
<task id="LOCAL-00282" summary="sss">
<created>1714748608159</created>
<option name="number" value="00282" />
@ -420,7 +412,14 @@
<option name="project" value="LOCAL" />
<updated>1718034595564</updated>
</task>
<option name="localTasksCounter" value="330" />
<task id="LOCAL-00330" summary="11/06/2024 - 23h30">
<created>1718141094205</created>
<option name="number" value="00330" />
<option name="presentableId" value="LOCAL-00330" />
<option name="project" value="LOCAL" />
<updated>1718141094207</updated>
</task>
<option name="localTasksCounter" value="331" />
<servers />
</component>
<component name="Vcs.Log.Tabs.Properties">
@ -462,7 +461,6 @@
</option>
</component>
<component name="VcsManagerConfiguration">
<MESSAGE value="sdsdd" />
<MESSAGE value="ddd" />
<MESSAGE value="17/05/2024 - 21h30" />
<MESSAGE value="sdf" />
@ -487,6 +485,7 @@
<MESSAGE value="07/06/2024 - 22h30" />
<MESSAGE value="ssq" />
<MESSAGE value="qqsd" />
<option name="LAST_COMMIT_MESSAGE" value="qqsd" />
<MESSAGE value="11/06/2024 - 23h30" />
<option name="LAST_COMMIT_MESSAGE" value="11/06/2024 - 23h30" />
</component>
</project>

View File

@ -12225,7 +12225,7 @@ def Create_Emargement_QR_Code_From_Inscription(diction):
"""
Verification des input acceptés
"""
field_list = ['token', 'session_id', 'tab_inscription_ids']
field_list = ['token', 'session_id', 'tab_emargement_ids']
incom_keys = diction.keys()
for val in incom_keys:
@ -12237,7 +12237,7 @@ def Create_Emargement_QR_Code_From_Inscription(diction):
"""
Verification des champs obligatoires
"""
field_list_obligatoire = ['token', 'session_id', 'tab_inscription_ids']
field_list_obligatoire = ['token', 'session_id', 'tab_emargement_ids']
for val in field_list_obligatoire:
if val not in diction:
@ -12272,31 +12272,31 @@ def Create_Emargement_QR_Code_From_Inscription(diction):
# Verifier que les inscriptions sont valides
my_inscription_ids = ""
if ("tab_inscription_ids" in diction.keys()):
if diction['tab_inscription_ids']:
my_inscription_ids = diction['tab_inscription_ids']
my_emargement_ids = ""
if ("tab_emargement_ids" in diction.keys()):
if diction['tab_emargement_ids']:
my_emargement_ids = diction['tab_emargement_ids']
tab_my_inscription_ids = str(my_inscription_ids).split(",")
if(len(tab_my_inscription_ids) <= 0 ):
tab_my_emargement_ids = str(my_emargement_ids).split(",")
if(len(tab_my_emargement_ids) <= 0 ):
mycommon.myprint(
str(inspect.stack()[0][3]) + " Aucun inscrit ")
return False, " Aucun inscrit "
str(inspect.stack()[0][3]) + " Aucune Séquence ")
return False, " Aucun Séquence "
for my_inscription_id in tab_my_inscription_ids:
for my_emargement_id in tab_my_emargement_ids:
# Verifier qui la formation n'a pas deja été evaluée
tmp_count = MYSY_GV.dbname['inscription'].count_documents({'session_id': str(diction['session_id']),
'_id': ObjectId(str(my_inscription_id)),
tmp_count = MYSY_GV.dbname['emargement'].count_documents({'session_id': str(diction['session_id']),
'_id': ObjectId(str(my_emargement_id)),
'partner_owner_recid': str(my_partner['recid']),
'status':'1' })
'statut':'0' })
if (tmp_count != 1):
mycommon.myprint(str(inspect.stack()[0][3]) + " L'identifiant de l'inscrit "+str(my_inscription_id)+" est invalide ")
return False, " L'identifiant de l'inscrit "+str(my_inscription_id)+" est invalide "
mycommon.myprint(str(inspect.stack()[0][3]) + " L'identifiant de l'émargement "+str(my_emargement_id)+" est invalide ")
return False, " L'identifiant de l'émargement "+str(my_emargement_id)+" est invalide "
# Creation d'une clé securisé
my_safe_token = mycommon.create_user_recid()
@ -12304,14 +12304,14 @@ def Create_Emargement_QR_Code_From_Inscription(diction):
"""
Mettre à jour l'inscription avec la clé
"""
tab_my_inscription_ids = str(my_inscription_ids).split(",")
for my_inscription_id in tab_my_inscription_ids:
tab_my_emargement_ids = str(my_emargement_ids).split(",")
for my_emargement_id in tab_my_emargement_ids:
ret_val2 = MYSY_GV.dbname['inscription'].find_one_and_update(
ret_val2 = MYSY_GV.dbname['emargement'].find_one_and_update(
{'session_id': str(diction['session_id']),
'_id': ObjectId(str(my_inscription_id)),
'_id': ObjectId(str(my_emargement_id)),
'partner_owner_recid': str(my_partner['recid']),
'status': '1'},
'statut': '0'},
{"$set": {'emargement_qr_safe_token':str(my_safe_token)}},
return_document=ReturnDocument.AFTER,
upsert=False,
@ -12385,24 +12385,182 @@ def Check_Emargement_QR_Code_From_Inscription_No_Token(diction):
return local_status, my_partner
# Verifier que les info sont valide
is_inscription_valide_count = MYSY_GV.dbname['inscription'].count_documents({'session_id': str(diction['session_id']),
is_emargement_valide_count = MYSY_GV.dbname['emargement'].count_documents({'session_id': str(diction['session_id']),
'emargement_qr_safe_token': str(diction['my_safe_token']),
'email': str( diction['user_email']),
'partner_owner_recid': str(diction['partner_owner_recid']),
'status': '1'})
'statut': '0'})
if( is_inscription_valide_count != 1):
if( is_emargement_valide_count <= 0 ):
mycommon.myprint(
str(inspect.stack()[0][3]) + " Les identifiants sont invalides ")
return False, " Les identifiants sont invalides "
RetObject = []
nb_val = 0
for retval in MYSY_GV.dbname['emargement'].find(
{'session_id': str(diction['session_id']),
'emargement_qr_safe_token': str(diction['my_safe_token']),
'email': str(diction['user_email']),
'partner_owner_recid': str(diction['partner_owner_recid']),
'statut': '0'}):
return True, " Les identifiants sont OK "
user = {}
user = retval
user['id'] = str(nb_val)
code_session = ""
class_interna_url = ""
class_title = ""
session_data = MYSY_GV.dbname['session_formation'].find_one({'_id':ObjectId(str(retval['session_id'])),
'partner_owner_recid':str(diction['partner_owner_recid']),
'valide':'1'})
if( session_data and 'code_session' in session_data.keys() ):
code_session = session_data['code_session']
if (session_data and 'class_internal_url' in session_data.keys()):
class_interna_url = session_data['class_internal_url']
class_data = MYSY_GV.dbname['myclass'].find_one({'internal_url':str(class_interna_url),
'partner_owner_recid':str(diction['partner_owner_recid']),
'valide':'1'}, {'title':1})
if( class_data and "title" in class_data.keys() ):
class_title = class_data['title']
user['class_title'] = str(class_title)
user['code_session'] = str(code_session)
nb_val = nb_val + 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 vérifier la validité des information "
return False, " Impossible de vérifier la validité des informations "
"""
Emargement avec le QR CODE pour dire qu'on est présent ou absent
"""
def Update_Emargement_QR_Code_From_Inscription_No_Token(file_img=None, Folder=None, diction=None):
try:
diction = mycommon.strip_dictionary(diction)
"""
Verification des input acceptés
"""
field_list = ['partner_owner_recid', 'my_safe_token', 'tab_emargement_ids', 'is_present']
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 = ['partner_owner_recid', 'my_safe_token', 'tab_emargement_ids', 'is_present']
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
"""
local_status, my_partner = mycommon.Get_Connected_User_Partner_Data_From_RecID(
str(diction['partner_owner_recid']))
if (local_status is not True):
return local_status, my_partner
# Verifier que l'identifiant de l'emargement est valide
my_emargement_ids = ""
if ("tab_emargement_ids" in diction.keys()):
if diction['tab_emargement_ids']:
my_emargement_ids = diction['tab_emargement_ids']
tab_my_emargement_ids = str(my_emargement_ids).split(",")
for my_emargement_id in tab_my_emargement_ids:
is_emargement_valide_count = MYSY_GV.dbname['emargement'].count_documents({'emargement_qr_safe_token': str(diction['my_safe_token']),
'_id': ObjectId(str( my_emargement_id) ),
'partner_owner_recid': str(diction['partner_owner_recid']),
'statut': '0'})
if( is_emargement_valide_count != 1):
mycommon.myprint(
str(inspect.stack()[0][3]) + " L'identifiant de l'émargement "+str(my_emargement_id)+" est invalide ")
return False, " L'identifiant de l'émargement "+str(my_emargement_id)+" est invalide "
image_signature_manuelle_string = ""
if (file_img):
status, saved_file = mycommon.Upload_Save_IMG_File(file_img, Folder)
if (status is False):
mycommon.myprint(str(saved_file))
return False, str(saved_file)
#print(" signature manuelle = ", saved_file)
with open(saved_file, "rb") as imageFile:
image_signature_manuelle_string = base64.b64encode(imageFile.read()).decode()
tab_my_emargement_ids = str(my_emargement_ids).split(",")
for my_emargement_id in tab_my_emargement_ids:
data_cle = {'emargement_qr_safe_token': str(diction['my_safe_token']),
'_id': ObjectId(str(my_emargement_id)),
'partner_owner_recid': str(diction['partner_owner_recid']),
'statut': '0'}
print(" ### data_cle = ", data_cle)
is_present = ""
if ("is_present" in diction.keys()):
if diction['is_present']:
is_present = diction['is_present']
# Mettre à jour de l'emargement
data_update = {}
now = str(datetime.now().strftime("%d/%m/%Y, %H:%M:%S"))
data_update['date_update'] = now
data_update['statut'] = "2"
data_update['date_emargement'] = now
data_update['update_by'] = str(my_partner['_id'])
data_update["mysy_manual_signature_img"] = "data:image/png;base64," + image_signature_manuelle_string
if (is_present == "1"):
data_update['is_present'] = True
elif (is_present == "0"):
data_update['is_present'] = False
inserted_id = ""
result = MYSY_GV.dbname['emargement'].find_one_and_update(
data_cle,
{"$set": data_update},
upsert=False,
return_document=ReturnDocument.AFTER
)
return True, "L'émargement a été prise en compte"
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'émarger "

File diff suppressed because one or more lines are too long

View File

@ -582,7 +582,6 @@ def UpdateUserEmargementDate(diction):
Cette fonction genere un fichier pdf pour les liste d'emargement
"""
def GerneratePDFEmargementList(diction):
try:
field_list = ['session_id', 'email', 'date', 'token', 'class_internal_url', 'courrier_template_id']
@ -691,6 +690,13 @@ def GerneratePDFEmargementList(diction):
local_tmp['sequence_end'] = val_tmp['sequence_end']
local_tmp['is_present'] = val_tmp['is_present']
mysy_manual_signature_img = ""
if( "mysy_manual_signature_img" in val_tmp.keys() ):
mysy_manual_signature_img = val_tmp['mysy_manual_signature_img']
local_tmp['mysy_manual_signature_img'] = mysy_manual_signature_img
tab_users.append(local_tmp)

37
main.py
View File

@ -9987,15 +9987,15 @@ def Delete_Suivi_Pedagogique():
API pour créer un fichier QR code pour
les émargements
"""
@app.route('/myclass/api/Create_Emargement_QR_Code_From_Inscription/<token>/<session_id>/<tab_inscription_ids>', methods=['POST','GET'])
@app.route('/myclass/api/Create_Emargement_QR_Code_From_Inscription/<token>/<session_id>/<tab_emargement_ids>', methods=['POST','GET'])
@crossdomain(origin='*')
def Create_Emargement_QR_Code_From_Inscription(token, session_id, tab_inscription_ids):
def Create_Emargement_QR_Code_From_Inscription(token, session_id, tab_emargement_ids):
# On recupere le corps (payload) de la requete
payload = mycommon.strip_dictionary (request.form.to_dict())
payload = {}
payload['token'] = str(token)
payload['session_id'] = str(session_id)
payload['tab_inscription_ids'] = str(tab_inscription_ids)
payload['tab_emargement_ids'] = str(tab_emargement_ids)
print(" ### Create_Emargement_QR_Code_From_Inscription : payload = ",str(payload))
@ -10020,6 +10020,37 @@ def Check_Emargement_QR_Code_From_Inscription_No_Token():
"""
API qui permet de signer un emargement en partant d'un QR CODE
"""
@app.route('/myclass/api/Update_Emargement_QR_Code_From_Inscription_No_Token/', methods=['POST','GET'])
@crossdomain(origin='*')
def Update_Emargement_QR_Code_From_Inscription_No_Token():
# On recupere le corps (payload) de la requete
payload = mycommon.strip_dictionary (request.form.to_dict())
print(" ### Update_Emargement_QR_Code_From_Inscription_No_Token payload = ",payload)
file_img = None
if request.method == 'POST':
# Create variable for uploaded file
if ('signature_img' in request.files.keys() and request.files['signature_img']):
file_img = request.files['signature_img']
user_ip = ""
headers_list = request.headers.getlist("X-Forwarded-For")
user_ip = headers_list[0] if headers_list else request.remote_addr
if( "signature_img" in payload.keys() ):
del payload['signature_img']
status, retval = inscription.Update_Emargement_QR_Code_From_Inscription_No_Token(file_img, MYSY_GV.TEMPORARY_DIRECTORY_V2, payload)
return jsonify(status=status, message=retval)
if __name__ == '__main__':
print(" debut api")
context = SSL.Context(SSL.SSLv23_METHOD)