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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Martin Mareš
Odevzdávací Systém MO
Commits
161176a0
Commit
161176a0
authored
4 years ago
by
Martin Mareš
Browse files
Options
Downloads
Patches
Plain Diff
Přehled soutěží na hlavní orgovské stránce
parent
7d5cc4b5
No related branches found
No related tags found
1 merge request
!80
Moje soutěže (minimalistická verze)
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
mo/web/org.py
+38
-5
38 additions, 5 deletions
mo/web/org.py
mo/web/templates/org_index.html
+33
-0
33 additions, 0 deletions
mo/web/templates/org_index.html
with
71 additions
and
5 deletions
mo/web/org.py
+
38
−
5
View file @
161176a0
from
flask
import
render_template
,
redirect
,
url_for
,
request
,
flash
from
flask
import
render_template
,
redirect
,
url_for
,
request
,
flash
,
g
from
sqlalchemy.orm
import
aliased
from
sqlalchemy
import
and_
,
or_
from
sqlalchemy.orm
import
aliased
,
joinedload
from
typing
import
List
,
Set
,
Dict
import
mo.db
as
db
import
mo.db
as
db
from
mo.web.jinja
import
user_url
import
mo.rights
import
mo.users
import
mo.users
from
mo.web.table
import
Table
,
Row
,
Column
from
mo.web
import
app
from
mo.web
import
app
from
mo.web.jinja
import
user_url
from
mo.web.table
import
Table
,
Row
,
Column
@app.route
(
'
/org/
'
)
@app.route
(
'
/org/
'
)
...
@@ -28,7 +31,37 @@ def org_index():
...
@@ -28,7 +31,37 @@ def org_index():
except
ValueError
:
except
ValueError
:
flash
(
'
ID uživatele musí být číslo
'
,
'
danger
'
)
flash
(
'
ID uživatele musí být číslo
'
,
'
danger
'
)
return
render_template
(
'
org_index.html
'
)
sess
=
db
.
get_session
()
ctr
=
(
sess
.
query
(
db
.
Contest
,
db
.
UserRole
)
.
select_from
(
db
.
UserRole
,
db
.
Round
,
db
.
Contest
)
.
filter
(
and_
(
db
.
UserRole
.
user_id
==
g
.
user
.
user_id
,
or_
(
db
.
UserRole
.
category
==
None
,
db
.
UserRole
.
category
==
db
.
Round
.
category
),
or_
(
db
.
UserRole
.
year
==
None
,
db
.
UserRole
.
year
==
db
.
Round
.
year
),
or_
(
db
.
UserRole
.
seq
==
None
,
db
.
UserRole
.
seq
==
db
.
Round
.
seq
),
db
.
Round
.
year
==
mo
.
current_year
,
db
.
Contest
.
round_id
==
db
.
Round
.
round_id
,
db
.
Contest
.
place_id
==
db
.
UserRole
.
place_id
))
.
options
(
joinedload
(
db
.
Contest
.
place
))
.
order_by
(
db
.
Round
.
level
,
db
.
Round
.
category
,
db
.
Round
.
seq
,
db
.
Round
.
part
,
db
.
Contest
.
place_id
,
db
.
Contest
.
contest_id
)
.
all
())
# Pokud máme pro jednu soutěž více rolí, zkombinujeme je
contests
:
List
[
db
.
Contest
]
=
[]
contest_role_sets
:
Dict
[
db
.
Contest
,
Set
[
db
.
RoleType
]]
=
{}
for
ct
,
ur
in
ctr
:
if
len
(
contests
)
==
0
or
contests
[
-
1
]
!=
ct
:
contests
.
append
(
ct
)
contest_role_sets
[
ct
.
contest_id
]
=
set
()
contest_role_sets
[
ct
.
contest_id
].
add
(
ur
.
role
)
# Role pro každou soutěž setřídíme podle důležitosti
contest_roles
:
Dict
[
db
.
Contest
,
List
[
db
.
RoleType
]]
=
{
ct_id
:
sorted
(
list
(
contest_role_sets
[
ct_id
]),
key
=
lambda
r
:
mo
.
rights
.
role_order_by_type
[
r
])
for
ct_id
in
contest_role_sets
.
keys
()
}
return
render_template
(
'
org_index.html
'
,
contests
=
contests
,
contest_roles
=
contest_roles
,
role_type_names
=
db
.
role_type_names
)
school_export_columns
=
(
school_export_columns
=
(
...
...
This diff is collapsed.
Click to expand it.
mo/web/templates/org_index.html
+
33
−
0
View file @
161176a0
...
@@ -2,6 +2,39 @@
...
@@ -2,6 +2,39 @@
{% block title %}Organizátorské rozhraní{% endblock %}
{% block title %}Organizátorské rozhraní{% endblock %}
{% block body %}
{% block body %}
{% if contests %}
<h3>
Moje soutěže
</h3>
<table
class=
"table table-bordered table-condensed greyhead"
>
{% set curr = namespace(level=-1) %}
{% for c in contests %}
{% if curr.level != c.round.level %}
<thead><tr>
<th>
ID
<th>
Kategorie
<th>
Kolo
<th>
{{ c.round.get_level().name|capitalize }}
<th>
Stav
<th>
Moje role
<th>
Odkazy
</thead>
{% set curr.level = c.round.level %}
{% endif %}
<tr>
<td><a
href=
'{{ url_for('
org_contest
',
id=
c.contest_id)
}}'
>
{{ c.round.round_code() }}
</a>
<td
class=
"text-center"
><b>
{{ c.round.category }}
</b>
<td>
{{ c.round.name }}
<td>
{{ c.place.name }}
<td
class=
"rstate-{{c.state.name}}"
>
{{ c.state.friendly_name() }}
<td>
{% for r in contest_roles[c.contest_id] %}{{ role_type_names[r] }}{% if not loop.last %}
<br>
{% endif %}{% endfor %}
<td>
<a
class=
"btn btn-xs btn-primary"
href=
'{{ url_for('
org_contest
',
id=
c.contest_id)
}}'
>
Detail
</a>
{% endfor %}
</table>
{% endif %}
<h3>
Různé
</h3>
<h3>
Různé
</h3>
<ul>
<ul>
...
...
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