-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathadmin.py
More file actions
43 lines (34 loc) · 1.3 KB
/
admin.py
File metadata and controls
43 lines (34 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
from flask import render_template
from packet import app
from packet.models import Packet, Freshman
from packet.routes.shared import packet_sort_key
from packet.utils import before_request, packet_auth, admin_auth
from packet.log_utils import log_cache, log_time
@app.route('/admin/packets')
@log_cache
@packet_auth
@admin_auth
@before_request
@log_time
def admin_packets(info=None):
open_packets = Packet.open_packets()
# Pre-calculate and store the return values of did_sign(), signatures_received(), and signatures_required()
for packet in open_packets:
packet.did_sign_result = packet.did_sign(info['uid'], app.config['REALM'] == 'csh')
packet.signatures_received_result = packet.signatures_received()
packet.signatures_required_result = packet.signatures_required()
open_packets.sort(key=packet_sort_key, reverse=True)
return render_template('admin_packets.html',
open_packets=open_packets,
info=info)
@app.route('/admin/freshmen')
@log_cache
@packet_auth
@admin_auth
@before_request
@log_time
def admin_freshmen(info=None):
all_freshmen = Freshman.query.limit(300).all()
return render_template('admin_freshmen.html',
all_freshmen=all_freshmen,
info=info)