Skip to content

Commit 75cf8b2

Browse files
committed
Showing data for on and off floor upperclassmen
1 parent 2150eff commit 75cf8b2

File tree

2 files changed

+24
-10
lines changed

2 files changed

+24
-10
lines changed

packet/routes/upperclassmen.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1+
from datetime import datetime
2+
from itertools import chain
3+
14
from flask import redirect, render_template
25

36
from packet import auth, app
4-
from packet.models import UpperSignature
7+
from packet.models import Packet
58
from packet.utils import before_request
69

710

@@ -15,5 +18,16 @@ def index():
1518
@auth.oidc_auth
1619
@before_request
1720
def upperclassman(uid, info=None):
18-
signatures = UpperSignature.query.filter_by(member=uid).order_by(UpperSignature.signed.desc())
19-
return render_template("upperclassman.html", info=info, signatures=signatures, member=uid)
21+
open_packets = Packet.query.filter(Packet.end > datetime.now()).filter(Packet.start < datetime.now()).all()
22+
23+
for packet in open_packets:
24+
packet.did_sign = False
25+
26+
for sig in chain(filter(lambda sig: sig.signed, packet.upper_signatures), packet.misc_signatures):
27+
if sig.member == uid:
28+
packet.did_sign = True
29+
break
30+
31+
open_packets.sort(key=lambda x: x.did_sign, reverse=True)
32+
33+
return render_template("upperclassman.html", info=info, open_packets=open_packets, member=uid)

packet/templates/upperclassman.html

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,20 @@ <h3 class="page-title">{{ get_display_name(member) }}</h3>
2323
</tr>
2424
</thead>
2525
<tbody>
26-
{% for m in signatures %}
26+
{% for packet in open_packets %}
2727
{# Using inline style because of how themeswitcher loads the css theme :( #}
28-
<tr {% if m.signed %}style="background-color: #4caf505e" {% endif %}>
28+
<tr {% if packet.did_sign %}style="background-color: #4caf505e" {% endif %}>
2929
<td>
30-
<a href="/packet/{{ m.packet.freshman.rit_username }}">
30+
<a href="/packet/{{ packet.freshman.rit_username }}">
3131
<img class="eval-user-img"
32-
alt="{{ m.packet.freshman.name }}"
33-
src="https://profiles.csh.rit.edu/image/{{ m.packet.freshman.rit_username }}"
32+
alt="{{ packet.freshman.name }}"
33+
src="https://profiles.csh.rit.edu/image/{{ packet.freshman.rit_username }}"
3434
width="25"
35-
height="25"/> {{ m.packet.freshman.name }} ({{ m.packet.freshman.rit_username }})
35+
height="25"/> {{ packet.freshman.name }} ({{ packet.freshman.rit_username }})
3636
</a>
3737
</td>
3838
<td width="15%">
39-
{% if m.signed %}
39+
{% if packet.did_sign %}
4040
<i class="fas fa-check"></i>
4141
{% else %}
4242
<i class="fas fa-times"></i>

0 commit comments

Comments
 (0)