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
13c1e0e5
Commit
13c1e0e5
authored
4 years ago
by
Martin Mareš
Browse files
Options
Downloads
Patches
Plain Diff
Klikací odkazy v tabulkach
parent
609c0013
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
+9
-7
9 additions, 7 deletions
mo/web/org_contest.py
mo/web/table.py
+14
-4
14 additions, 4 deletions
mo/web/table.py
with
23 additions
and
11 deletions
mo/web/org_contest.py
+
9
−
7
View file @
13c1e0e5
...
...
@@ -16,7 +16,7 @@ import mo.imports
import
mo.rights
import
mo.util
from
mo.web
import
app
from
mo.web.table
import
Table
,
Column
,
cell_place_link
,
cell_user_link
from
mo.web.table
import
Table
,
Column
,
cell_place_link
,
cell_user_link
,
cell_email_link
import
wtforms.validators
as
validators
...
...
@@ -255,20 +255,22 @@ def make_contestant_table(round: db.Round, contest: Optional[db.Contest]) -> Tab
rows
:
List
[
dict
]
=
[]
for
pion
,
pant
,
ct
in
ctants
:
u
=
pion
.
user
rows
.
append
({
'
first_name
'
:
pion
.
user
.
first_name
,
'
last_name
'
:
pion
.
user
.
last_name
,
'
email
'
:
cell_user_link
(
pion
.
user
,
pion
.
user
.
email
),
'
sort_key
'
:
(
locale
.
strxfrm
(
u
.
last_name
),
locale
.
strxfrm
(
u
.
first_name
),
u
.
user_id
),
'
first_name
'
:
cell_user_link
(
u
,
u
.
first_name
),
'
last_name
'
:
cell_user_link
(
u
,
u
.
last_name
),
'
email
'
:
cell_email_link
(
u
),
'
school
'
:
pant
.
school_place
.
name
,
'
school_code
'
:
cell_place_link
(
pant
.
school_place
,
pant
.
school_place
.
get_code
()),
'
grade
'
:
pant
.
grade
,
'
born_year
'
:
pant
.
birth_year
,
'
region_code
'
:
ct
.
place
.
get_code
(),
'
place_code
'
:
pion
.
place
.
get_code
(),
'
region_code
'
:
cell_place_link
(
ct
.
place
,
ct
.
place
.
get_code
()
)
,
'
place_code
'
:
cell_place_link
(
pion
.
place
,
pion
.
place
.
get_code
()
)
,
'
status
'
:
pion
.
state
.
name
,
})
rows
.
sort
(
key
=
lambda
r
:
(
locale
.
strxfrm
(
r
[
'
last_name
'
]),
locale
.
strxfrm
(
r
[
'
first_name
'
])
))
rows
.
sort
(
key
=
lambda
r
:
r
[
'
sort_key
'
])
cols
:
Sequence
[
Column
]
=
contest_list_columns
if
not
contest
:
...
...
This diff is collapsed.
Click to expand it.
mo/web/table.py
+
14
−
4
View file @
13c1e0e5
...
...
@@ -5,6 +5,7 @@ from html import escape
import
io
from
markupsafe
import
Markup
from
typing
import
Sequence
,
Optional
,
Iterable
import
urllib.parse
import
werkzeug.exceptions
import
mo.csv
...
...
@@ -40,13 +41,18 @@ class Cell:
class
CellLink
(
Cell
):
url
:
str
hint
:
Optional
[
str
]
def
__init__
(
self
,
text
:
str
,
url
:
str
):
def
__init__
(
self
,
text
:
str
,
url
:
str
,
hint
:
Optional
[
str
]
=
None
):
Cell
.
__init__
(
self
,
text
)
self
.
url
=
url
self
.
hint
=
hint
def
to_html
(
self
)
->
str
:
return
'
<a href=
"'
+
escape
(
self
.
url
)
+
'"
>
'
+
escape
(
self
.
text
)
+
'
</a>
'
a
=
'
<a href=
"'
+
escape
(
self
.
url
)
+
'"'
if
self
.
hint
:
a
+=
'
title=
"'
+
escape
(
self
.
hint
)
+
'"'
return
a
+
'
>
'
+
escape
(
self
.
text
)
+
'
</a>
'
class
Table
:
...
...
@@ -138,9 +144,13 @@ class Table:
# Pomocné funkce na generování různých typů odkazů
def
cell_email_link
(
user
:
db
.
User
)
->
CellLink
:
return
CellLink
(
user
.
email
,
'
mailto:
'
+
urllib
.
parse
.
quote
(
user
.
email
,
safe
=
'
@
'
))
def
cell_user_link
(
user
:
db
.
User
,
text
:
str
)
->
CellLink
:
return
CellLink
(
text
,
'
/FIXME
'
)
return
CellLink
(
text
,
url_for
(
'
org_user
'
,
id
=
user
.
user_id
)
)
def
cell_place_link
(
place
:
db
.
Place
,
text
:
str
)
->
CellLink
:
return
CellLink
(
text
,
url_for
(
'
org_place
'
,
id
=
place
.
place_id
))
return
CellLink
(
text
,
url_for
(
'
org_place
'
,
id
=
place
.
place_id
)
,
hint
=
place
.
name
)
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