feat: added submissions history, formatted

This commit is contained in:
Андрей Сумин
2025-03-02 03:17:18 +03:00
parent cb541b3a2a
commit 696fc8e58b
18 changed files with 130 additions and 78 deletions
@@ -11,12 +11,17 @@ class CompetitionOut(ModelSchema):
state: Literal["not_started", "started", "finished"]
@staticmethod
def resolve_state(self, context) -> Literal["not_started", "started", "finished"]:
if not (state := State.objects.filter(user=context.get("request").auth, competition=self).first()):
def resolve_state(
self, context
) -> Literal["not_started", "started", "finished"]:
if not (
state := State.objects.filter(
user=context.get("request").auth, competition=self
).first()
):
return "not_started"
return state.state
class Meta:
model = Competition
exclude = ("participants",)