feat: First commit
This commit is contained in:
41
__init__.py
Normal file
41
__init__.py
Normal file
@@ -0,0 +1,41 @@
|
||||
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()
|
||||
Reference in New Issue
Block a user