Skip to content

Commit

Permalink
Simple bugfix merges (#1531)
Browse files Browse the repository at this point in the history
* Closes #1530 
* Clean up some wording and comments
* Pin isort version to fix flake8 issue (gforcada/flake8-isort#88)
  • Loading branch information
ColdHeat committed Jul 6, 2020
1 parent adc70fb commit 7dcfba4
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 6 deletions.
1 change: 1 addition & 0 deletions CTFd/api/v1/challenges.py
Expand Up @@ -374,6 +374,7 @@ def get(self, challenge_id):
response["solves"] = solves
else:
response["solves"] = None
solves = None

if authed():
# Get current attempts for the user
Expand Down
2 changes: 1 addition & 1 deletion CTFd/themes/admin/assets/js/pages/challenge.js
Expand Up @@ -399,7 +399,7 @@ $(() => {
ezQuery({
title: "Missing Flags",
body:
"This challenge does not have any flags meaning it is unsolveable. Are you sure you'd like to update this challenge?",
"This challenge does not have any flags meaning it may be unsolveable. Are you sure you'd like to update this challenge?",
success: update_challenge
});
} else {
Expand Down
2 changes: 1 addition & 1 deletion CTFd/themes/admin/static/js/pages/challenge.dev.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion CTFd/themes/admin/static/js/pages/challenge.min.js

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions CTFd/themes/core/assets/js/pages/challenges.js
Expand Up @@ -52,6 +52,13 @@ const displayChal = chal => {

$("#challenge-window").empty();

// Inject challenge data into the plugin
challenge.data = responses[0].data;

// Call preRender function in plugin
challenge.preRender();

// Build HTML from the Jinja response in API
$("#challenge-window").append(responses[0].data.view);

$("#challenge-window #challenge-input").addClass("form-control");
Expand Down
2 changes: 1 addition & 1 deletion CTFd/themes/core/static/js/pages/challenges.dev.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion CTFd/themes/core/static/js/pages/challenges.min.js

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion Makefile
Expand Up @@ -12,7 +12,9 @@ format:
prettier --write '**/*.md'

test:
pytest -rf --cov=CTFd --cov-context=test --ignore=node_modules/ \
pytest -rf --cov=CTFd --cov-context=test \
--ignore-glob="**/node_modules/" \
--ignore=node_modules/ \
-W ignore::sqlalchemy.exc.SADeprecationWarning \
-W ignore::sqlalchemy.exc.SAWarning \
-n auto
Expand Down
1 change: 1 addition & 0 deletions development.txt
Expand Up @@ -14,6 +14,7 @@ pytest-xdist==1.32.0
pytest-cov==2.9.0
sphinx_rtd_theme==0.4.3
flask-debugtoolbar==0.11.0
isort==4.3.21
flake8-isort==3.0.0
Faker==4.1.0
pipdeptree==0.13.2
Expand Down
15 changes: 15 additions & 0 deletions tests/api/v1/test_challenges.py
Expand Up @@ -244,6 +244,21 @@ def test_api_challenge_get_visibility_private():
destroy_ctfd(app)


def test_api_challenge_get_with_admin_only_account_visibility():
"""Can a private user get /api/v1/challenges/<challenge_id> if account_visibility is admins_only"""
app = create_ctfd()
with app.app_context():
gen_challenge(app.db)
register_user(app)
client = login_as_user(app)
r = client.get("/api/v1/challenges/1")
assert r.status_code == 200
set_config("account_visibility", "admins")
r = client.get("/api/v1/challenges/1")
assert r.status_code == 200
destroy_ctfd(app)


def test_api_challenge_get_ctftime_private():
"""Can a private user get /api/v1/challenges/<challenge_id> if ctftime is over"""
app = create_ctfd()
Expand Down

0 comments on commit 7dcfba4

Please sign in to comment.