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

DB: Úloha má typ

parent 62609c8f
No related branches found
No related tags found
1 merge request!98Praktické úlohy a propojení s CMS
...@@ -179,13 +179,20 @@ CREATE TABLE participations ( ...@@ -179,13 +179,20 @@ CREATE TABLE participations (
CREATE INDEX participations_contest_id_index ON participations (contest_id, place_id); CREATE INDEX participations_contest_id_index ON participations (contest_id, place_id);
-- Úloha -- Úlohy
CREATE TYPE task_type AS ENUM (
'regular', -- obyčejná úloha
'cms' -- praktická úloha kategorie P odevzdávaná přes CMS
);
CREATE TABLE tasks ( CREATE TABLE tasks (
task_id serial PRIMARY KEY, task_id serial PRIMARY KEY,
round_id int NOT NULL REFERENCES rounds(round_id), round_id int NOT NULL REFERENCES rounds(round_id),
code varchar(255) NOT NULL, -- např. "P-I-1" code varchar(255) NOT NULL, -- např. "P-I-1"
name varchar(255) NOT NULL, name varchar(255) NOT NULL,
max_points numeric(5,1) DEFAULT NULL, -- maximální počet bodů, pokud je nastaven, nelze zadat více bodů max_points numeric(5,1) DEFAULT NULL, -- maximální počet bodů, pokud je nastaven, nelze zadat více bodů
type task_type NOT NULL DEFAULT 'regular',
UNIQUE (round_id, code) UNIQUE (round_id, code)
); );
......
SET ROLE 'mo_osmo';
CREATE TYPE task_type AS ENUM (
'regular', -- obyčejná úloha
'cms' -- praktická úloha kategorie P odevzdávaná přes CMS
);
ALTER TABLE tasks ADD COLUMN type task_type NOT NULL DEFAULT 'regular';
...@@ -476,6 +476,20 @@ class Participation(Base): ...@@ -476,6 +476,20 @@ class Participation(Base):
user = relationship('User') user = relationship('User')
class TaskType(MOEnum):
regular = auto()
cms = auto()
def friendly_name(self) -> str:
return task_type_names[self]
task_type_names = {
TaskType.regular: 'standardní',
TaskType.cms: 'programovací (CMS)',
}
class Task(Base): class Task(Base):
__tablename__ = 'tasks' __tablename__ = 'tasks'
__table_args__ = ( __table_args__ = (
...@@ -487,6 +501,7 @@ class Task(Base): ...@@ -487,6 +501,7 @@ class Task(Base):
code = Column(String(255), nullable=False) code = Column(String(255), nullable=False)
name = Column(String(255), nullable=False) name = Column(String(255), nullable=False)
max_points = Column(Numeric) max_points = Column(Numeric)
type = Column(Enum(TaskType, name='task_type'), nullable=False, default=TaskType.regular)
round = relationship('Round') round = relationship('Round')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment