From 2a417179f938fea282b11409e7defba3e8fa84b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Setni=C4=8Dka?= <setnicka@seznam.cz> Date: Sat, 4 Dec 2021 20:49:59 +0100 Subject: [PATCH] =?UTF-8?q?Score:=20P=C5=99esun=20OrderCell=20do=20mo.web.?= =?UTF-8?q?table?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bude použita i z účastnické části webu. --- mo/web/org_score.py | 27 +-------------------------- mo/web/table.py | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/mo/web/org_score.py b/mo/web/org_score.py index 1e5c0681..fe5d112d 100644 --- a/mo/web/org_score.py +++ b/mo/web/org_score.py @@ -12,35 +12,10 @@ from mo.rights import Right from mo.score import Score from mo.web import app from mo.web.org_contest import get_context -from mo.web.table import Cell, CellInput, CellLink, Column, Row, Table, cell_pion_link +from mo.web.table import Cell, CellInput, CellLink, Column, Row, Table, OrderCell, cell_pion_link from mo.util_format import format_decimal, inflect_number -class OrderCell(Cell): - place: int - span: int - continuation: bool - - def __init__(self, place: int, span: int = 1, continuation: bool = False): - self.place = place - self.span = span - self.continuation = continuation - - def __str__(self) -> str: - if self.span == 1: - return f"{self.place}." - else: - return f"{self.place}.–{self.place + self.span - 1}." - - def to_html(self) -> str: - if self.continuation: - return "" # covered by rowspan cell above this one - elif self.span == 1: - return f"<td>{self.__str__()}" - else: - return f"<td rowspan='{self.span}'>{self.__str__()}" - - class SolPointsCell(Cell): contest_id: int user: db.User diff --git a/mo/web/table.py b/mo/web/table.py index 95995dc2..f95571a3 100644 --- a/mo/web/table.py +++ b/mo/web/table.py @@ -116,6 +116,31 @@ class CellMarkup(Cell): return self.html +class OrderCell(Cell): + place: int + span: int + continuation: bool + + def __init__(self, place: int, span: int = 1, continuation: bool = False): + self.place = place + self.span = span + self.continuation = continuation + + def __str__(self) -> str: + if self.span == 1: + return f"{self.place}." + else: + return f"{self.place}.–{self.place + self.span - 1}." + + def to_html(self) -> str: + if self.continuation: + return "" # covered by rowspan cell above this one + elif self.span == 1: + return f"<td>{self.__str__()}" + else: + return f"<td rowspan='{self.span}'>{self.__str__()}" + + class Table: columns: Sequence[Column] rows: Iterable[Row] -- GitLab