Admin can select staffer

This commit is contained in:
Doug Le Tough 2019-02-26 15:31:34 +11:00
parent 2d56973682
commit 28f4ce1af2
2 changed files with 26 additions and 1 deletions

View File

@ -544,6 +544,17 @@ def turns_list():
######################################################################## ########################################################################
# Staffs # Staffs
######################################################################## ########################################################################
def get_staffers():
try:
staffers = Tetawebapp_users.query(Tetawebapp_users.id > 1).all()
return staffers
except Exception as e:
print "[+] Error at get_staffers:"
print "------------------------------"
print "%s" % e.message
print "------------------------------"
return False
def get_staffs(): def get_staffs():
""" """ """ """
try: try:
@ -853,14 +864,16 @@ def logout():
@check_session @check_session
def staffsheet(): def staffsheet():
try: try:
is_admin = session['is_admin']
user_id = session['user_id'] user_id = session['user_id']
if len(check_user_info()) == 0: if len(check_user_info()) == 0:
page = str(request.url_rule) page = str(request.url_rule)
menu = get_menu(page) menu = get_menu(page)
turns = turns_list() turns = turns_list()
staffs = get_staffs() staffs = get_staffs()
staffers = get_staffers()
roles = get_roles() roles = get_roles()
return render_template('staffsheet.html', menu=menu, turns=turns, staffs=staffs, user_id=user_id, roles=roles, message='') return render_template('staffsheet.html', menu=menu, turns=turns, staffs=staffs, staffers=staffers, user_id=user_id, is_admin=is_admin, roles=roles, message='')
else: else:
return account() return account()
except AttributeError as e: except AttributeError as e:

View File

@ -68,6 +68,18 @@
{% endif %} {% endif %}
{% if user_id == sslot[0].user_id %} {% if user_id == sslot[0].user_id %}
<div class='sheet_user{{ num_slot }} {{ border }}' id='staff_{{ turn_id }}_{{ slot }}' onclick='javascript:clear_sheet(this, {{ 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>
{% elif is_admin %}
<div class='sheet_user{{ num_slot }} {{ border }}'>
<select id='staff_{{ turn_id }}_{{ slot }}' onchange='javascript:select_user(this, {{ turn_id }}, {{ slot }})'>
{% for staffer in staffers %}
{% if staffer.name == sslot[1] %}
<option value='{{ staffer.id }}'>{{ staffer.name }}</option>
{% else %}
<option selected='selected' value='{{ staffer.id }}'>{{ staffer.name }}</option>
{% endif %}
{% endfor %}
</select>
</div>
{% else %} {% else %}
<div class='sheet_user{{ num_slot }} {{ border }}' id='staff_{{ turn_id }}_{{ slot }}' 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 %}