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
Martin Mareš
Odevzdávací Systém MO
Commits
2742e071
Commit
2742e071
authored
4 years ago
by
Jiří Setnička
Browse files
Options
Downloads
Patches
Plain Diff
DB: Přesunutí task_statement_available jako metodu db.Round
parent
45014c19
No related branches found
No related tags found
2 merge requests
!12
Účastnická část webu podporuje všechny stavy kola
,
!9
WIP: Zárodek uživatelské části webu a submitování
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
mo/db.py
+8
-0
8 additions, 0 deletions
mo/db.py
mo/web/user.py
+2
-12
2 additions, 12 deletions
mo/web/user.py
with
10 additions
and
12 deletions
mo/db.py
+
8
−
0
View file @
2742e071
...
...
@@ -15,6 +15,7 @@ from sqlalchemy.dialects.postgresql import JSONB
from
sqlalchemy.ext.declarative
import
declarative_base
from
typing
import
Optional
,
List
import
mo
# HACK: Work-around for https://github.com/dropbox/sqlalchemy-stubs/issues/114
from
typing
import
TYPE_CHECKING
,
TypeVar
,
Type
,
Any
...
...
@@ -186,6 +187,13 @@ class Round(Base):
def
round_code
(
self
):
return
f
"
{
self
.
year
}
-
{
self
.
category
}
-
{
self
.
seq
}
"
def
task_statement_available
(
self
)
->
bool
:
# Zde jsme raději přepečliví...
return
(
self
.
state
!=
RoundState
.
preparing
and
self
.
tasks_file
is
not
None
and
self
.
ct_tasks_start
is
not
None
and
mo
.
now
>=
self
.
ct_tasks_start
)
class
User
(
Base
):
__tablename__
=
'
users
'
...
...
This diff is collapsed.
Click to expand it.
mo/web/user.py
+
2
−
12
View file @
2742e071
...
...
@@ -76,16 +76,6 @@ def get_task(contest: db.Contest, id: int) -> db.Task:
return
task
def
task_statement_available
(
contest
:
db
.
Contest
)
->
bool
:
round
=
contest
.
round
# Zde jsme raději přepečliví...
return
(
round
.
state
==
db
.
RoundState
.
running
and
round
.
tasks_file
is
not
None
and
round
.
ct_tasks_start
is
not
None
and
mo
.
now
>=
round
.
ct_tasks_start
)
@app.route
(
'
/user/contest/<int:id>/
'
)
def
user_contest
(
id
:
int
):
contest
=
get_contest
(
id
)
...
...
@@ -104,7 +94,7 @@ def user_contest(id: int):
'
user_contest.html
'
,
contest
=
contest
,
task_sols
=
task_sols
,
statement_visible
=
task_statement_available
(
contest
),
statement_visible
=
contest
.
round
.
task_statement_available
(),
max_submit_size
=
config
.
MAX_CONTENT_LENGTH
,
db
=
db
,
# kvůli hodnotám enumů
)
...
...
@@ -114,7 +104,7 @@ def user_contest(id: int):
def
user_task_statement
(
id
:
int
):
contest
=
get_contest
(
id
)
if
not
task_statement_available
(
contest
):
if
not
contest
.
round
.
task_statement_available
():
logger
.
warn
(
f
'
Účastník #
{
g
.
user
.
user_id
}
chce zadání, na které nemá právo
'
)
raise
werkzeug
.
exceptions
.
Forbidden
()
...
...
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
register
or
sign in
to comment