Skip to content
Snippets Groups Projects
Commit 1cea1f08 authored by Jiří Setnička's avatar Jiří Setnička
Browse files

Table: Tabulky mají id

parent fb3d7886
No related branches found
No related tags found
1 merge request!115Výběr sloupečků v exportech
This commit is part of merge request !115. Comments created here will be created in the context of that merge request.
......@@ -215,5 +215,10 @@ def org_export_schools():
'kraj_code': k.get_code(),
})
table = Table(school_export_columns, gen_rows(), 'skoly')
table = Table(
id="skoly",
columns=school_export_columns,
rows=gen_rows(),
filename='skoly',
)
return table.send_as(format, streaming=True)
......@@ -647,6 +647,7 @@ def make_contestant_table(query: Query, round: db.Round, add_checkbox: bool = Fa
cols.append(Column(key='user_id', name='user_id'))
return Table(
id="ucastnici",
columns=cols,
rows=rows,
filename='ucastnici',
......
......
......@@ -228,6 +228,7 @@ def org_score(round_id: Optional[int] = None, hier_id: Optional[int] = None, ct_
if contest:
filename += f"_oblast_{contest.place.code or contest.place.place_id}"
table = Table(
id="vysledky",
table_class="data full center",
columns=columns,
rows=table_rows,
......@@ -406,6 +407,7 @@ def org_score_snapshot(ct_id: int, scoretable_id: int):
filename = f"vysledky_{ctx.round.year}-{ctx.round.category}-{ctx.round.level}_oblast_{ctx.contest.place.code or ctx.contest.place.place_id}"
table = Table(
id="vysledky",
table_class="data full center",
columns=columns,
rows=table_rows,
......
......
......@@ -142,6 +142,7 @@ class OrderCell(Cell):
class Table:
id: str # validní jako HTML id a unikátní pro tabulky zobrazené na stejné stránce
columns: Sequence[Column]
rows: Iterable[Row]
filename: str
......@@ -149,10 +150,11 @@ class Table:
table_class: str
def __init__(
self, columns: Sequence[Column], rows: Iterable[Row],
self, id: str, columns: Sequence[Column], rows: Iterable[Row],
filename: str, show_downlink: bool = True,
table_class: str = "data"
):
self.id = id
self.columns = columns
self.rows = rows
self.filename = filename
......@@ -160,7 +162,7 @@ class Table:
self.table_class = table_class
def to_html(self) -> str:
tab = [f'<table class="{self.table_class}">', '<thead>', '<tr>']
tab = [f'<table class="{self.table_class}" id="{self.id}">', '<thead>', '<tr>']
for c in self.columns:
tab.append(f'\t<th>{c.title}')
......
......
......@@ -549,6 +549,7 @@ def user_contest_score(id: int):
filename = f"vysledky_{round.year}-{round.category}-{round.level}_oblast_{contest.place.code or contest.place.place_id}"
table = Table(
id="vysledky",
table_class="data full center",
columns=columns,
rows=table_rows,
......
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment