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

DB: Delegace v db.py

parent 95e8f42b
No related branches found
No related tags found
1 merge request!49Stavy soutěže
...@@ -157,6 +157,7 @@ class RoundState(MOEnum): ...@@ -157,6 +157,7 @@ class RoundState(MOEnum):
running = auto() running = auto()
grading = auto() grading = auto()
closed = auto() closed = auto()
delegate = auto()
def friendly_name(self) -> str: def friendly_name(self) -> str:
return round_state_names[self] return round_state_names[self]
...@@ -167,6 +168,7 @@ round_state_names = { ...@@ -167,6 +168,7 @@ round_state_names = {
RoundState.running: 'běží', RoundState.running: 'běží',
RoundState.grading: 'opravuje se', RoundState.grading: 'opravuje se',
RoundState.closed: 'ukončeno', RoundState.closed: 'ukončeno',
RoundState.delegate: 'po oblastech',
} }
...@@ -305,6 +307,7 @@ class Contest(Base): ...@@ -305,6 +307,7 @@ class Contest(Base):
master_contest_id = Column(Integer, ForeignKey('contests.contest_id')) master_contest_id = Column(Integer, ForeignKey('contests.contest_id'))
round_id = Column(Integer, ForeignKey('rounds.round_id'), nullable=False) round_id = Column(Integer, ForeignKey('rounds.round_id'), nullable=False)
place_id = Column(Integer, ForeignKey('places.place_id'), nullable=False) place_id = Column(Integer, ForeignKey('places.place_id'), nullable=False)
state = Column(Enum(RoundState, name='round_state'), nullable=False, server_default=text("'preparing'::round_state"))
master = relationship('Contest', primaryjoin='Contest.master_contest_id == Contest.contest_id', remote_side='Contest.contest_id', post_update=True) master = relationship('Contest', primaryjoin='Contest.master_contest_id == Contest.contest_id', remote_side='Contest.contest_id', post_update=True)
place = relationship('Place') place = relationship('Place')
...@@ -320,6 +323,13 @@ class Contest(Base): ...@@ -320,6 +323,13 @@ class Contest(Base):
add_self or Contest.contest_id != self.contest_id, add_self or Contest.contest_id != self.contest_id,
).options(joinedload(Contest.round)).all() ).options(joinedload(Contest.round)).all()
def get_state(self):
if self.round.state != RoundState.delegate:
return self.round.state
else:
return self.state
class LogType(MOEnum): class LogType(MOEnum):
general = auto() general = auto()
user = auto() user = auto()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment