Skip to content
This repository was archived by the owner on Dec 8, 2022. It is now read-only.

Commit fdccd25

Browse files
authored
Merge branch 'master' into hotfix-flask-q-sync
2 parents 2840fab + 20d4935 commit fdccd25

24 files changed

+169
-3534
lines changed

CodeChallenge/__init__.py

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import os
2+
import re
23

34
import sentry_sdk
4-
from flask import Flask, jsonify, make_response, send_from_directory, redirect
5+
from flask import Flask, jsonify, make_response, send_from_directory
56
from flask_cors import CORS
67
from sentry_sdk.integrations.flask import FlaskIntegration
78
from werkzeug.middleware.proxy_fix import ProxyFix
@@ -22,6 +23,7 @@
2223
from .manage import add_question, del_question # NoQA
2324
from .models import db, init_db # NoQA
2425

26+
STATIC_FILES = re.compile(r"\.(ico|png|xml|json)$")
2527

2628
# Globally accessible libraries
2729

@@ -93,24 +95,12 @@ def send_images(path):
9395
def send_assets(path):
9496
return send_from_directory("assets", path)
9597

96-
@app.route("/landing", defaults={"path": ""})
97-
@app.route("/landing/<path:path>")
98-
def send_landing(path):
99-
100-
# if core.current_rank() != -1:
101-
# return redirect("/")
102-
103-
if path:
104-
return send_from_directory("../landing/", path)
105-
return send_from_directory("../landing/", "index.html")
106-
10798
@app.route("/", defaults={"path": ""})
10899
@app.route("/<path:path>")
109100
def catch_all(path):
110101

111-
# show landing page
112-
if core.current_rank() == -1 and (not path or path == "home"):
113-
return redirect("/landing")
102+
if STATIC_FILES.search(path):
103+
return send_from_directory(app.config["DIST_DIR"], path)
114104

115105
return send_from_directory(app.config["DIST_DIR"], "index.html")
116106

CodeChallenge/api/questions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def json_error(reason, status=400):
2020

2121
@bp.before_request
2222
def end_code_challenge():
23-
if core.challenge_ended():
23+
if core.challenge_ended() and request.path != "/api/v1/questions/leaderboard":
2424
r = jsonify(status="error",
2525
reason="code challenge has ended")
2626
r.status_code = 403

CodeChallenge/api/vote.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,21 @@ def get_contestants():
4848

4949
contestants = []
5050
for ans in p.items: # type: Answer
51+
52+
display = None
53+
if ans.user.studentfirstname \
54+
and ans.user.studentlastname:
55+
display = f"{ans.user.studentfirstname} " \
56+
f"{ans.user.studentlastname[0]}."
57+
5158
contestants.append(dict(
5259
id=ans.id,
5360
text=ans.text,
5461
numVotes=len(ans.votes),
62+
firstName=ans.user.studentfirstname,
63+
lastName=ans.user.studentlastname,
64+
username=ans.user.username,
65+
display=display
5566
))
5667

5768
return jsonify(

CodeChallenge/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,4 @@ class DevelopmentConfig(ProductionConfig):
8484

8585
@property
8686
def DIST_DIR(self):
87-
return os.path.join(self.ROOT_DIR, "public")
87+
return os.path.join(self.ROOT_DIR, "dist")

CodeChallenge/models.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class Answer(db.Model):
3636
text = db.Column(db.String(2000))
3737
correct = db.Column(db.Boolean)
3838
question = db.relationship("Question", lazy=True, uselist=False)
39+
user = db.relationship("Users", lazy=True, uselist=False)
3940
votes = db.relationship("Vote", cascade="all,delete",
4041
lazy=True, uselist=True)
4142

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
"eslint-plugin-prettier": "^3.1.1",
3232
"eslint-plugin-vue": "^5.0.0",
3333
"js-yaml": "^3.13.1",
34+
"mini-css-extract-plugin": "^0.9.0",
3435
"node-sass": "^4.12.0",
3536
"prettier": "^1.18.2",
3637
"sass": "^1.19.0",

0 commit comments

Comments
 (0)