Skip to content

Commit c5559aa

Browse files
committed
Refactoring, docs, and removed dead code
1 parent 803f865 commit c5559aa

File tree

5 files changed

+16
-17
lines changed

5 files changed

+16
-17
lines changed

config.env.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@
1414
OIDC_CLIENT_ID = environ.get("PACKET_OIDC_CLIENT_ID", "packet")
1515
OIDC_CLIENT_SECRET = environ.get("PACKET_OIDC_CLIENT_SECRET", "PLEASE_REPLACE_ME")
1616

17-
# SAML config
18-
SAML_METADATA_URL = environ.get("PACKET_SAML_METADATA_URL", "https://shibboleth.main.ad.rit.edu/rit-metadata.xml")
19-
2017
# SQLAlchemy config
2118
SQLALCHEMY_DATABASE_URI = environ.get("PACKET_DATABASE_URI", None)
2219
SQLALCHEMY_TRACK_MODIFICATIONS = False

packet/__init__.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,15 @@
3333
})
3434

3535
# LDAP
36-
_ldap = csh_ldap.CSHLDAP(app.config['LDAP_BIND_DN'], app.config['LDAP_BIND_PASS'])
36+
_ldap = csh_ldap.CSHLDAP(app.config["LDAP_BIND_DN"], app.config["LDAP_BIND_PASS"])
3737

3838
# pylint: disable=wrong-import-position
39+
from . import models
3940
from . import context_processors
41+
from . import commands
42+
from .routes import api, shared
4043

4144
if app.config["REALM"] == "csh":
4245
from .routes import upperclassmen
4346
else:
4447
from .routes import freshmen
45-
46-
from .routes import api, shared
47-
from . import commands
48-
from . import models

packet/models.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,10 @@ def did_sign(self, username, is_csh):
103103
# The user must be a misc CSHer that hasn't signed this packet or an off-floor freshmen
104104
return False
105105

106+
@classmethod
107+
def open_packets(cls):
108+
return cls.query.filter(cls.start < datetime.now(), cls.end > datetime.now()).all()
109+
106110
class UpperSignature(db.Model):
107111
__tablename__ = "signature_upper"
108112
packet_id = Column(Integer, ForeignKey("packet.id"), primary_key=True)

packet/routes/shared.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,17 @@
22
Routes available to both freshmen and CSH users
33
"""
44

5-
from datetime import datetime
65
from flask import render_template, redirect
76

87
from packet import auth, app
98
from packet.utils import before_request
109
from packet.models import Packet
1110

1211

13-
@app.route('/logout')
12+
@app.route("/logout/")
1413
@auth.oidc_logout
1514
def logout():
16-
return redirect("/")
15+
return redirect("http://csh.rit.edu")
1716

1817

1918
@app.route("/packet/<freshman_username>/<packet_id>/")
@@ -47,7 +46,7 @@ def freshman_packet(freshman_username, packet_id, info=None):
4746
@auth.oidc_auth
4847
@before_request
4948
def packets(info=None):
50-
open_packets = Packet.query.filter(Packet.start < datetime.now(), Packet.end > datetime.now()).all()
49+
open_packets = Packet.open_packets()
5150

5251
# Pre-calculate and store the return values of did_sign(), signatures_received(), and signatures_required()
5352
for packet in open_packets:

packet/templates/include/nav.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<nav class="navbar fixed-top navbar-expand-lg navbar-dark bg-primary">
22
<div class="container">
3-
<a class="navbar-brand" href="/">Packet</a>
3+
<a class="navbar-brand" href="{{ url_for("index") }}">Packet</a>
44

55
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarColor01"
66
aria-controls="navbarColor01" aria-expanded="false" aria-label="Toggle navigation">
@@ -11,16 +11,16 @@
1111
<ul class="navbar-nav mr-auto">
1212

1313
<li class="nav-item">
14-
<a class="nav-link" href="/packets">Active Packets</a>
14+
<a class="nav-link" href="{{ url_for("packets") }}">Active Packets</a>
1515
</li>
1616

1717
{% if info.realm == "csh" %}
1818
<li class="nav-item">
19-
<a class="nav-link" href="/upperclassmen">Signatures</a>
19+
<a class="nav-link" href="{{ url_for("upperclassmen_total") }}">Signatures</a>
2020
</li>
2121
{% else %}
2222
<li class="nav-item">
23-
<a class="nav-link" href="/essays">Essays</a>
23+
<a class="nav-link" href="{{ url_for("essays") }}">Essays</a>
2424
</li>
2525
{% endif %}
2626

@@ -41,7 +41,7 @@
4141
<a class="dropdown-item" href="https://themeswitcher.csh.rit.edu/">Theme</a>
4242
<div class="dropdown-divider"></div>
4343
{% endif %}
44-
<a class="dropdown-item" href="/logout">Logout</a>
44+
<a class="dropdown-item" href="{{ url_for("logout") }}">Logout</a>
4545
</div>
4646

4747
</li>

0 commit comments

Comments
 (0)