From b795377edece39eb3579f76ce5d2e2b80365f396 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Setni=C4=8Dka?= <setnicka@seznam.cz> Date: Fri, 1 Jan 2021 19:36:59 +0100 Subject: [PATCH] =?UTF-8?q?DB:=20Podpora=20pro=20vytahov=C3=A1n=C3=AD=20ka?= =?UTF-8?q?tegori=C3=AD,=20kol=20a=20stav=C5=AF=20=C3=BA=C4=8Dasti=20do=20?= =?UTF-8?q?formul=C3=A1=C5=99=C5=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mo/db.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/mo/db.py b/mo/db.py index a9b2f5da..cf8d1f77 100644 --- a/mo/db.py +++ b/mo/db.py @@ -232,6 +232,23 @@ class PartState(MOEnum): present = auto() absent = auto() + @classmethod + def choices(enum): + out = [] + for item in enum: + out.append((item.name, part_state_names[item])) + return out + + +part_state_names = { + PartState.registered: 'registrovaný', + PartState.invited: 'pozvaný', + PartState.refused: 'odmítnutý', + PartState.present: 'přítomný', + PartState.absent: 'nepřítomný', +} + + class Participation(Base): __tablename__ = 'participations' @@ -357,6 +374,14 @@ def get_session() -> Session: return _session +def get_categories() -> List[str]: + return [cat for (cat,) in get_session().query(Round.category).distinct()] + + +def get_seqs() -> List[str]: + return [seq for (seq,) in get_session().query(Round.seq).distinct()] + + def get_place_parents(place: Place) -> List[Place]: sess = get_session() -- GitLab