From bf1e2cc97094972c6eb79ec6aea8b501568dda46 Mon Sep 17 00:00:00 2001 From: Doug Le Tough Date: Wed, 7 Mar 2018 15:43:20 +0100 Subject: [PATCH] "Reload stafsheet if trying to update a filled staff" --- participate.py | 9 +++++---- static/scripts/tetawebapp.js | 3 +++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/participate.py b/participate.py index 8c01d1b..96ec376 100755 --- a/participate.py +++ b/participate.py @@ -534,7 +534,8 @@ def save_staff_slot(turn_id, slot_id, user_id): return False if commit != None: return False - return True + return True + return False def get_roles(): """ Get full roles list """ @@ -542,7 +543,7 @@ def get_roles(): roles = Tetawebapp_roles.query.filter(Tetawebapp_roles.id > 3).all() return roles except Exception as e: - print "[+] Error at get_staffs:" + print "[+] Error at get_roles:" print "------------------------------" print "%s" % e.message print "------------------------------" @@ -1132,7 +1133,7 @@ def clear_staff_slot(TURN_ID, SLOT_ID): user_id = session['user_id'] if (drop_staff_slot(turn_id, slot_id, user_id)): return " " - return "Erreur" + return "KO" except AttributeError: # User is not logged in return render_template('login_or_register.html', message="Utilisateur ou mot de passe invalide") @@ -1151,7 +1152,7 @@ def update_staff_slot(TURN_ID, SLOT_ID): if user_name != None: if (save_staff_slot(turn_id, slot_id, user_id)): return user_name - return "Erreur" + return "KO" except AttributeError as e: # User is not logged in print e diff --git a/static/scripts/tetawebapp.js b/static/scripts/tetawebapp.js index e6ffbea..0cff5da 100644 --- a/static/scripts/tetawebapp.js +++ b/static/scripts/tetawebapp.js @@ -137,6 +137,9 @@ function get_html_from_ajax(obj, url) { xhttp.onreadystatechange = function() { if (xhttp.readyState == 4 && xhttp.status == 200) { var response = xhttp.responseText; + if (response == "KO"){ + document.location.reload(true); + } obj.innerHTML = response; } };