"Feuille de staff mise à jour via Ajax"
This commit is contained in:
parent
4ff620e51a
commit
31fd1aba52
@ -334,6 +334,19 @@ def delete_user(user_id):
|
|||||||
print "------------------------------"
|
print "------------------------------"
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def get_user_name(user_id):
|
||||||
|
""" Get pseudo from user ID """
|
||||||
|
try:
|
||||||
|
user = Tetawebapp_users.query.filter_by(id=int(user_id)).first()
|
||||||
|
return user.name
|
||||||
|
except Exception as e:
|
||||||
|
print "[+] Error at get_pseudo:"
|
||||||
|
print "------------------------------"
|
||||||
|
print "%s" % e.message
|
||||||
|
print "------------------------------"
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
def save_turn(role_id, day, start, end, num_slot):
|
def save_turn(role_id, day, start, end, num_slot):
|
||||||
""" Save a new turn """
|
""" Save a new turn """
|
||||||
days = ['2018-05-08', '2018-05-09', '2018-05-10', '2018-05-11', '2018-05-12', '2018-05-13', '2018-05-14']
|
days = ['2018-05-08', '2018-05-09', '2018-05-10', '2018-05-11', '2018-05-12', '2018-05-13', '2018-05-14']
|
||||||
@ -1117,16 +1130,9 @@ def clear_staff_slot(TURN_ID, SLOT_ID):
|
|||||||
turn_id = int(TURN_ID.encode('utf-8'))
|
turn_id = int(TURN_ID.encode('utf-8'))
|
||||||
slot_id = int(SLOT_ID.encode('utf-8'))
|
slot_id = int(SLOT_ID.encode('utf-8'))
|
||||||
user_id = session['user_id']
|
user_id = session['user_id']
|
||||||
message = "Erreur lors de l'enregistrement des données"
|
|
||||||
if (drop_staff_slot(turn_id, slot_id, user_id)):
|
if (drop_staff_slot(turn_id, slot_id, user_id)):
|
||||||
message = ''
|
return " "
|
||||||
page = str(request.url_rule)
|
return "Erreur"
|
||||||
menu = get_menu(page)
|
|
||||||
turns = turns_list()
|
|
||||||
staffs = get_staffs()
|
|
||||||
roles = get_roles()
|
|
||||||
user_id = session['user_id']
|
|
||||||
return render_template('staffsheet.html', menu=menu, turns=turns, staffs=staffs, user_id=user_id, roles=roles, message=message.decode('utf-8'))
|
|
||||||
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")
|
||||||
@ -1141,16 +1147,11 @@ def update_staff_slot(TURN_ID, SLOT_ID):
|
|||||||
turn_id = int(TURN_ID.encode('utf-8'))
|
turn_id = int(TURN_ID.encode('utf-8'))
|
||||||
slot_id = int(SLOT_ID.encode('utf-8'))
|
slot_id = int(SLOT_ID.encode('utf-8'))
|
||||||
user_id = session['user_id']
|
user_id = session['user_id']
|
||||||
message = "Erreur lors de l'enregistrement des données"
|
user_name = get_user_name(user_id)
|
||||||
|
if user_name != None:
|
||||||
if (save_staff_slot(turn_id, slot_id, user_id)):
|
if (save_staff_slot(turn_id, slot_id, user_id)):
|
||||||
message = ''
|
return user_name
|
||||||
page = str(request.url_rule)
|
return "Erreur"
|
||||||
menu = get_menu(page)
|
|
||||||
turns = turns_list()
|
|
||||||
staffs = get_staffs()
|
|
||||||
roles = get_roles()
|
|
||||||
user_id = session['user_id']
|
|
||||||
return render_template('staffsheet.html', menu=menu, turns=turns, staffs=staffs, user_id=user_id, roles=roles, message=message.decode('utf-8'))
|
|
||||||
except AttributeError as e:
|
except AttributeError as e:
|
||||||
# User is not logged in
|
# User is not logged in
|
||||||
print e
|
print e
|
||||||
|
@ -60,14 +60,18 @@ function save_turn() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function update_sheet(turn, slot) {
|
function update_sheet(obj, turn, slot) {
|
||||||
document.location = '/staffsheet/update/'+turn+'/'+slot;
|
var url = '/staffsheet/update/'+turn+'/'+slot;
|
||||||
|
get_html_from_ajax(obj, url);
|
||||||
|
obj.onclick=function (){ return clear_sheet(obj, turn, slot);}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function clear_sheet(turn, slot) {
|
function clear_sheet(obj, turn, slot) {
|
||||||
if (confirm("Voulez-vous vraiment libérer ce créneau ? \n\n Confirmer ?")) {
|
if (confirm("Voulez-vous vraiment libérer ce créneau ? \n\n Confirmer ?")) {
|
||||||
document.location = '/staffsheet/clear/'+turn+'/'+slot;
|
var url = '/staffsheet/clear/'+turn+'/'+slot;
|
||||||
|
get_html_from_ajax(obj, url);
|
||||||
|
obj.onclick=function (){ return update_sheet(obj, turn, slot);}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -67,14 +67,14 @@
|
|||||||
{% if allocated_slot.append(sslot[0].slot_num) %}
|
{% if allocated_slot.append(sslot[0].slot_num) %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if user_id == sslot[0].user_id %}
|
{% if user_id == sslot[0].user_id %}
|
||||||
<div class='sheet_user{{ num_slot }} {{ border }}' onclick='javascript:clear_sheet({{ turn_id }}, {{ slot }})'>{{ sslot[1] }}</div>
|
<div class='sheet_user{{ num_slot }} {{ border }}' id='staff_{{ turn_id }}_{{ slot }}' onclick='javascript:clear_sheet(this, {{ turn_id }}, {{ slot }})'>{{ sslot[1] }}</div>
|
||||||
{% else %}
|
{% else %}
|
||||||
<div class='sheet_user{{ num_slot }} {{ border }}' style='cursor: text;'>{{ sslot[1] }}</div>
|
<div class='sheet_user{{ num_slot }} {{ border }}' id='staff_{{ turn_id }}_{{ slot }}' style='cursor: text;'>{{ sslot[1] }}</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% if slot not in allocated_slot %}
|
{% if slot not in allocated_slot %}
|
||||||
<div class='sheet_user{{ num_slot }} {{ border }}' onclick='javascript:update_sheet({{ turn_id }}, {{ slot }})'> </div>
|
<div class='sheet_user{{ num_slot }} {{ border }}' id='staff_{{ turn_id }}_{{ slot }}' onclick='javascript:update_sheet(this, {{ turn_id }}, {{ slot }})'> </div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user