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
98e263ef
Project 'mj/mo-submit' was moved to 'mo-p/osmo'. Please update any links and bookmarks that may still have the old path.
Commit
98e263ef
authored
Nov 21, 2021
by
Martin Mareš
Browse files
Options
Downloads
Patches
Plain Diff
Statistiky na orgovské domácí stránce
Closes
#239
.
parent
caac11ce
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.py
+45
-2
45 additions, 2 deletions
mo/web/org.py
mo/web/templates/org_index.html
+5
-2
5 additions, 2 deletions
mo/web/templates/org_index.html
with
50 additions
and
4 deletions
mo/web/org.py
+
45
−
2
View file @
98e263ef
from
dataclasses
import
dataclass
,
field
from
flask
import
render_template
,
redirect
,
url_for
,
request
,
flash
,
g
from
sqlalchemy
import
and_
,
or_
from
sqlalchemy
import
and_
,
or_
,
tuple_
from
sqlalchemy.orm
import
aliased
,
joinedload
from
typing
import
List
,
Set
,
Optional
from
typing
import
List
,
Set
,
Optional
,
Dict
,
Tuple
import
mo.config
as
config
import
mo.db
as
db
...
...
@@ -20,6 +20,10 @@ class OrgOverview:
contest
:
Optional
[
db
.
Contest
]
role_set
:
Set
[
db
.
RoleType
]
=
field
(
default_factory
=
set
)
role_list
:
List
[
db
.
RoleType
]
=
field
(
default_factory
=
list
)
num_contests
:
int
=
0
contest_states
:
Set
[
db
.
RoundState
]
=
field
(
default_factory
=
set
)
num_active_pants
:
int
=
0
num_unconfirmed_pants
:
int
=
0
@app.route
(
'
/org/
'
)
...
...
@@ -74,9 +78,48 @@ def org_index():
for
o
in
overview
:
o
.
role_list
=
sorted
(
o
.
role_set
,
key
=
lambda
r
:
mo
.
rights
.
role_order_by_type
[
r
])
get_stats
(
overview
)
return
render_template
(
'
org_index.html
'
,
overview
=
overview
,
role_type_names
=
db
.
role_type_names
)
def
get_stats
(
overview
:
List
[
OrgOverview
])
->
None
:
sess
=
db
.
get_session
()
over_by_round_place
:
Dict
[
Tuple
[
int
,
int
],
OrgOverview
]
=
{}
rcs_for
:
List
[
Tuple
[
int
,
int
]]
=
[]
rps_for
:
List
[
Tuple
[
int
,
int
]]
=
[]
for
o
in
overview
:
rp
=
(
o
.
round
.
round_id
,
o
.
place
.
place_id
)
over_by_round_place
[
rp
]
=
o
if
o
.
contest
:
o
.
num_contests
=
1
o
.
contest_states
.
add
(
o
.
contest
.
state
)
else
:
rcs_for
.
append
(
rp
)
rps_for
.
append
(
rp
)
if
rcs_for
:
rcss
=
(
sess
.
query
(
db
.
RegionContestStat
)
.
filter
(
tuple_
(
db
.
RegionContestStat
.
round_id
,
db
.
RegionContestStat
.
region
).
in_
(
rcs_for
))
.
all
())
for
rcs
in
rcss
:
o
=
over_by_round_place
[(
rcs
.
round_id
,
rcs
.
region
)]
o
.
num_contests
+=
rcs
.
count
o
.
contest_states
.
add
(
rcs
.
state
)
if
rps_for
:
rpss
=
(
sess
.
query
(
db
.
RegionParticipantStat
)
.
filter
(
tuple_
(
db
.
RegionParticipantStat
.
round_id
,
db
.
RegionParticipantStat
.
region
).
in_
(
rps_for
))
.
all
())
for
rps
in
rpss
:
o
=
over_by_round_place
[(
rps
.
round_id
,
rps
.
region
)]
if
rps
.
state
==
db
.
PartState
.
active
:
o
.
num_active_pants
+=
rps
.
count
elif
rps
.
state
==
db
.
PartState
.
registered
:
o
.
num_unconfirmed_pants
+=
rps
.
count
school_export_columns
=
(
Column
(
key
=
'
code
'
,
name
=
'
kod
'
),
Column
(
key
=
'
name
'
,
name
=
'
nazev
'
),
...
...
This diff is collapsed.
Click to expand it.
mo/web/templates/org_index.html
+
5
−
2
View file @
98e263ef
...
...
@@ -15,6 +15,7 @@
<th>
Kolo
<th>
{{ o.round.get_level().name|capitalize }}
<th>
Stav
<th
class=
'has-tip'
title=
'S=soutěže, U=soutěžící účastníci, P=přihlášky čekající na potvrzení'
>
Statistiky
<th>
Moje role
<th>
Odkazy
</thead>
...
...
@@ -35,11 +36,13 @@
<td>
{{ o.round.name }}
{% if o.contest %}
<td>
{{ o.place.name }}
<td
class=
"rstate-{{o.contest.state.name}}"
>
{{ o.contest.state.friendly_name() }}
{% else %}
<td><i>
{{ o.place.name_locative() }}
</i>
<td>
{% endif %}
<td>
{% for s in o.contest_states %}{% if not loop.first %}
<br>
{% endif %}
<span
class=
"rstate-{{s.name}}"
>
{{ s.friendly_name() }}
</span>
{% endfor %}
<td>
{% if not o.contest %}{{ o.num_contests }}S / {% endif %}
{{- o.num_active_pants }}U
{%- if o.num_unconfirmed_pants %} /
<span
class=
'warning-text'
>
{{ o.num_unconfirmed_pants }}P
</span>
{% endif %}
<td>
{% for r in o.role_list %}{{ role_type_names[r] }}{% if not loop.last %}
<br>
{% endif %}{% endfor %}
<td><a
class=
"btn btn-xs btn-primary"
href=
'{{ detail_url }}'
>
Detail
</a>
{% endfor %}
...
...
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