21/10/22 - 17h
parent
3f9343d2de
commit
8d506631ce
|
@ -117,6 +117,7 @@ def AddStagiairetoClass(diction):
|
|||
|
||||
mydata['date_update'] = str(datetime.now())
|
||||
mydata['status'] = "0" # 0 ==> Preinscription
|
||||
mydata['price'] = "0"
|
||||
|
||||
coll_inscription = MYSY_GV.dbname['inscription']
|
||||
|
||||
|
|
124
emargement.py
124
emargement.py
|
@ -81,6 +81,7 @@ def CreateTableauEmargement(diction):
|
|||
mydata['session_id'] = diction['session_id']
|
||||
session_id = diction['session_id']
|
||||
|
||||
|
||||
"""
|
||||
Recuperation des info de la session de formation
|
||||
"""
|
||||
|
@ -122,7 +123,7 @@ def CreateTableauEmargement(diction):
|
|||
##print(" ### date_emargement = "+str(date_emargement) + " < "+str(datetime.strptime(str(date_au), '%d/%m/%Y') ))
|
||||
|
||||
|
||||
print("#### Liste Date = "+str(liste_date))
|
||||
#print("#### Liste Date = "+str(liste_date))
|
||||
coll_emargement = MYSY_GV.dbname['emargement']
|
||||
|
||||
#Recuperation de la liste des participants dont l'inscription est validée
|
||||
|
@ -138,6 +139,11 @@ def CreateTableauEmargement(diction):
|
|||
my_local_data['date_update'] = str(datetime.now())
|
||||
|
||||
for local_date in liste_date :
|
||||
query_key = {}
|
||||
query_key['email'] = tmp_val['email']
|
||||
query_key['session_id'] = tmp_val['session_id']
|
||||
query_key['date'] = str(local_date)
|
||||
|
||||
new_my_local_data = {}
|
||||
new_my_local_data['email'] = tmp_val['email']
|
||||
new_my_local_data['nom'] = tmp_val['nom']
|
||||
|
@ -146,11 +152,18 @@ def CreateTableauEmargement(diction):
|
|||
new_my_local_data['class_internal_url'] = tmp_val['class_internal_url']
|
||||
new_my_local_data['date_update'] = str(datetime.now())
|
||||
new_my_local_data['date'] = str(local_date)
|
||||
new_my_local_data['matin'] = '0'
|
||||
new_my_local_data['apresmidi'] = '0'
|
||||
new_my_local_data['matin'] = False
|
||||
new_my_local_data['apresmidi'] = True
|
||||
|
||||
print("### emargement insertion de : "+str(new_my_local_data))
|
||||
coll_emargement.insert_one(new_my_local_data)
|
||||
|
||||
local_ret_val = coll_emargement.find_one_and_update(
|
||||
query_key,
|
||||
{"$set": new_my_local_data},
|
||||
upsert=True,
|
||||
return_document=ReturnDocument.AFTER
|
||||
)
|
||||
|
||||
|
||||
|
||||
return True, "ok"
|
||||
|
@ -228,3 +241,106 @@ def GetTableauEmargement(diction):
|
|||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
|
||||
return False, "Impossible de recuperer le tableau d'emargement"
|
||||
|
||||
"""
|
||||
Fonction de mise à jour de l'emargement d'une personne sur une date
|
||||
"""
|
||||
def UpdateUserEmargementDate(diction):
|
||||
try:
|
||||
'''
|
||||
# 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.
|
||||
'''
|
||||
field_list = [ 'session_id', 'token', 'email', 'date', 'matin', 'apresmidi']
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
if val not in field_list:
|
||||
mycommon.myprint(str(inspect.stack()[0][
|
||||
3]) + " - Creation partner account : Le champ '" + val + "' n'est pas autorisé, Creation partenaire annulée")
|
||||
return False, "Impossible de créer la liste d'emargement. Toutes les informations fournies ne sont pas valables"
|
||||
|
||||
"""
|
||||
Verification de la liste des champs obligatoires
|
||||
"""
|
||||
field_list_obligatoire = [ 'session_id', 'token', 'email', 'date']
|
||||
|
||||
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, "Impossible de créer la liste d'emargement, Toutes les informations necessaires n'ont pas été fournies"
|
||||
|
||||
mydata = {}
|
||||
|
||||
my_token = ""
|
||||
if ("token" in diction.keys()):
|
||||
if diction['token']:
|
||||
my_token = diction['token']
|
||||
|
||||
my_email = ""
|
||||
if ("email" in diction.keys()):
|
||||
if diction['email']:
|
||||
my_email = diction['email']
|
||||
mydata['email'] = diction['email']
|
||||
|
||||
my_date = ""
|
||||
if ("date" in diction.keys()):
|
||||
if diction['date']:
|
||||
my_date = diction['date']
|
||||
mydata['date'] = diction['date']
|
||||
|
||||
my_matin = ""
|
||||
if ("matin" in diction.keys()):
|
||||
if diction['matin']:
|
||||
my_matin = diction['matin']
|
||||
|
||||
my_apresmidi = ""
|
||||
if ("apresmidi" in diction.keys()):
|
||||
if diction['apresmidi']:
|
||||
my_apresmidi = diction['apresmidi']
|
||||
|
||||
partner_recid = mycommon.get_parnter_recid_from_token(my_token)
|
||||
if (partner_recid is False):
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - Impossible de valider l'emargement ")
|
||||
return False, "Impossible de valider l'emargement "
|
||||
|
||||
session_id = ""
|
||||
if ("session_id" in diction.keys()):
|
||||
if diction['session_id']:
|
||||
mydata['session_id'] = diction['session_id']
|
||||
session_id = diction['session_id']
|
||||
|
||||
mydata['date_update'] = str(datetime.now())
|
||||
|
||||
if( my_matin == "1"):
|
||||
mydata['matin'] = True
|
||||
elif (my_matin == "0"):
|
||||
mydata['matin'] = False
|
||||
|
||||
if (my_apresmidi == "1"):
|
||||
mydata['apresmidi'] = True
|
||||
elif (my_apresmidi == "0"):
|
||||
mydata['apresmidi'] = False
|
||||
|
||||
|
||||
query_key = {}
|
||||
query_key['email'] = mydata['email']
|
||||
query_key['session_id'] = mydata['session_id']
|
||||
query_key['date'] = str(my_date)
|
||||
|
||||
coll_emargement = MYSY_GV.dbname['emargement']
|
||||
local_ret_val = coll_emargement.find_one_and_update(
|
||||
query_key,
|
||||
{"$set": mydata},
|
||||
upsert=False,
|
||||
return_document=ReturnDocument.AFTER
|
||||
)
|
||||
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " OK, la liste d'emargement de la session "+str( mydata['session_id'])+" a été mise à jour")
|
||||
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) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
|
||||
return False, "Impossible de valider l'émargement"
|
14
main.py
14
main.py
|
@ -1762,7 +1762,7 @@ Cette API Crée la liste d'emargement
|
|||
def CreateTableauEmargement():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = request.form.to_dict()
|
||||
print(" ### CreateTableauEmargement : payload = ",payload)
|
||||
print(" ### CreateTableauEmargement : payload = ",str(payload))
|
||||
localStatus, message= emargement.CreateTableauEmargement(payload)
|
||||
return jsonify(status=localStatus, message=message )
|
||||
|
||||
|
@ -1778,6 +1778,18 @@ def GetTableauEmargement():
|
|||
localStatus, message= emargement.GetTableauEmargement(payload)
|
||||
return jsonify(status=localStatus, message=message )
|
||||
|
||||
"""
|
||||
API de mise à jour de l'emargement d'une personne
|
||||
"""
|
||||
@app.route('/myclass/api/UpdateUserEmargementDate/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def UpdateUserEmargementDate():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = request.form.to_dict()
|
||||
print(" ### UpdateUserEmargementDate : payload = ",str(payload))
|
||||
localStatus, message= emargement.UpdateUserEmargementDate(payload)
|
||||
return jsonify(status=localStatus, message=message )
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
Loading…
Reference in New Issue