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
6387dee2
Project 'mj/mo-submit' was moved to 'mo-p/osmo'. Please update any links and bookmarks that may still have the old path.
Commit
6387dee2
authored
Jul 6, 2021
by
Martin Mareš
Browse files
Options
Downloads
Patches
Plain Diff
Protokoly: UI na objednání zpracování scanů
parent
b3cbae70
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
mo/web/org_contest.py
+28
-4
28 additions, 4 deletions
mo/web/org_contest.py
mo/web/templates/org_contest_protocols.html
+23
-1
23 additions, 1 deletion
mo/web/templates/org_contest_protocols.html
with
51 additions
and
5 deletions
mo/web/org_contest.py
+
28
−
4
View file @
6387dee2
...
@@ -1663,7 +1663,7 @@ def org_contest_add_user(ct_id: int, site_id: Optional[int] = None):
...
@@ -1663,7 +1663,7 @@ def org_contest_add_user(ct_id: int, site_id: Optional[int] = None):
)
)
class
Proto
Gen
Form
(
FlaskForm
):
class
Gen
ProtoForm
(
FlaskForm
):
num_universal
=
wtforms
.
IntegerField
(
num_universal
=
wtforms
.
IntegerField
(
'
Univerzálních listů
'
,
'
Univerzálních listů
'
,
default
=
0
,
default
=
0
,
...
@@ -1680,6 +1680,11 @@ class ProtoGenForm(FlaskForm):
...
@@ -1680,6 +1680,11 @@ class ProtoGenForm(FlaskForm):
gen_protos
=
wtforms
.
SubmitField
(
'
Vytvořit protokoly
'
)
gen_protos
=
wtforms
.
SubmitField
(
'
Vytvořit protokoly
'
)
class
ProcessScansForm
(
FlaskForm
):
files
=
wtforms
.
MultipleFileField
(
'
Soubory PDF se scany
'
,
validators
=
[
validators
.
required
()])
process_scans
=
wtforms
.
SubmitField
(
'
Zpracovat scany
'
)
@app.route
(
'
/org/contest/c/<int:ct_id>/protocols
'
,
methods
=
(
'
GET
'
,
'
POST
'
))
@app.route
(
'
/org/contest/c/<int:ct_id>/protocols
'
,
methods
=
(
'
GET
'
,
'
POST
'
))
@app.route
(
'
/org/contest/c/<int:ct_id>/site/<int:site_id>/protocols
'
,
methods
=
(
'
GET
'
,
'
POST
'
))
@app.route
(
'
/org/contest/c/<int:ct_id>/site/<int:site_id>/protocols
'
,
methods
=
(
'
GET
'
,
'
POST
'
))
def
org_contest_protocols
(
ct_id
:
int
,
site_id
:
Optional
[
int
]
=
None
):
def
org_contest_protocols
(
ct_id
:
int
,
site_id
:
Optional
[
int
]
=
None
):
...
@@ -1687,16 +1692,23 @@ def org_contest_protocols(ct_id: int, site_id: Optional[int] = None):
...
@@ -1687,16 +1692,23 @@ def org_contest_protocols(ct_id: int, site_id: Optional[int] = None):
round
,
contest
,
site
=
ctx
.
round
,
ctx
.
contest
,
ctx
.
site
round
,
contest
,
site
=
ctx
.
round
,
ctx
.
contest
,
ctx
.
site
assert
contest
assert
contest
class
PGF
(
ProtoGenForm
):
class
GPF
(
GenProtoForm
):
pass
class
PSF
(
ProcessScansForm
):
pass
pass
tasks
=
db
.
get_session
().
query
(
db
.
Task
).
filter_by
(
round
=
round
).
order_by
(
db
.
Task
.
code
).
all
()
tasks
=
db
.
get_session
().
query
(
db
.
Task
).
filter_by
(
round
=
round
).
order_by
(
db
.
Task
.
code
).
all
()
for
t
in
tasks
:
for
t
in
tasks
:
setattr
(
PGF
,
f
'
task_
{
t
.
task_id
}
'
,
wtforms
.
BooleanField
(
t
.
code
,
default
=
True
))
setattr
(
GPF
,
f
'
task_
{
t
.
task_id
}
'
,
wtforms
.
BooleanField
(
t
.
code
,
default
=
True
))
setattr
(
PSF
,
f
'
task_
{
t
.
task_id
}
'
,
wtforms
.
BooleanField
(
t
.
code
,
default
=
True
))
gen_form
=
P
GF
()
gen_form
=
G
P
F
()
gen_task_fields
=
[
f
for
f
in
gen_form
if
f
.
name
.
startswith
(
'
task_
'
)]
gen_task_fields
=
[
f
for
f
in
gen_form
if
f
.
name
.
startswith
(
'
task_
'
)]
proc_form
=
PSF
()
proc_task_fields
=
[
f
for
f
in
proc_form
if
f
.
name
.
startswith
(
'
task_
'
)]
if
gen_form
.
validate_on_submit
()
and
gen_form
.
gen_protos
.
data
:
if
gen_form
.
validate_on_submit
()
and
gen_form
.
gen_protos
.
data
:
mo
.
jobs
.
protocols
.
schedule_create_protocols
(
mo
.
jobs
.
protocols
.
schedule_create_protocols
(
contest
,
site
,
g
.
user
,
contest
,
site
,
g
.
user
,
...
@@ -1707,9 +1719,21 @@ def org_contest_protocols(ct_id: int, site_id: Optional[int] = None):
...
@@ -1707,9 +1719,21 @@ def org_contest_protocols(ct_id: int, site_id: Optional[int] = None):
flash
(
'
Výroba prototokolů zahájena.
'
,
'
success
'
)
flash
(
'
Výroba prototokolů zahájena.
'
,
'
success
'
)
return
redirect
(
url_for
(
'
org_jobs
'
))
return
redirect
(
url_for
(
'
org_jobs
'
))
if
proc_form
.
validate_on_submit
()
and
proc_form
.
process_scans
.
data
:
files
=
request
.
files
.
getlist
(
proc_form
.
files
.
name
)
mo
.
jobs
.
protocols
.
schedule_process_scans
(
contest
,
site
,
g
.
user
,
tasks
=
[
t
for
t
in
tasks
if
getattr
(
proc_form
,
f
'
task_
{
t
.
task_id
}
'
).
data
],
in_file_names
=
[
f
.
stream
.
name
for
f
in
files
],
)
flash
(
'
Zpracování scanů zahájeno.
'
,
'
success
'
)
return
redirect
(
url_for
(
'
org_jobs
'
))
return
render_template
(
return
render_template
(
'
org_contest_protocols.html
'
,
'
org_contest_protocols.html
'
,
ctx
=
ctx
,
ctx
=
ctx
,
gen_form
=
gen_form
,
gen_form
=
gen_form
,
gen_task_fields
=
gen_task_fields
,
gen_task_fields
=
gen_task_fields
,
proc_form
=
proc_form
,
proc_task_fields
=
proc_task_fields
,
)
)
This diff is collapsed.
Click to expand it.
mo/web/templates/org_contest_protocols.html
+
23
−
1
View file @
6387dee2
...
@@ -12,8 +12,10 @@ Protokoly pro {{ ctx.round.name|lower }} kategorie {{ ctx.round.category }}
...
@@ -12,8 +12,10 @@ Protokoly pro {{ ctx.round.name|lower }} kategorie {{ ctx.round.category }}
<p>
Zde je možné vytvořit PDF s formuláři protokolů pro všechny soutěžící. Každý
<p>
Zde je možné vytvořit PDF s formuláři protokolů pro všechny soutěžící. Každý
formulář je opatřen unikátním QR kódem. FIXME: Dovysvětlit.
formulář je opatřen unikátním QR kódem. FIXME: Dovysvětlit.
<h3>
Formuláře protokolů
</h3>
{% macro field(f) %}
{% macro field(f) %}
{{ wtf.form_field(f, form_type='horizontal', horizontal_columns=('lg', 3, 7), button_map={'gen_protos': 'primary'}) }}
{{ wtf.form_field(f, form_type='horizontal', horizontal_columns=('lg', 3, 7), button_map={'gen_protos':
'primary', 'process_scans':
'primary'}) }}
{% endmacro %}
{% endmacro %}
<form
action=
""
method=
POST
class=
"form form-horizontal"
role=
"form"
>
<form
action=
""
method=
POST
class=
"form form-horizontal"
role=
"form"
>
...
@@ -31,4 +33,24 @@ formulář je opatřen unikátním QR kódem. FIXME: Dovysvětlit.
...
@@ -31,4 +33,24 @@ formulář je opatřen unikátním QR kódem. FIXME: Dovysvětlit.
{{ field(gen_form.num_universal) }}
{{ field(gen_form.num_universal) }}
{{ field(gen_form.num_blank) }}
{{ field(gen_form.num_blank) }}
{{ field(gen_form.gen_protos) }}
{{ field(gen_form.gen_protos) }}
</form>
<h3>
Zpracování scanů
</h3>
<form
action=
""
method=
POST
class=
"form form-horizontal"
role=
"form"
enctype=
'multipart/form-data'
>
{{ proc_form.csrf_token }}
{% if proc_task_fields %}
<div
class=
'form-group'
>
<label
class=
'control-label col-lg-3'
for=
'{{ proc_task_fields[0].id }}'
>
Úlohy
</label>
<div
class=
'col-lg-7'
>
{% for f in proc_task_fields %}
{{ wtf.form_field(f) }}
{% endfor %}
</div>
</div>
{% endif %}
{{ field(proc_form.files) }}
{{ field(proc_form.process_scans) }}
</form>
{% endblock %}
{% endblock %}
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