correction des routes suite aux modifications du frontend
This commit is contained in:
@@ -76,13 +76,20 @@ def retreive_scheduler():
|
||||
try:
|
||||
with open(current_app.config['DB_PATH'], 'r') as f:
|
||||
data = json.load(f)
|
||||
content = []
|
||||
content = {'mode':'', 'days':[]}
|
||||
if 'OPERATION' in data:
|
||||
content['mode'] = data['OPERATION']
|
||||
else:
|
||||
abort(status.HTTP_406_NOT_ACCEPTABLE, description="mode d'opération manquant en base de données")
|
||||
|
||||
sched = []
|
||||
if 'HORAIRES' in data:
|
||||
for day in data['HORAIRES']:
|
||||
h = []
|
||||
for hour in data['HORAIRES'][day]:
|
||||
h.append(hour)
|
||||
content.append({'name': day, 'horaires':h})
|
||||
sched.append({'name': day, 'horaires': h})
|
||||
content['days'] = sched
|
||||
else:
|
||||
abort(status.HTTP_406_NOT_ACCEPTABLE, description="horaire manquant en base de données")
|
||||
except FileNotFoundError as e:
|
||||
@@ -108,8 +115,13 @@ def update_scheduler():
|
||||
current_app.logger.error("Fichier ({}) manquant".format(current_app.config['DB_PATH']))
|
||||
abort(status.HTTP_406_NOT_ACCEPTABLE, description="Fichier manquant")
|
||||
|
||||
if 'mode' not in data_req or 'days' not in data_req:
|
||||
current_app.logger.error("paramètre(s) manquant(s) dans la requete")
|
||||
abort(status.HTTP_406_NOT_ACCEPTABLE, description="Paramètre(s) manquant(s)")
|
||||
|
||||
data_db['OPERATION'] = data_req['mode']
|
||||
for day in data_db['HORAIRES']:
|
||||
for d in data_req:
|
||||
for d in data_req['days']:
|
||||
if 'name' in d and d['name'] == day:
|
||||
data_db['HORAIRES'][day] = d['horaires']
|
||||
elif 'name' not in d:
|
||||
|
||||
Reference in New Issue
Block a user