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
e8e8eb47
Project 'mj/mo-submit' was moved to 'mo-p/osmo'. Please update any links and bookmarks that may still have the old path.
Commit
e8e8eb47
authored
Mar 22, 2021
by
Jiří Setnička
Browse files
Options
Downloads
Patches
Plain Diff
DB: Zprávičky
parent
af17ab2c
No related branches found
No related tags found
1 merge request
!57
Zprávičky
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
db/db.ddl
+13
-0
13 additions, 0 deletions
db/db.ddl
db/upgrade-20210322.sql
+16
-0
16 additions, 0 deletions
db/upgrade-20210322.sql
mo/db.py
+15
-0
15 additions, 0 deletions
mo/db.py
with
44 additions
and
0 deletions
db/db.ddl
+
13
−
0
View file @
e8e8eb47
...
@@ -107,6 +107,7 @@ CREATE TABLE rounds (
...
@@ -107,6 +107,7 @@ CREATE TABLE rounds (
score_mode score_mode NOT NULL DEFAULT 'basic', -- mód výsledkovky
score_mode score_mode NOT NULL DEFAULT 'basic', -- mód výsledkovky
score_winner_limit int DEFAULT NULL, -- bodový limit na označení za vítěze
score_winner_limit int DEFAULT NULL, -- bodový limit na označení za vítěze
score_successful_limit int DEFAULT NULL, -- bodový limit na označení za úspěšného řešitele
score_successful_limit int DEFAULT NULL, -- bodový limit na označení za úspěšného řešitele
has_messages boolean NOT NULL DEFAULT false, -- má zprávičky
UNIQUE (year, category, seq, part)
UNIQUE (year, category, seq, part)
);
);
...
@@ -298,3 +299,15 @@ CREATE TABLE jobs (
...
@@ -298,3 +299,15 @@ CREATE TABLE jobs (
in_file varchar(255) DEFAULT NULL,
in_file varchar(255) DEFAULT NULL,
out_file varchar(255) DEFAULT NULL
out_file varchar(255) DEFAULT NULL
);
);
-- Zprávičky k soutěžím
CREATE TABLE messages (
message_id serial PRIMARY KEY,
round_id int NOT NULL REFERENCES rounds(round_id),
created_at timestamp with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP, -- čas publikování zprávičky
created_by int NOT NULL REFERENCES users(user_id), -- autor zprávičky
title text NOT NULL,
markdown text NOT NULL,
html text NOT NULL
);
This diff is collapsed.
Click to expand it.
db/upgrade-20210322.sql
0 → 100644
+
16
−
0
View file @
e8e8eb47
SET
ROLE
'mo_osmo'
;
-- Zprávičky k soutěžím
ALTER
TABLE
rounds
ADD
COLUMN
has_messages
boolean
NOT
NULL
DEFAULT
false
;
-- má zprávičky
CREATE
TABLE
messages
(
message_id
serial
PRIMARY
KEY
,
round_id
int
NOT
NULL
REFERENCES
rounds
(
round_id
),
created_at
timestamp
with
time
zone
NOT
NULL
DEFAULT
CURRENT_TIMESTAMP
,
-- čas publikování zprávičky
created_by
int
NOT
NULL
REFERENCES
users
(
user_id
),
-- autor zprávičky
title
text
NOT
NULL
,
markdown
text
NOT
NULL
,
html
text
NOT
NULL
);
This diff is collapsed.
Click to expand it.
mo/db.py
+
15
−
0
View file @
e8e8eb47
...
@@ -209,6 +209,7 @@ class Round(Base):
...
@@ -209,6 +209,7 @@ class Round(Base):
score_mode
=
Column
(
Enum
(
RoundScoreMode
,
name
=
'
score_mode
'
),
nullable
=
False
,
server_default
=
text
(
"'
basic
'
::score_mode
"
))
score_mode
=
Column
(
Enum
(
RoundScoreMode
,
name
=
'
score_mode
'
),
nullable
=
False
,
server_default
=
text
(
"'
basic
'
::score_mode
"
))
score_winner_limit
=
Column
(
Integer
)
score_winner_limit
=
Column
(
Integer
)
score_successful_limit
=
Column
(
Integer
)
score_successful_limit
=
Column
(
Integer
)
has_messages
=
Column
(
Boolean
,
nullable
=
False
,
server_default
=
text
(
"
false
"
))
master
=
relationship
(
'
Round
'
,
primaryjoin
=
'
Round.master_round_id == Round.round_id
'
,
remote_side
=
'
Round.round_id
'
,
post_update
=
True
)
master
=
relationship
(
'
Round
'
,
primaryjoin
=
'
Round.master_round_id == Round.round_id
'
,
remote_side
=
'
Round.round_id
'
,
post_update
=
True
)
...
@@ -592,6 +593,20 @@ class Job(Base):
...
@@ -592,6 +593,20 @@ class Job(Base):
user
=
relationship
(
'
User
'
)
user
=
relationship
(
'
User
'
)
class
Message
(
Base
):
__tablename__
=
'
messages
'
message_id
=
Column
(
Integer
,
primary_key
=
True
,
server_default
=
text
(
"
nextval(
'
messages_message_id_seq
'
::regclass)
"
))
round_id
=
Column
(
Integer
,
ForeignKey
(
'
rounds.round_id
'
),
nullable
=
False
)
created_at
=
Column
(
DateTime
(
True
),
nullable
=
False
,
server_default
=
text
(
"
CURRENT_TIMESTAMP
"
))
created_by
=
Column
(
Integer
,
ForeignKey
(
'
users.user_id
'
))
title
=
Column
(
Text
,
nullable
=
False
)
markdown
=
Column
(
Text
,
nullable
=
False
)
html
=
Column
(
Text
,
nullable
=
False
)
created_by_user
=
relationship
(
'
User
'
)
_engine
:
Optional
[
Engine
]
=
None
_engine
:
Optional
[
Engine
]
=
None
_session
:
Optional
[
Session
]
=
None
_session
:
Optional
[
Session
]
=
None
flask_db
:
Any
=
None
flask_db
:
Any
=
None
...
...
...
...
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