From 73f818fea3aacc0bae66ff6ff99671a8b534b1d9 Mon Sep 17 00:00:00 2001 From: tripathiji1312 Date: Wed, 19 Feb 2025 19:56:38 +0530 Subject: [PATCH 1/3] refactor: Updated ctf.py for two new fields and created attackdefproblem model --- src/pwncore/models/ctf.py | 3 ++- src/pwncore/models/round2.py | 25 +++++++++++++++++++++++++ src/pwncore/types.py | 2 -- 3 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 src/pwncore/models/round2.py delete mode 100644 src/pwncore/types.py diff --git a/src/pwncore/models/ctf.py b/src/pwncore/models/ctf.py index 611a1d7..d86a19d 100644 --- a/src/pwncore/models/ctf.py +++ b/src/pwncore/models/ctf.py @@ -39,7 +39,8 @@ class Problem(BaseProblem): ma = fields.IntField(default=500) visible = fields.BooleanField(default=True) tags = fields.SmallIntField(default=1) # by default misc, 16 tag limit - + difficulty_level = fields.SmallIntField(default=1) + problem_type = fields.TextField(default="jeopardy") #Can use enum too hints: fields.ReverseRelation[Hint] class PydanticMeta: diff --git a/src/pwncore/models/round2.py b/src/pwncore/models/round2.py new file mode 100644 index 0000000..c23ea05 --- /dev/null +++ b/src/pwncore/models/round2.py @@ -0,0 +1,25 @@ + +from tortoise import fields +from tortoise.models import Model +from tortoise.contrib.pydantic import pydantic_model_creator + +from ctf import Problem +from user import Team + + +class AttackDefProblem(Model): + id = fields.IntField(pk=True) + team: fields.ForeignKeyRelation[Team] = fields.ForeignKeyField( + "models.Team", related_name="attackdef_problems" + ) + problem: fields.ForeignKeyRelation[Problem] = fields.ForeignKeyField( + "models.Problem", related_name="problems" + ) + + def __repr__(self): + return ( + f"" # team_id_ to access id via relation + ) + + +AttackDefProblem_Pydantic = pydantic_model_creator(AttackDefProblem) \ No newline at end of file diff --git a/src/pwncore/types.py b/src/pwncore/types.py deleted file mode 100644 index 0db45c2..0000000 --- a/src/pwncore/types.py +++ /dev/null @@ -1,2 +0,0 @@ -"""Only for type aliases and nothing else. -""" From 999f80aac431ffc14f219fafd43ae17a63a76f07 Mon Sep 17 00:00:00 2001 From: tripathiji1312 Date: Wed, 19 Feb 2025 19:59:07 +0530 Subject: [PATCH 2/3] fix: Modified round2.py --- src/pwncore/models/round2.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/pwncore/models/round2.py b/src/pwncore/models/round2.py index c23ea05..86a1275 100644 --- a/src/pwncore/models/round2.py +++ b/src/pwncore/models/round2.py @@ -16,10 +16,5 @@ class AttackDefProblem(Model): "models.Problem", related_name="problems" ) - def __repr__(self): - return ( - f"" # team_id_ to access id via relation - ) - AttackDefProblem_Pydantic = pydantic_model_creator(AttackDefProblem) \ No newline at end of file From 6f1912c1f30796615ffc5e6ca0f940f9596927ff Mon Sep 17 00:00:00 2001 From: tripathiji1312 Date: Sat, 22 Feb 2025 10:00:15 +0530 Subject: [PATCH 3/3] fix: Modified round2.py --- src/pwncore/models/round2.py | 5 ++--- src/pwncore/types.py | 2 ++ 2 files changed, 4 insertions(+), 3 deletions(-) create mode 100644 src/pwncore/types.py diff --git a/src/pwncore/models/round2.py b/src/pwncore/models/round2.py index 86a1275..9896676 100644 --- a/src/pwncore/models/round2.py +++ b/src/pwncore/models/round2.py @@ -1,10 +1,9 @@ - from tortoise import fields from tortoise.models import Model from tortoise.contrib.pydantic import pydantic_model_creator -from ctf import Problem -from user import Team +from pwncore.models.ctf import Problem +from pwncore.models.user import Team class AttackDefProblem(Model): diff --git a/src/pwncore/types.py b/src/pwncore/types.py new file mode 100644 index 0000000..95ddbfd --- /dev/null +++ b/src/pwncore/types.py @@ -0,0 +1,2 @@ +"""Only for type aliases and nothing else. +""" \ No newline at end of file