mirror of
https://github.com/aljazceru/CTFd.git
synced 2025-12-17 22:14:25 +01:00
Fix issue loading update view in Python 3. Thanks to @mayoneko (#766)
* Fix `update.html` in Python 3
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
from flask import current_app as app, render_template, render_template_string, url_for
|
||||
from CTFd.utils.decorators import admins_only
|
||||
from CTFd.utils import binary_type
|
||||
from CTFd.models import Solves, Challenges, Flags
|
||||
from CTFd.plugins.challenges import get_chal_class
|
||||
from CTFd.admin import admin
|
||||
import os
|
||||
import six
|
||||
|
||||
|
||||
@admin.route('/admin/challenges')
|
||||
@@ -22,9 +24,12 @@ def challenges_detail(challenge_id):
|
||||
flags = Flags.query.filter_by(challenge_id=challenge.id).all()
|
||||
challenge_class = get_chal_class(challenge.type)
|
||||
|
||||
with open(os.path.join(app.root_path, challenge_class.templates['update'].lstrip('/'))) as update:
|
||||
with open(os.path.join(app.root_path, challenge_class.templates['update'].lstrip('/')), 'rb') as update:
|
||||
tpl = update.read()
|
||||
if six.PY3 and isinstance(tpl, binary_type):
|
||||
tpl = tpl.decode('utf-8')
|
||||
update_j2 = render_template_string(
|
||||
update.read().decode('utf-8'),
|
||||
tpl,
|
||||
challenge=challenge
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user