feat: added state to competition response

This commit is contained in:
Андрей Сумин committed 2025-03-02 02:57:41 +03:00
1 parent 923fb4d509
commit 00a409317d
2 files changed
+9 -1

No files matched your search

@@ -8,6 +8,14 @@ from apps.competition.models import Competition, State
class CompetitionOut(ModelSchema):
id: UUID
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()):
return "not_started"
return state.state
class Meta:
model = Competition