unblock stuff
parent
5697d696dd
commit
2bdadcaded
|
@ -63,6 +63,10 @@ if production:
|
||||||
def competition_is_running():
|
def competition_is_running():
|
||||||
return competition_begin < datetime.now() < competition_end
|
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.
|
# Don't touch these. Instead, copy secrets.example to secrets and edit that.
|
||||||
import yaml
|
import yaml
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
|
@ -10,7 +10,7 @@ challenges = Blueprint("challenges", __name__, template_folder="../templates/cha
|
||||||
|
|
||||||
@challenges.route('/challenges/')
|
@challenges.route('/challenges/')
|
||||||
@decorators.must_be_allowed_to("view challenges")
|
@decorators.must_be_allowed_to("view challenges")
|
||||||
@decorators.competition_running_required
|
@decorators.competition_started_required
|
||||||
@decorators.confirmed_email_required
|
@decorators.confirmed_email_required
|
||||||
def index():
|
def index():
|
||||||
stages = challenge.get_stages()
|
stages = challenge.get_stages()
|
||||||
|
@ -25,7 +25,7 @@ def index():
|
||||||
@challenges.route('/challenges/<challenge_id>/solves/')
|
@challenges.route('/challenges/<challenge_id>/solves/')
|
||||||
@decorators.must_be_allowed_to("view challenge solves")
|
@decorators.must_be_allowed_to("view challenge solves")
|
||||||
@decorators.must_be_allowed_to("view challenges")
|
@decorators.must_be_allowed_to("view challenges")
|
||||||
@decorators.competition_running_required
|
@decorators.competition_started_required
|
||||||
@decorators.confirmed_email_required
|
@decorators.confirmed_email_required
|
||||||
def show_solves(challenge_id):
|
def show_solves(challenge_id):
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -48,6 +48,15 @@ def competition_running_required(f):
|
||||||
return f(*args, **kwargs)
|
return f(*args, **kwargs)
|
||||||
return decorated
|
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):
|
def admin_required(f):
|
||||||
@wraps(f)
|
@wraps(f)
|
||||||
def decorated(*args, **kwargs):
|
def decorated(*args, **kwargs):
|
||||||
|
|
Loading…
Reference in New Issue