diff --git a/.travis.yml b/.travis.yml index 08f6642..202fc15 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,4 +15,4 @@ before_script: - psql -c 'create database ctfd;' -U postgres script: - pep8 --ignore E501,E712 CTFd/ tests/ - - nosetests + - nosetests -d diff --git a/CTFd/admin/__init__.py b/CTFd/admin/__init__.py index 2504e9e..93b0549 100644 --- a/CTFd/admin/__init__.py +++ b/CTFd/admin/__init__.py @@ -117,6 +117,7 @@ def admin_config(): mail_tls = bool(request.form.get('mail_tls', None)) mail_ssl = bool(request.form.get('mail_ssl', None)) mail_useauth = bool(request.form.get('mail_useauth', None)) + workshop_mode = bool(request.form.get('workshop_mode', None)) except (ValueError, TypeError): view_challenges_unregistered = None view_scoreboard_if_authed = None @@ -128,6 +129,7 @@ def admin_config(): mail_tls = None mail_ssl = None mail_useauth = None + workshop_mode = None finally: view_challenges_unregistered = utils.set_config('view_challenges_unregistered', view_challenges_unregistered) view_scoreboard_if_authed = utils.set_config('view_scoreboard_if_authed', view_scoreboard_if_authed) @@ -139,6 +141,7 @@ def admin_config(): mail_tls = utils.set_config('mail_tls', mail_tls) mail_ssl = utils.set_config('mail_ssl', mail_ssl) mail_useauth = utils.set_config('mail_useauth', mail_useauth) + workshop_mode = utils.set_config('workshop_mode', workshop_mode) mail_server = utils.set_config("mail_server", request.form.get('mail_server', None)) mail_port = utils.set_config("mail_port", request.form.get('mail_port', None)) @@ -207,6 +210,8 @@ def admin_config(): prevent_name_change = utils.get_config('prevent_name_change') verify_emails = utils.get_config('verify_emails') + workshop_mode = utils.get_config('workshop_mode') + db.session.commit() db.session.close() @@ -236,4 +241,5 @@ def admin_config(): prevent_name_change=prevent_name_change, verify_emails=verify_emails, view_after_ctf=view_after_ctf, - themes=themes) + themes=themes, + workshop_mode=workshop_mode) diff --git a/CTFd/challenges.py b/CTFd/challenges.py index 9ced081..f783115 100644 --- a/CTFd/challenges.py +++ b/CTFd/challenges.py @@ -153,6 +153,11 @@ def solves_per_chal(): if not utils.user_can_view_challenges(): return redirect(url_for('auth.login', next=request.path)) + chals = Challenges.query\ + .filter(or_(Challenges.hidden != True, Challenges.hidden == None))\ + .order_by(Challenges.value)\ + .all() + solves_sub = db.session.query( Solves.chalid, db.func.count(Solves.chalid).label('solves') @@ -168,15 +173,21 @@ def solves_per_chal(): ) \ .join(Challenges, solves_sub.columns.chalid == Challenges.id).all() - json = {} + data = {} if utils.hide_scores(): for chal, count, name in solves: - json[chal] = -1 + data[chal] = -1 + for c in chals: + if c.id not in data: + data[c.id] = -1 else: for chal, count, name in solves: - json[chal] = count + data[chal] = count + for c in chals: + if c.id not in data: + data[c.id] = 0 db.session.close() - return jsonify(json) + return jsonify(data) @challenges.route('/solves') diff --git a/CTFd/themes/admin/templates/config.html b/CTFd/themes/admin/templates/config.html index 00a074b..d93d9d6 100644 --- a/CTFd/themes/admin/templates/config.html +++ b/CTFd/themes/admin/templates/config.html @@ -53,6 +53,16 @@ +
+ +
+