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

DB: Zavedeny stavy kol, zaneseno do mo.db

parent 651feb07
Branches
No related tags found
1 merge request!9WIP: Zárodek uživatelské části webu a submitování
......@@ -73,9 +73,9 @@ CREATE TABLE schools (
CREATE TYPE round_state AS ENUM (
'preparing', -- v přípravě (viditelné pouze organizátorům)
'submit', -- je možno odevzdávat
'ready', -- je možno odevzdávat (za daných časových omezeních)
'grading', -- je možno opravovat a vyplňovat body
'closed', -- uzavřeno, není dovoleno nic měnit, zveřejněny výsledky
'closed' -- uzavřeno, není dovoleno nic měnit, zveřejněny výsledky
-- garanta stavy neomezují, vždycky může všechno
);
......@@ -86,7 +86,7 @@ CREATE TABLE rounds (
seq int NOT NULL, -- 1=domácí kolo atd.
level int NOT NULL, -- úroveň hierarchie míst
name varchar(255) NOT NULL, -- zobrazované jméno ("Krajské kolo" apod.)
state round_state NOT NULL DEFAULT preparing, -- stav kola
state round_state NOT NULL DEFAULT 'preparing', -- stav kola
submit_start timestamp with time zone DEFAULT NULL, -- od kdy se smí odevzdávat
ct_submit_end timestamp with time zone DEFAULT NULL, -- do kdy mohou odevzdávat účastníci
pr_submit_end timestamp with time zone DEFAULT NULL, -- do kdy může odevzdávat dozor
......@@ -221,5 +221,4 @@ CREATE TABLE log (
details jsonb NOT NULL -- detaily (závislé na typu)
);
-- FIXME: Obecná políčka na poznámky
-- FIXME: Indexy
......@@ -38,6 +38,13 @@ class MOEnum(str, PythonEnum):
def _generate_next_value_(name, start, count, last_values):
return name
@classmethod
def choices(enum):
out = []
for item in enum:
out.append((item.name, item.friendly_name()))
return out
class PlaceType(MOEnum):
region = auto()
......@@ -140,6 +147,24 @@ class School(Base):
place = relationship('Place', uselist=False, back_populates='school')
class RoundState(MOEnum):
preparing = auto()
ready = auto()
grading = auto()
closed = auto()
def friendly_name(self) -> str:
return round_state_names[self]
round_state_names = {
RoundState.preparing: 'připrava',
RoundState.ready: 'připraveno',
RoundState.grading: 'opravuje se',
RoundState.closed: 'ukončeno',
}
class Round(Base):
__tablename__ = 'rounds'
__table_args__ = (
......@@ -152,6 +177,10 @@ class Round(Base):
seq = Column(Integer, nullable=False)
level = Column(Integer, nullable=False)
name = Column(String(255), nullable=False)
state = Column(Enum(RoundState, name='round_state'), nullable=False, server_default=text("'preparing'::round_state"))
submit_start = Column(DateTime(True))
ct_submit_end = Column(DateTime(True))
pr_submit_end = Column(DateTime(True))
def round_code(self):
return f"{self.year}-{self.category}-{self.seq}"
......@@ -166,6 +195,7 @@ class User(Base):
last_name = Column(String(255), nullable=False)
is_org = Column(Boolean, nullable=False, server_default=text("false"))
is_admin = Column(Boolean, nullable=False, server_default=text("false"))
is_test = Column(Boolean, nullable=False, server_default=text("false"))
created_at = Column(DateTime(True), nullable=False, server_default=text("CURRENT_TIMESTAMP"))
last_login_at = Column(DateTime(True))
reset_at = Column(DateTime(True))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment