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

DB: Kód kola je povinný

parent 67c907cc
No related branches found
No related tags found
1 merge request!97Import orgů
......@@ -113,10 +113,10 @@ CREATE TABLE rounds (
master_round_id int DEFAULT NULL REFERENCES rounds(round_id),
year int NOT NULL, -- ročník MO
category varchar(2) NOT NULL, -- "A", "Z5" apod.
seq int NOT NULL, -- 1=domácí kolo atd.
seq int NOT NULL, -- pořadí kola v kategorii (od 1)
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
code varchar(255) NOT NULL, -- kód kola ("1", "S" apod.)
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
......@@ -131,7 +131,8 @@ CREATE TABLE rounds (
has_messages boolean NOT NULL DEFAULT false, -- má zprávičky
enroll_mode enroll_mode NOT NULL DEFAULT 'manual', -- režim přihlašování (pro vyšší kola vždy 'manual')
enroll_advert varchar(255) NOT NULL DEFAULT '', -- popis v přihlašovacím formuláři
UNIQUE (year, category, seq, part)
UNIQUE (year, category, seq, part),
UNIQUE (year, category, code, part)
);
CREATE INDEX rounds_master_round_id_index ON rounds (master_round_id);
......
SET ROLE mo_osmo;
ALTER TABLE rounds ALTER COLUMN code DROP DEFAULT;
UPDATE rounds SET code=seq WHERE code='';
ALTER TABLE rounds ADD UNIQUE(year, category, code, part);
......@@ -250,7 +250,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, server_default=text("''::text"))
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))
......@@ -270,7 +270,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.code or self.seq}"
return f"{self.year}-{self.category}-{self.code}"
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 to comment