Skip to content
Snippets Groups Projects
Commit 702a9a20 authored by Martin Mareš's avatar Martin Mareš
Browse files

DB: Zavedení custom kódu kola

parent a3e9e7a6
Branches
No related tags found
1 merge request!99Custom kód kola
......@@ -115,6 +115,7 @@ CREATE TABLE rounds (
seq int NOT NULL, -- 1=domácí kolo atd.
part int NOT NULL DEFAULT 0, -- část kola (nenulová u dělených kol)
level int NOT NULL, -- úroveň hierarchie míst
code varchar(255) NOT NULL DEFAULT '', -- kód kola ("1", "S" apod.), prázdný=podle seq
name varchar(255) NOT NULL, -- zobrazované jméno ("Krajské kolo" apod.)
state round_state NOT NULL DEFAULT 'preparing', -- stav kola
tasks_file varchar(255) DEFAULT NULL, -- jméno souboru se zadáním úloh
......
SET ROLE 'mo_osmo';
ALTER TABLE ROUNDS ADD COLUMN
code varchar(255) NOT NULL DEFAULT '';
......@@ -249,6 +249,7 @@ class Round(Base):
seq = Column(Integer, nullable=False)
part = Column(Integer, nullable=False)
level = Column(Integer, nullable=False)
code = Column(String(255), nullable=False)
name = Column(String(255), nullable=False)
state = Column(Enum(RoundState, name='round_state'), nullable=False, server_default=text("'preparing'::round_state"))
tasks_file = Column(String(255))
......@@ -268,7 +269,7 @@ class Round(Base):
def round_code_short(self):
""" Pro samostatné kolo ekvivalentní s `round_code()`, pro skupinu kol společná část kódu. """
return f"{self.year}-{self.category}-{self.seq}"
return f"{self.year}-{self.category}-{self.code or self.seq}"
def part_code(self):
return chr(ord('a') + self.part - 1) if self.part > 0 else ""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment