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
a759772d
Commit
a759772d
authored
4 years ago
by
Martin Mareš
Browse files
Options
Downloads
Patches
Plain Diff
UI pro generování protokolů
parent
53708877
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
+53
-0
53 additions, 0 deletions
mo/web/org_contest.py
mo/web/templates/org_contest_protocols.html
+34
-0
34 additions, 0 deletions
mo/web/templates/org_contest_protocols.html
with
87 additions
and
0 deletions
mo/web/org_contest.py
+
53
−
0
View file @
a759772d
...
...
@@ -20,6 +20,7 @@ from mo.csv import FileFormat
import
mo.config
as
config
import
mo.db
as
db
from
mo.imports
import
ImportType
,
create_import
import
mo.jobs.protocols
import
mo.jobs.submit
from
mo.rights
import
Right
,
RoundRights
import
mo.util
...
...
@@ -1660,3 +1661,55 @@ def org_contest_add_user(ct_id: int, site_id: Optional[int] = None):
contest
=
contest
,
round
=
ctx
.
master_round
,
site
=
ctx
.
site
,
form
=
form
)
class
ProtoGenForm
(
FlaskForm
):
num_universal
=
wtforms
.
IntegerField
(
'
Univerzálních listů
'
,
default
=
0
,
validators
=
[
validators
.
NumberRange
(
min
=
0
,
max
=
1000
)],
description
=
'
Počet listů s univerzální hlavičkou, kterými může začínat řešení libovolné úlohy.
'
+
'
Při scanování se třídí ručně.
'
)
num_blank
=
wtforms
.
IntegerField
(
'
Pokračovacích listů
'
,
default
=
0
,
validators
=
[
validators
.
NumberRange
(
min
=
0
,
max
=
1000
)],
description
=
'
Počet listů na pokračování řešení.
'
,
)
gen_protos
=
wtforms
.
SubmitField
(
'
Vytvořit protokoly
'
)
@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
'
))
def
org_contest_protocols
(
ct_id
:
int
,
site_id
:
Optional
[
int
]
=
None
):
ctx
=
get_context
(
ct_id
=
ct_id
,
site_id
=
site_id
)
round
,
contest
,
site
=
ctx
.
round
,
ctx
.
contest
,
ctx
.
site
assert
contest
class
PGF
(
ProtoGenForm
):
pass
tasks
=
db
.
get_session
().
query
(
db
.
Task
).
filter_by
(
round
=
round
).
order_by
(
db
.
Task
.
code
).
all
()
for
t
in
tasks
:
setattr
(
PGF
,
f
'
task_
{
t
.
task_id
}
'
,
wtforms
.
BooleanField
(
t
.
code
,
default
=
True
))
gen_form
=
PGF
()
gen_task_fields
=
[
f
for
f
in
gen_form
if
f
.
name
.
startswith
(
'
task_
'
)]
if
gen_form
.
validate_on_submit
()
and
gen_form
.
gen_protos
.
data
:
mo
.
jobs
.
protocols
.
schedule_create_protocols
(
contest
,
site
,
g
.
user
,
tasks
=
[
t
for
t
in
tasks
if
getattr
(
gen_form
,
f
'
task_
{
t
.
task_id
}
'
).
data
],
num_universal
=
gen_form
.
num_universal
.
data
,
num_blank
=
gen_form
.
num_blank
.
data
,
)
flash
(
'
Výroba prototokolů zahájena.
'
,
'
success
'
)
return
redirect
(
url_for
(
'
org_jobs
'
))
return
render_template
(
'
org_contest_protocols.html
'
,
ctx
=
ctx
,
gen_form
=
gen_form
,
gen_task_fields
=
gen_task_fields
,
)
This diff is collapsed.
Click to expand it.
mo/web/templates/org_contest_protocols.html
0 → 100644
+
34
−
0
View file @
a759772d
{% extends "base.html" %}
{% import "bootstrap/wtf.html" as wtf %}
{% block title %}
Protokoly pro {{ ctx.round.name|lower }} kategorie {{ ctx.round.category }}
{% endblock %}
{% block breadcrumbs %}
{{ ctx.breadcrumbs(action="Protokoly") }}
{% endblock %}
{% block body %}
<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.
{% macro field(f) %}
{{ wtf.form_field(f, form_type='horizontal', horizontal_columns=('lg', 3, 7), button_map={'gen_protos': 'primary'}) }}
{% endmacro %}
<form
action=
""
method=
POST
class=
"form form-horizontal"
role=
"form"
>
{{ gen_form.csrf_token }}
{% if gen_task_fields %}
<div
class=
'form-group'
>
<label
class=
'control-label col-lg-3'
for=
'{{ gen_task_fields[0].id }}'
>
Úlohy
</label>
<div
class=
'col-lg-7'
>
{% for f in gen_task_fields %}
{{ wtf.form_field(f) }}
{% endfor %}
</div>
</div>
{% endif %}
{{ field(gen_form.num_universal) }}
{{ field(gen_form.num_blank) }}
{{ field(gen_form.gen_protos) }}
{% 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
register
or
sign in
to comment