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
73e6c50a
Commit
73e6c50a
authored
4 years ago
by
Martin Mareš
Browse files
Options
Downloads
Patches
Plain Diff
Správce kola může nahrát soubor se zadáním
parent
ea743f62
Branches
Branches containing commit
No related tags found
1 merge request
!75
Upload zadání
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
mo/web/org_round.py
+57
-0
57 additions, 0 deletions
mo/web/org_round.py
mo/web/templates/org_edit_statement.html
+12
-0
12 additions, 0 deletions
mo/web/templates/org_edit_statement.html
mo/web/templates/org_round.html
+1
-0
1 addition, 0 deletions
mo/web/templates/org_round.html
with
70 additions
and
0 deletions
mo/web/org_round.py
+
57
−
0
View file @
73e6c50a
import
decimal
import
decimal
from
flask
import
render_template
,
g
,
redirect
,
url_for
,
flash
,
request
from
flask
import
render_template
,
g
,
redirect
,
url_for
,
flash
,
request
import
locale
import
locale
import
flask_wtf.file
from
flask_wtf.form
import
FlaskForm
from
flask_wtf.form
import
FlaskForm
import
bleach
import
bleach
from
bleach.sanitizer
import
ALLOWED_TAGS
from
bleach.sanitizer
import
ALLOWED_TAGS
import
markdown
import
markdown
import
os
from
sqlalchemy
import
func
from
sqlalchemy
import
func
from
sqlalchemy.orm
import
joinedload
from
sqlalchemy.orm
import
joinedload
from
sqlalchemy.sql.functions
import
coalesce
from
sqlalchemy.sql.functions
import
coalesce
...
@@ -520,6 +522,61 @@ def org_task_statement(id: int):
...
@@ -520,6 +522,61 @@ def org_task_statement(id: int):
return
mo
.
web
.
util
.
send_task_statement
(
round
)
return
mo
.
web
.
util
.
send_task_statement
(
round
)
class
StatementEditForm
(
FlaskForm
):
file
=
flask_wtf
.
file
.
FileField
(
"
Soubor
"
,
render_kw
=
{
'
autofocus
'
:
True
})
upload
=
wtforms
.
SubmitField
(
'
Nahrát
'
)
delete
=
wtforms
.
SubmitField
(
'
Smazat
'
)
@app.route
(
'
/org/contest/r/<int:id>/task-statement/edit
'
,
methods
=
(
'
GET
'
,
'
POST
'
))
def
org_edit_statement
(
id
:
int
):
sess
=
db
.
get_session
()
round
,
_
,
rr
=
get_round_rr
(
id
,
Right
.
manage_round
,
True
)
def
log_changes
():
if
sess
.
is_modified
(
round
):
changes
=
db
.
get_object_changes
(
round
)
app
.
logger
.
info
(
f
"
Kolo #
{
id
}
změněno, změny:
{
changes
}
"
)
mo
.
util
.
log
(
type
=
db
.
LogType
.
round
,
what
=
id
,
details
=
{
'
action
'
:
'
edit
'
,
'
changes
'
:
changes
},
)
form
=
StatementEditForm
()
if
form
.
validate_on_submit
():
if
form
.
upload
.
data
:
if
form
.
file
.
data
is
not
None
:
file
=
form
.
file
.
data
.
stream
secure_category
=
werkzeug
.
utils
.
secure_filename
(
round
.
category
)
stmt_dir
=
f
'
{
round
.
year
}
-
{
secure_category
}
-
{
round
.
seq
}
'
full_dir
=
os
.
path
.
join
(
mo
.
util
.
data_dir
(
'
statements
'
),
stmt_dir
)
os
.
makedirs
(
full_dir
,
exist_ok
=
True
)
full_name
=
mo
.
util
.
link_to_dir
(
file
.
name
,
full_dir
,
suffix
=
'
.pdf
'
)
file_name
=
os
.
path
.
join
(
stmt_dir
,
os
.
path
.
basename
(
full_name
))
app
.
logger
.
info
(
f
'
Nahráno zadání:
{
file_name
}
'
)
round
.
tasks_file
=
file_name
log_changes
()
sess
.
commit
()
flash
(
'
Zadání nahráno
'
,
'
success
'
)
return
redirect
(
url_for
(
'
org_round
'
,
id
=
id
))
else
:
flash
(
'
Vyberte si prosím soubor
'
,
'
danger
'
)
if
form
.
delete
.
data
:
round
.
tasks_file
=
None
log_changes
()
sess
.
commit
()
flash
(
'
Zadání smazáno
'
,
'
success
'
)
return
redirect
(
url_for
(
'
org_round
'
,
id
=
id
))
return
render_template
(
'
org_edit_statement.html
'
,
round
=
round
,
form
=
form
,
)
class
MessageAddForm
(
FlaskForm
):
class
MessageAddForm
(
FlaskForm
):
title
=
wtforms
.
StringField
(
'
Nadpis
'
,
validators
=
[
validators
.
Required
()])
title
=
wtforms
.
StringField
(
'
Nadpis
'
,
validators
=
[
validators
.
Required
()])
markdown
=
wtforms
.
TextAreaField
(
markdown
=
wtforms
.
TextAreaField
(
...
...
This diff is collapsed.
Click to expand it.
mo/web/templates/org_edit_statement.html
0 → 100644
+
12
−
0
View file @
73e6c50a
{% extends "base.html" %}
{% import "bootstrap/wtf.html" as wtf %}
{% block title %}Zadání kola {{ round.round_code() }}{% endblock %}
{% block breadcrumbs %}
{{ contest_breadcrumbs(round=round, action="Zadáni") }}
{% endblock %}
{% block body %}
{{ wtf.quick_form(form, form_type='horizontal', button_map={'upload': 'primary', 'delete': 'danger'}) }}
{% endblock %}
This diff is collapsed.
Click to expand it.
mo/web/templates/org_round.html
+
1
−
0
View file @
73e6c50a
...
@@ -77,6 +77,7 @@
...
@@ -77,6 +77,7 @@
{% endif %}
{% endif %}
{% if can_manage_round %}
{% if can_manage_round %}
<a
class=
"btn btn-default"
href=
'{{ url_for('
org_round_edit
',
id=
round.round_id)
}}'
>
Nastavení a termíny
</a>
<a
class=
"btn btn-default"
href=
'{{ url_for('
org_round_edit
',
id=
round.round_id)
}}'
>
Nastavení a termíny
</a>
<a
class=
"btn btn-default"
href=
'{{ url_for('
org_edit_statement
',
id=
round.round_id)
}}'
>
Zadání
</a>
{% endif %}
{% endif %}
{% if round.has_messages %}
{% if round.has_messages %}
<a
class=
"btn btn-default"
href=
'{{ url_for('
org_round_messages
',
id=
round.round_id)
}}'
>
Zprávičky
</a>
<a
class=
"btn btn-default"
href=
'{{ url_for('
org_round_messages
',
id=
round.round_id)
}}'
>
Zprávičky
</a>
...
...
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