39 lines
1.1 KiB
Python
39 lines
1.1 KiB
Python
import os
|
|
|
|
from CTFd.models import db
|
|
from CTFd.plugins import register_admin_plugin_menu_bar
|
|
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 report_cheater(challenge_id: int, cheater_id: int, helper_id: int, flag_id: int):
|
|
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)
|