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
fc1f361a
Commit
fc1f361a
authored
2 years ago
by
Martin Mareš
Browse files
Options
Downloads
Patches
Plain Diff
Účastnický submit ošetřuje kolize
Closes
#206
parent
1195ddeb
No related branches found
No related tags found
1 merge request
!129
Bezpečné transakce při zakládání uživatelů/účastníků/účastí
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
mo/web/user.py
+17
-13
17 additions, 13 deletions
mo/web/user.py
with
17 additions
and
13 deletions
mo/web/user.py
+
17
−
13
View file @
fc1f361a
...
@@ -5,6 +5,7 @@ import flask_wtf.file
...
@@ -5,6 +5,7 @@ import flask_wtf.file
import
hashlib
import
hashlib
import
hmac
import
hmac
from
sqlalchemy
import
and_
from
sqlalchemy
import
and_
from
sqlalchemy.dialects.postgresql
import
insert
as
pgsql_insert
from
sqlalchemy.orm
import
joinedload
from
sqlalchemy.orm
import
joinedload
from
typing
import
List
,
Tuple
,
Optional
from
typing
import
List
,
Tuple
,
Optional
import
werkzeug.exceptions
import
werkzeug.exceptions
...
@@ -409,22 +410,25 @@ def user_contest_task(contest_id: int, task_id: int):
...
@@ -409,22 +410,25 @@ def user_contest_task(contest_id: int, task_id: int):
flash
(
f
'
Chyba:
{
e
}
'
,
'
danger
'
)
flash
(
f
'
Chyba:
{
e
}
'
,
'
danger
'
)
return
redirect
(
url_for
(
'
user_contest_task
'
,
contest_id
=
contest_id
,
task_id
=
task_id
))
return
redirect
(
url_for
(
'
user_contest_task
'
,
contest_id
=
contest_id
,
task_id
=
task_id
))
is_broken
=
paper
.
is_broken
()
sess
.
add
(
paper
)
sess
.
add
(
paper
)
sess
.
flush
()
# FIXME: Bylo by hezké použít INSERT ... ON CONFLICT UPDATE
sess
.
connection
().
execute
(
# (SQLAlchemy to umí, ale ne přes ORM, jen core rozhraním)
pgsql_insert
(
db
.
Solution
.
__table__
)
sol
=
(
sess
.
query
(
db
.
Solution
)
.
values
(
.
filter_by
(
task
=
task
,
user
=
g
.
user
)
task_id
=
task
.
task_id
,
.
with_for_update
()
user_id
=
g
.
user
.
user_id
,
.
one_or_none
())
final_submit
=
paper
.
paper_id
,
if
sol
is
None
:
)
sol
=
db
.
Solution
(
task
=
task
,
user
=
g
.
user
)
.
on_conflict_do_update
(
sess
.
add
(
sol
)
constraint
=
'
solutions_pkey
'
,
sol
.
final_submit_obj
=
paper
set_
=
{
'
final_submit
'
:
paper
.
paper_id
},
)
)
sess
.
commit
()
sess
.
commit
()
if
paper
.
is_broken
()
:
if
is_broken
:
flash
(
'
Soubor není korektní PDF, ale přesto jsme ho přijali a pokusíme se ho zpracovat.
'
+
flash
(
'
Soubor není korektní PDF, ale přesto jsme ho přijali a pokusíme se ho zpracovat.
'
+
'
Zkontrolujte prosím, že se na vašem počítači zobrazuje správně.
'
,
'
Zkontrolujte prosím, že se na vašem počítači zobrazuje správně.
'
,
'
warning
'
)
'
warning
'
)
...
...
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