Browse Source

Admin can select staffer

Doug Le Tough 1 year ago
parent
commit
28f4ce1af2
2 changed files with 26 additions and 1 deletions
  1. 14
    1
      participate.py
  2. 12
    0
      templates/staffsheet.html

+ 14
- 1
participate.py View File

@@ -544,6 +544,17 @@ def turns_list():
544 544
 ########################################################################
545 545
 # Staffs
546 546
 ########################################################################
547
+def get_staffers():
548
+  try:
549
+    staffers = Tetawebapp_users.query(Tetawebapp_users.id > 1).all()
550
+    return staffers
551
+  except Exception as e:
552
+    print "[+] Error at get_staffers:"
553
+    print "------------------------------"
554
+    print "%s" % e.message
555
+    print "------------------------------"
556
+    return False
557
+
547 558
 def get_staffs():
548 559
   """ """
549 560
   try:
@@ -853,14 +864,16 @@ def logout():
853 864
 @check_session
854 865
 def staffsheet():
855 866
   try:
867
+    is_admin = session['is_admin']
856 868
     user_id = session['user_id']
857 869
     if len(check_user_info()) == 0:
858 870
       page = str(request.url_rule)
859 871
       menu = get_menu(page)
860 872
       turns = turns_list()
861 873
       staffs = get_staffs()
874
+      staffers = get_staffers()
862 875
       roles = get_roles()
863
-      return render_template('staffsheet.html', menu=menu, turns=turns, staffs=staffs, user_id=user_id, roles=roles, message='')
876
+      return render_template('staffsheet.html', menu=menu, turns=turns, staffs=staffs, staffers=staffers, user_id=user_id, is_admin=is_admin, roles=roles, message='')
864 877
     else:
865 878
      return account()
866 879
   except AttributeError as e:

+ 12
- 0
templates/staffsheet.html View File

@@ -68,6 +68,18 @@
68 68
         {%           endif %}
69 69
         {%           if user_id == sslot[0].user_id %}
70 70
             <div class='sheet_user{{ num_slot }} {{ border }}' id='staff_{{ turn_id }}_{{ slot }}' onclick='javascript:clear_sheet(this, {{ turn_id }}, {{ slot }})'>{{ sslot[1] }}</div>
71
+        {%           elif is_admin %}
72
+            <div class='sheet_user{{ num_slot }} {{ border }}'>
73
+              <select id='staff_{{ turn_id }}_{{ slot }}' onchange='javascript:select_user(this, {{ turn_id }}, {{ slot }})'>
74
+        {%              for staffer in staffers %}
75
+        {%                if staffer.name == sslot[1] %}
76
+                <option value='{{ staffer.id }}'>{{ staffer.name }}</option>
77
+        {%                else %}
78
+                <option selected='selected' value='{{ staffer.id }}'>{{ staffer.name }}</option>
79
+        {%                endif %}
80
+        {%              endfor %}
81
+              </select>
82
+            </div>
71 83
         {%           else %}
72 84
             <div class='sheet_user{{ num_slot }} {{ border }}' id='staff_{{ turn_id }}_{{ slot }}' style='cursor: text;'>{{ sslot[1] }}</div>
73 85
         {%           endif %}

Loading…
Cancel
Save