Skip to content

Commit 54e90d1

Browse files
committed
Add page for evals with packets opened in the past semester
1 parent e5761dc commit 54e90d1

File tree

8 files changed

+61
-5
lines changed

8 files changed

+61
-5
lines changed

.tool-versions

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
python 3.9.7
2+
nodejs 10.24.1

packet/models.py

+7
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,13 @@ def open_packets(cls) -> list['Packet']:
129129
"""
130130
return cls.query.filter(cls.start < datetime.now(), cls.end > datetime.now()).all()
131131

132+
@classmethod
133+
def opened_after(cls, date: datetime) -> list['Packet']:
134+
"""
135+
Helper method for fetching all packets opened after a given date
136+
"""
137+
return cls.query.filter(cls.start > date).all()
138+
132139
@classmethod
133140
def by_id(cls, packet_id: int) -> 'Packet':
134141
"""

packet/routes/admin.py

+23
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from flask import render_template
2+
import datetime
23

34
from packet import app
45
from packet.models import Packet, Freshman
@@ -29,6 +30,28 @@ def admin_packets(info=None):
2930
info=info)
3031

3132

33+
@app.route('/admin/past-packets')
34+
@log_cache
35+
@packet_auth
36+
@admin_auth
37+
@before_request
38+
@log_time
39+
def admin_past_packets(info=None):
40+
open_packets = Packet.opened_after(datetime.date.today() - datetime.timedelta(days=(30 * 4)))
41+
42+
# Pre-calculate and store the return values of did_sign(), signatures_received(), and signatures_required()
43+
for packet in open_packets:
44+
packet.did_sign_result = packet.did_sign(info['uid'], app.config['REALM'] == 'csh')
45+
packet.signatures_received_result = packet.signatures_received()
46+
packet.signatures_required_result = packet.signatures_required()
47+
48+
open_packets.sort(key=packet_sort_key, reverse=False)
49+
50+
return render_template('admin_past_packets.html',
51+
open_packets=open_packets,
52+
info=info)
53+
54+
3255
@app.route('/admin/freshmen')
3356
@log_cache
3457
@packet_auth
+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{% extends "extend/base.html" %}
2+
3+
{% block body %}
4+
<div class="container main">
5+
<div class="ml-4">
6+
<div class="row justify-content-between w-100">
7+
<div class="col-xs-10">
8+
<h4 class="page-title">Past Packets</h4>
9+
</div>
10+
</div>
11+
</div>
12+
<div id="eval-blocks">
13+
{% include 'include/admin/open_packets.html' %}
14+
</div>
15+
</div>
16+
{% endblock %}
17+
18+
{% block scripts %}
19+
{{ super() }}
20+
<script src="{{ url_for('static', filename='js/admin.min.js') }}"></script>
21+
{% endblock %}

packet/templates/include/nav.html

+2-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
</a>
2727
<div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
2828
<a class="dropdown-item" href="{{ url_for("admin_freshmen") }}">Freshmen</a>
29-
<a class="dropdown-item" href="{{ url_for("admin_packets") }}">Packets</a>
29+
<a class="dropdown-item" href="{{ url_for("admin_packets") }}">Active Packets</a>
30+
<a class="dropdown-item" href="{{ url_for("admin_past_packets") }}">Past Packets</a>
3031
</div>
3132
</li>
3233
{% endif %}

packet/utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def before_reqest_callback() -> Any:
7070
"""
7171
Pre-request function to ensure we're on the right URL before OIDC sees anything
7272
"""
73-
if urlparse(request.base_url).hostname != app.config['SERVER_NAME']:
73+
if urlparse(request.base_url).hostname != app.config['SERVER_NAME'].split(':')[0]:
7474
return redirect(request.base_url.replace(urlparse(request.base_url).hostname,
7575
app.config['SERVER_NAME']), code=302)
7676
return None

requirements.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Flask-Mail==0.9.1
33
Flask-Migrate~=2.7.0
44
Flask-pyoidc~=3.7.0
55
Flask~=1.1.4
6-
csh_ldap~=2.3.1
6+
csh_ldap~=2.4.0
77
ddtrace==1.1.4
88
flask_sqlalchemy~=2.5.1
99
gunicorn~=20.0.4

requirements.txt

+4-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ click==7.1.2
2828
# pip-tools
2929
cryptography==37.0.2
3030
# via oic
31-
csh-ldap==2.3.1
31+
csh-ldap==2.4.0
3232
# via -r requirements.in
3333
ddsketch==2.0.3
3434
# via ddtrace
@@ -60,6 +60,8 @@ flask-sqlalchemy==2.5.1
6060
# flask-migrate
6161
future==0.18.2
6262
# via pyjwkest
63+
greenlet==1.1.3
64+
# via sqlalchemy
6365
gunicorn==20.0.4
6466
# via -r requirements.in
6567
idna==3.3
@@ -129,7 +131,7 @@ pylint-quotes==0.2.1
129131
# via -r requirements.in
130132
pyparsing==3.0.9
131133
# via packaging
132-
python-ldap==3.0.0
134+
python-ldap==3.4.0
133135
# via csh-ldap
134136
requests==2.27.1
135137
# via

0 commit comments

Comments
 (0)