mirror of
https://github.com/aljazceru/CTFd.git
synced 2025-12-17 22:14:25 +01:00
Bootstrap beta 3, Regression fixes, bugfixes (#543)
* Upgrade to Bootstrap v4 beta 3 * Fix incorrect FontAwesome5 icon * Fixing regressions & code quality issues. Files, Tags & Hints now appear in the admin challenge preview. Fixed color issues with file buttons and badges. Pass script_root into challenge type plugin. * Fixing incorrect FontAwesome5 icon * Fix test for /admin/chals/<chalid> * Expand test to include tags, hints, files
This commit is contained in:
@@ -31,22 +31,31 @@ def admin_chal_types():
|
||||
@admins_only
|
||||
def admin_chals():
|
||||
if request.method == 'POST':
|
||||
chals = Challenges.query.add_columns('id', 'type', 'name', 'value', 'description', 'category', 'hidden', 'max_attempts').order_by(Challenges.value).all()
|
||||
chals = Challenges.query.order_by(Challenges.value).all()
|
||||
|
||||
json_data = {'game': []}
|
||||
for x in chals:
|
||||
type_class = CHALLENGE_CLASSES.get(x.type)
|
||||
for chal in chals:
|
||||
tags = [tag.tag for tag in Tags.query.add_columns('tag').filter_by(chal=chal.id).all()]
|
||||
files = [str(f.location) for f in Files.query.filter_by(chal=chal.id).all()]
|
||||
hints = []
|
||||
for hint in Hints.query.filter_by(chal=chal.id).all():
|
||||
hints.append({'id': hint.id, 'cost': hint.cost, 'hint': hint.hint})
|
||||
|
||||
type_class = CHALLENGE_CLASSES.get(chal.type)
|
||||
type_name = type_class.name if type_class else None
|
||||
|
||||
json_data['game'].append({
|
||||
'id': x.id,
|
||||
'name': x.name,
|
||||
'value': x.value,
|
||||
'description': x.description,
|
||||
'category': x.category,
|
||||
'hidden': x.hidden,
|
||||
'max_attempts': x.max_attempts,
|
||||
'type': x.type,
|
||||
'id': chal.id,
|
||||
'name': chal.name,
|
||||
'value': chal.value,
|
||||
'description': chal.description,
|
||||
'category': chal.category,
|
||||
'files': files,
|
||||
'tags': tags,
|
||||
'hints': hints,
|
||||
'hidden': chal.hidden,
|
||||
'max_attempts': chal.max_attempts,
|
||||
'type': chal.type,
|
||||
'type_name': type_name,
|
||||
'type_data': {
|
||||
'id': type_class.id,
|
||||
@@ -77,6 +86,17 @@ def admin_chal_detail(chalid):
|
||||
return jsonify({'status': 0, 'message': message})
|
||||
elif request.method == 'GET':
|
||||
obj, data = chal_class.read(chal)
|
||||
|
||||
tags = [tag.tag for tag in Tags.query.add_columns('tag').filter_by(chal=chal.id).all()]
|
||||
files = [str(f.location) for f in Files.query.filter_by(chal=chal.id).all()]
|
||||
hints = []
|
||||
for hint in Hints.query.filter_by(chal=chal.id).all():
|
||||
hints.append({'id': hint.id, 'cost': hint.cost, 'hint': hint.hint})
|
||||
|
||||
data['tags'] = tags
|
||||
data['files'] = files
|
||||
data['hints'] = hints
|
||||
|
||||
return jsonify(data)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user