Allowing admins to preview challenge board

This commit is contained in:
Kevin Chung
2015-05-09 23:33:14 -04:00
parent 1e445791d1
commit be6430be4f

View File

@@ -1,6 +1,6 @@
from flask import current_app as app, render_template, request, redirect, abort, jsonify, json as json_mod, url_for, session
from CTFd.utils import ctftime, authed, unix_time, get_kpm, can_view_challenges
from CTFd.utils import ctftime, authed, unix_time, get_kpm, can_view_challenges, is_admin
from CTFd.models import db, Challenges, Files, Solves, WrongKeys, Keys
import time
@@ -10,7 +10,7 @@ import logging
def init_challenges(app):
@app.route('/challenges', methods=['GET'])
def challenges():
if not ctftime():
if not is_admin() and not ctftime():
return redirect('/')
if can_view_challenges():
return render_template('chals.html')
@@ -19,7 +19,7 @@ def init_challenges(app):
@app.route('/chals', methods=['GET'])
def chals():
if not ctftime():
if not is_admin() and not ctftime():
return redirect('/')
if can_view_challenges():
chals = Challenges.query.add_columns('id', 'name', 'value', 'description', 'category').order_by(Challenges.value).all()