Files
ctfd-cheaters/__init__.py

38 lines
1.0 KiB
Python

import os
from CTFd.models import db
from CTFd.plugins.migrations import upgrade
from CTFd.utils.decorators import admins_only
from flask import Blueprint, render_template, request
from .models import CheaterTeams
PLUGIN_PATH = os.path.dirname(__file__)
directory_name = PLUGIN_PATH.split(os.sep)[-1] # Get the directory name of this file
bp = Blueprint(directory_name, __name__, template_folder="templates")
def add_cheater(challenge_id: int, cheater_id: int, helper_id: int, flag: str):
cheater = CheaterTeams(challenge_id, cheater_id, helper_id, flag)
db.session.add(cheater)
db.session.commit()
@bp.route("/admin/cheaters", methods=["GET"])
@admins_only
def show_cheaters():
if request.method == "GET":
cheaters = CheaterTeams.query.all()
return render_template("cheaters.html", cheaters=cheaters)
def load(app):
app.db.create_all()
upgrade(plugin_name="cheaters")
register_admin_plugin_menu_bar(title="Cheaters", route="/admin/cheaters")
app.register_blueprint(bp)