Fixing view CTF after end and making it less confusing

This commit is contained in:
Kevin Chung
2015-09-10 22:12:41 -04:00
parent a17016416e
commit 1685a528b8
2 changed files with 14 additions and 6 deletions

View File

@@ -10,8 +10,12 @@ import logging
def init_challenges(app): def init_challenges(app):
@app.route('/challenges', methods=['GET']) @app.route('/challenges', methods=['GET'])
def challenges(): def challenges():
if not is_admin() and not ctftime() and not view_after_ctf(): if not is_admin():
return redirect('/') if not ctftime():
if view_after_ctf():
pass
else:
return redirect('/')
if can_view_challenges(): if can_view_challenges():
return render_template('chals.html', ctftime=ctftime()) return render_template('chals.html', ctftime=ctftime())
else: else:
@@ -19,8 +23,12 @@ def init_challenges(app):
@app.route('/chals', methods=['GET']) @app.route('/chals', methods=['GET'])
def chals(): def chals():
if not is_admin() and not ctftime() and not view_after_ctf(): if not is_admin():
return redirect('/') if not ctftime():
if view_after_ctf():
pass
else:
return redirect('/')
if can_view_challenges(): if can_view_challenges():
chals = Challenges.query.add_columns('id', 'name', 'value', 'description', 'category').order_by(Challenges.value).all() chals = Challenges.query.add_columns('id', 'name', 'value', 'description', 'category').order_by(Challenges.value).all()

View File

@@ -73,7 +73,7 @@ def admins_only(f):
def view_after_ctf(): def view_after_ctf():
if get_config('view_after_ctf') == '1' and get_config("end") > time.time: if get_config('view_after_ctf') == '1' and time.time() > int(get_config("end")):
return True return True
else: else:
return False return False
@@ -211,4 +211,4 @@ def get_digitalocean():
if token: if token:
return digitalocean.Manager(token=token) return digitalocean.Manager(token=token)
else: else:
return False return False