Skip to content

Commit 5e63cbd

Browse files
authored
Merge pull request #20 from ComputerScienceHouse/current-packets-page
Add current packets collection logic
2 parents 33f7e48 + 0bf270a commit 5e63cbd

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

packet/routes/shared.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
from flask import render_template
2+
from datetime import datetime
3+
from itertools import chain
24

35
from packet import auth, app
46
from packet.models import Freshman, Packet
@@ -23,5 +25,19 @@ def freshman_packet(uid, info=None):
2325
@auth.oidc_auth
2426
@before_request
2527
def 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)

packet/templates/active_packets.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)