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

Score: Přesun OrderCell do mo.web.table

Bude použita i z účastnické části webu.
parent daf7ab1f
Branches
No related tags found
1 merge request!110Zveřejňování výsledkovky účastníkům
...@@ -12,35 +12,10 @@ from mo.rights import Right ...@@ -12,35 +12,10 @@ from mo.rights import Right
from mo.score import Score from mo.score import Score
from mo.web import app from mo.web import app
from mo.web.org_contest import get_context 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 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): class SolPointsCell(Cell):
contest_id: int contest_id: int
user: db.User user: db.User
......
...@@ -116,6 +116,31 @@ class CellMarkup(Cell): ...@@ -116,6 +116,31 @@ class CellMarkup(Cell):
return self.html 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: class Table:
columns: Sequence[Column] columns: Sequence[Column]
rows: Iterable[Row] rows: Iterable[Row]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment