42 lines
1.0 KiB
Python
42 lines
1.0 KiB
Python
import os
|
|
|
|
from flask import render_template, Blueprint
|
|
from flask import request
|
|
|
|
from .models import CheaterTeams
|
|
from . import globals
|
|
|
|
from CTFd.plugins.migrations import upgrade
|
|
from CTFd.utils.decorators import admins_only
|
|
from CTFd.models import db
|
|
|
|
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):
|
|
globals.initialize()
|
|
app.db.create_all()
|
|
upgrade(plugin_name="cheaters")
|
|
|
|
app.register_blueprint(bp)
|
|
|
|
load_hooks()
|