File tree Expand file tree Collapse file tree 2 files changed +19
-3
lines changed
Expand file tree Collapse file tree 2 files changed +19
-3
lines changed Original file line number Diff line number Diff line change 11from flask import render_template
2+ from datetime import datetime
3+ from itertools import chain
24
35from packet import auth , app
46from packet .models import Freshman , Packet
@@ -23,5 +25,19 @@ def freshman_packet(uid, info=None):
2325@auth .oidc_auth
2426@before_request
2527def packets (info = None ):
26- packets = Packet .query .all ()
28+ packets = Packet .query .filter (Packet .end > datetime .now ()).filter (Packet .start < datetime .now ()).all ()
29+
30+ # Add the did_sign flag
31+ if app .config ["REALM" ] == "csh" :
32+ # User is an upperclassman
33+ for packet in packets :
34+ for sig in filter (lambda sig : sig .member == info ["uid" ], chain (packet .upper_signatures ,
35+ packet .misc_signatures )):
36+ packet .did_sign = sig .signed
37+ else :
38+ # User is a freshman
39+ for packet in packets :
40+ for sig in filter (lambda sig : sig .freshman_username == info ["uid" ], packet .fresh_signatures ):
41+ packet .did_sign = sig .signed
42+
2743 return render_template ("active_packets.html" , info = info , packets = packets )
Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ <h3 class="page-title">Active Packets</h3>
2626 < tbody >
2727 {% for packet in packets %}
2828 {% if packet.is_open() %}
29- < tr >
29+ < tr {% if packet.did_sign %}style =" background-color: #4caf505e " {% endif %} >
3030 < td >
3131 < a href ="/packet/{{ packet.freshman.rit_username }} ">
3232 < img class ="eval-user-img "
@@ -41,7 +41,7 @@ <h3 class="page-title">Active Packets</h3>
4141 </ td >
4242 {% if info.onfloor or info.realm == "csh" %}
4343 < td class ="sign-packet " align ="right ">
44- {% if not packet_signed %}
44+ {% if not packet.did_sign %}
4545 < button class ="btn btn-primary sign-button "
4646 data-freshman_uid ="{{ packet.freshman.rit_username }} "
4747 data-freshman_name ="{{ packet.freshman.name }} "> Sign
You can’t perform that action at this time.
0 commit comments