fix: Change all() with first()
This commit is contained in:
@@ -19,9 +19,9 @@ bp = Blueprint(directory_name, __name__, template_folder="templates")
|
|||||||
|
|
||||||
def create_flag_if_missing(challenge_id: int, user_id: int, flag_content: str):
|
def create_flag_if_missing(challenge_id: int, user_id: int, flag_content: str):
|
||||||
user_id_str = str(user_id)
|
user_id_str = str(user_id)
|
||||||
flags = Flags.query.filter_by(id=challenge_id, data=user_id_str).all()
|
flag = Flags.query.filter_by(id=challenge_id, data=user_id_str).first()
|
||||||
|
|
||||||
if len(flags) == 0:
|
if flag is None:
|
||||||
new_flag = Flags(
|
new_flag = Flags(
|
||||||
challenge_id=challenge_id,
|
challenge_id=challenge_id,
|
||||||
type="personal",
|
type="personal",
|
||||||
@@ -32,7 +32,7 @@ def create_flag_if_missing(challenge_id: int, user_id: int, flag_content: str):
|
|||||||
db.session.commit()
|
db.session.commit()
|
||||||
return new_flag.id
|
return new_flag.id
|
||||||
|
|
||||||
return flags[0].id
|
return flag
|
||||||
|
|
||||||
|
|
||||||
@bp.route("/admin/cheaters", methods=["GET"])
|
@bp.route("/admin/cheaters", methods=["GET"])
|
||||||
|
|||||||
Reference in New Issue
Block a user