diff --git a/mo/web/org_score.py b/mo/web/org_score.py index 1e5c0681e246d20b3ad157d5c01778f93a0c0957..fe5d112d042e20e0502b82c25363c770ebb5f834 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 95995dc2d25990aa44e1e750f123f53ee1ae9810..f95571a34282f974d6f807535a59c97e55b69e9f 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]