Example #1
0
def challenges_detail(challenge_id):
    from fyp import showCategory
    challenges = dict(
        Challenges.query.with_entities(Challenges.id, Challenges.name).all())
    challenge = Challenges.query.filter_by(id=challenge_id).first_or_404()
    solves = Solves.query.filter_by(challenge_id=challenge.id).all()
    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('/')),
            'rb') as update:
        tpl = update.read()
        if six.PY3 and isinstance(tpl, binary_type):
            tpl = tpl.decode('utf-8')
        update_j2 = render_template_string(tpl, challenge=challenge)

    update_script = url_for(
        'views.static_html',
        route=challenge_class.scripts['update'].lstrip('/'))
    return render_template('admin/challenges/challenge.html',
                           update_template=update_j2,
                           update_script=update_script,
                           challenge=challenge,
                           challenges=challenges,
                           solves=solves,
                           flags=flags,
                           category=showCategory()[challenge.category_id])
Example #2
0
def category_listing():
    from fyp import showCategory
    return render_template('admin/challenges/category.html',
                           category=enumerate(showCategory()))
Example #3
0
def challenges_listing():
    from fyp import showCategory
    challenges = Challenges.query.all()
    return render_template('admin/challenges/challenges.html',
                           challenges=challenges,
                           category=showCategory())
Example #4
0
 def get(self):
     from fyp import showCategory
     return {'data': showCategory()}