Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Odevzdávací Systém MO
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
MO-P
Odevzdávací Systém MO
Commits
cdf28165
Commit
cdf28165
authored
Oct 6, 2021
by
Martin Mareš
Browse files
Options
Downloads
Patches
Plain Diff
DB: Kód kola je povinný
parent
67c907cc
No related branches found
No related tags found
1 merge request
!97
Import orgů
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
db/db.ddl
+4
-3
4 additions, 3 deletions
db/db.ddl
db/upgrade-20211006.sql
+7
-0
7 additions, 0 deletions
db/upgrade-20211006.sql
mo/db.py
+2
-2
2 additions, 2 deletions
mo/db.py
with
13 additions
and
5 deletions
db/db.ddl
+
4
−
3
View file @
cdf28165
...
...
@@ -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);
...
...
This diff is collapsed.
Click to expand it.
db/upgrade-20211006.sql
0 → 100644
+
7
−
0
View file @
cdf28165
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
);
This diff is collapsed.
Click to expand it.
mo/db.py
+
2
−
2
View file @
cdf28165
...
...
@@ -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
""
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
sign in
to comment