"Reload stafsheet if trying to update a filled staff"

This commit is contained in:
Doug Le Tough 2018-03-07 15:43:20 +01:00
parent 31fd1aba52
commit bf1e2cc970
2 changed files with 8 additions and 4 deletions

View File

@ -534,7 +534,8 @@ def save_staff_slot(turn_id, slot_id, user_id):
return False return False
if commit != None: if commit != None:
return False return False
return True return True
return False
def get_roles(): def get_roles():
""" Get full roles list """ """ Get full roles list """
@ -542,7 +543,7 @@ def get_roles():
roles = Tetawebapp_roles.query.filter(Tetawebapp_roles.id > 3).all() roles = Tetawebapp_roles.query.filter(Tetawebapp_roles.id > 3).all()
return roles return roles
except Exception as e: except Exception as e:
print "[+] Error at get_staffs:" print "[+] Error at get_roles:"
print "------------------------------" print "------------------------------"
print "%s" % e.message print "%s" % e.message
print "------------------------------" print "------------------------------"
@ -1132,7 +1133,7 @@ def clear_staff_slot(TURN_ID, SLOT_ID):
user_id = session['user_id'] user_id = session['user_id']
if (drop_staff_slot(turn_id, slot_id, user_id)): if (drop_staff_slot(turn_id, slot_id, user_id)):
return " " return " "
return "Erreur" return "KO"
except AttributeError: except AttributeError:
# User is not logged in # User is not logged in
return render_template('login_or_register.html', message="Utilisateur ou mot de passe invalide") 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 user_name != None:
if (save_staff_slot(turn_id, slot_id, user_id)): if (save_staff_slot(turn_id, slot_id, user_id)):
return user_name return user_name
return "Erreur" return "KO"
except AttributeError as e: except AttributeError as e:
# User is not logged in # User is not logged in
print e print e

View File

@ -137,6 +137,9 @@ function get_html_from_ajax(obj, url) {
xhttp.onreadystatechange = function() { xhttp.onreadystatechange = function() {
if (xhttp.readyState == 4 && xhttp.status == 200) { if (xhttp.readyState == 4 && xhttp.status == 200) {
var response = xhttp.responseText; var response = xhttp.responseText;
if (response == "KO"){
document.location.reload(true);
}
obj.innerHTML = response; obj.innerHTML = response;
} }
}; };