unblock stuff

master
James Sigurðarson 2016-08-26 20:24:03 +00:00
parent 5697d696dd
commit 2bdadcaded
3 changed files with 15 additions and 2 deletions

View File

@ -63,6 +63,10 @@ if production:
def competition_is_running():
return competition_begin < datetime.now() < competition_end
def competition_has_started():
return competition_begin < datetime.now()
# Don't touch these. Instead, copy secrets.example to secrets and edit that.
import yaml
from collections import namedtuple

View File

@ -10,7 +10,7 @@ challenges = Blueprint("challenges", __name__, template_folder="../templates/cha
@challenges.route('/challenges/')
@decorators.must_be_allowed_to("view challenges")
@decorators.competition_running_required
@decorators.competition_started_required
@decorators.confirmed_email_required
def index():
stages = challenge.get_stages()
@ -25,7 +25,7 @@ def index():
@challenges.route('/challenges/<challenge_id>/solves/')
@decorators.must_be_allowed_to("view challenge solves")
@decorators.must_be_allowed_to("view challenges")
@decorators.competition_running_required
@decorators.competition_started_required
@decorators.confirmed_email_required
def show_solves(challenge_id):
try:

View File

@ -48,6 +48,15 @@ def competition_running_required(f):
return f(*args, **kwargs)
return decorated
def competition_started_required(f):
@wraps(f)
def decorated(*args, **kwargs):
if not config.competition_has_started() and not ("admin" in session and session["admin"]):
flash("The competition hasn't started")
return redirect(url_for('scoreboard.index'))
return f(*args, **kwargs)
return decorated
def admin_required(f):
@wraps(f)
def decorated(*args, **kwargs):