Skip to content

Commit 482aaff

Browse files
authored
Merge pull request #61 from ComputerScienceHouse/develop
Version 3.0.2
2 parents 0cc3bae + 7bf8add commit 482aaff

File tree

16 files changed

+204
-87
lines changed

16 files changed

+204
-87
lines changed

frontend/scss/components/_datatables.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,9 @@ div {
3333
}
3434
}
3535

36+
table {
37+
.dataTable {
38+
margin-top: 0 !important;
39+
margin-bottom: 0 !important;
40+
}
41+
}
Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
1-
.sign-packet {
2-
float: right;
3-
text-align: right;
4-
}
1+
button {
2+
&.sign-packet {
3+
float: right;
4+
text-align: right;
5+
}
6+
7+
&.sign-button {
8+
float: right;
9+
}
510

6-
.sign-button {
7-
float: right;
11+
&.signed-button {
12+
float: right;
13+
}
814
}

gulpfile.js/tasks/favicon.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ gulp.task('generate-favicon', function(done) {
2929
desktopBrowser: {},
3030
windows: {
3131
pictureAspect: 'whiteSilhouette',
32-
backgroundColor: '#9f00a7',
32+
backgroundColor: '#b0197e',
3333
onConflict: 'override',
3434
assets: {
3535
windows80Ie10Tile: true,
@@ -43,7 +43,7 @@ gulp.task('generate-favicon', function(done) {
4343
},
4444
androidChrome: {
4545
pictureAspect: 'noChange',
46-
themeColor: '#222222',
46+
themeColor: '#b0197e',
4747
manifest: {
4848
display: 'standalone',
4949
orientation: 'notSet',
@@ -57,7 +57,7 @@ gulp.task('generate-favicon', function(done) {
5757
},
5858
safariPinnedTab: {
5959
pictureAspect: 'silhouette',
60-
themeColor: '#222222'
60+
themeColor: '#b0197e'
6161
}
6262
},
6363
settings: {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"title": "CSH Packet",
33
"name": "csh-packet",
4-
"version": "3.0.1",
4+
"version": "3.0.2",
55
"description": "A webpacket for CSH",
66
"bugs": {
77
"url": "https://github.com/ComputerScienceHouse/packet/issues",

packet/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "3.0.1"
1+
__version__ = "3.0.2"

packet/routes/shared.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
from datetime import datetime
22
from itertools import chain
33

4-
from flask import render_template
4+
from flask import render_template, redirect
55

66
from packet import auth, app
77
from packet.models import Freshman, Packet
88
from packet.packet import get_signatures, get_number_required, get_number_signed, get_upperclassmen_percent
99
from packet.utils import before_request, signed_packet
1010

1111

12+
@app.route('/logout')
13+
@auth.oidc_logout
14+
def logout():
15+
return redirect("/")
16+
17+
1218
@app.route("/packet/<uid>")
1319
@auth.oidc_auth
1420
@before_request

packet/routes/upperclassmen.py

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1+
from datetime import datetime
2+
from itertools import chain
3+
14
from flask import redirect, render_template
5+
from sqlalchemy import func, case
26

3-
from packet import auth, app
4-
from packet.models import UpperSignature
7+
from packet import auth, app, db
8+
from packet.models import Packet, UpperSignature, MiscSignature
59
from packet.utils import before_request
610

711

@@ -15,5 +19,37 @@ def index():
1519
@auth.oidc_auth
1620
@before_request
1721
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)
22+
open_packets = Packet.query.filter(Packet.end > datetime.now()).filter(Packet.start < datetime.now()).all()
23+
signatures = 0
24+
25+
for packet in open_packets:
26+
packet.did_sign = False
27+
28+
for sig in chain(filter(lambda sig: sig.signed, packet.upper_signatures), packet.misc_signatures):
29+
if sig.member == uid:
30+
packet.did_sign = True
31+
signatures += 1
32+
break
33+
34+
open_packets.sort(key=lambda x: x.did_sign, reverse=True)
35+
36+
return render_template("upperclassman.html", info=info, open_packets=open_packets, member=uid,
37+
signatures=signatures)
38+
39+
40+
@app.route("/upperclassmen")
41+
@auth.oidc_auth
42+
@before_request
43+
def upperclassmen_total(info=None):
44+
open_packets = Packet.query.filter(Packet.end > datetime.now()).filter(Packet.start < datetime.now()).count()
45+
46+
# TODO: Only count open Packets
47+
upperclassmen = (db.session.query(func.count(case([(UpperSignature.signed == True, 1)])).label("signatures"),
48+
UpperSignature.member)).group_by(UpperSignature.member).all()
49+
upperclassmen += (db.session.query(func.count().label("signatures"),
50+
MiscSignature.member)).group_by(MiscSignature.member).all()
51+
52+
upperclassmen.sort(reverse=True)
53+
54+
return render_template("upperclassmen_totals.html", info=info, upperclassmen=upperclassmen,
55+
open_packets=open_packets)

packet/static/js/signing.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ $(document).ready(function () {
1616
url: "/api/v1/" + userData + "/sign/" + packetData.freshman_uid,
1717
method: "POST",
1818
success: function (data) {
19-
swal("Congratulations or I'm Sorry\nYou've signed " + packetData.freshman_name + "'s packet", {
19+
swal("Congratulations or I'm sorry\nYou've signed " + packetData.freshman_name + "'s packet.", {
2020
icon: "success",
2121
})
2222
.then(() => {

packet/static/js/tables.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
$(document).ready(function () {
2+
3+
$('#active_packets_table').DataTable({
4+
"searching": true,
5+
"order": [[2, 'desc']],
6+
"paging": false,
7+
"info": false,
8+
"columnDefs": [
9+
{
10+
"type": "num-fmt", "targets": 1
11+
}
12+
]
13+
});
14+
15+
});

packet/templates/active_packets.html

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,12 @@ <h3 class="page-title">Active Packets</h3>
1414
<div class="card-body table-fill">
1515
<div class="card-body table-fill">
1616
<div class="table-responsive">
17-
<table class="table table-striped no-bottom-margin" data-module="table"
18-
data-searchable="true" data-sort-column="3" data-sort-order="asc"
19-
data-length-changable="true" data-paginated="false">
17+
<table id="active_packets_table" class="table table-striped no-bottom-margin">
2018
<thead>
2119
<tr>
2220
<th>Name</th>
2321
<th>Signatures</th>
22+
<th>Sign</th>
2423
</tr>
2524
</thead>
2625
<tbody>
@@ -36,7 +35,7 @@ <h3 class="page-title">Active Packets</h3>
3635
height="25"/> {{ packet.freshman.name }} ({{ packet.freshman.rit_username }})
3736
</a>
3837
</td>
39-
<td>
38+
<td data-sort="{{ packet.total_signatures }}">
4039
{% if packet.total_signatures == packet.required_signatures %}
4140
💯 {# 100% emoji #}
4241
{% else %}
@@ -46,13 +45,13 @@ <h3 class="page-title">Active Packets</h3>
4645
{% if (info.onfloor and info.uid != packet.freshman.rit_username) or info.realm == "csh" %}
4746
<td class="sign-packet" align="right">
4847
{% if not packet.did_sign %}
49-
<button class="btn btn-primary sign-button"
48+
<button class="btn btn-sm btn-primary sign-button"
5049
data-freshman_uid="{{ packet.freshman.rit_username }}"
5150
data-freshman_name="{{ packet.freshman.name }}">
5251
Sign
5352
</button>
5453
{% else %}
55-
<button class="btn btn-primary" disabled="disabled"><i
54+
<button class="btn btn-sm btn-primary signed-button" disabled="disabled"><i
5655
class="fa fa-check"></i>&nbsp;Signed
5756
</button>
5857
{% endif %}
@@ -76,3 +75,8 @@ <h3 class="page-title">Active Packets</h3>
7675
</div>
7776
</div>
7877
{% endblock %}
78+
79+
{% block scripts %}
80+
{{ super() }}
81+
<script src="/static/js/tables.js"></script>
82+
{% endblock %}

0 commit comments

Comments
 (0)