Skip to content
Snippets Groups Projects

Označení neaktivovaných účtů -- vytvoření user_html_flags

Merged Jiří Kalvoda requested to merge jk/issue-196-v2 into devel
+ 22
2
@@ -11,6 +11,7 @@ import werkzeug.exceptions
from mo.csv import FileFormat
import mo.db as db
from mo.web import app
from mo.web.util import user_html_flags
@dataclass
@@ -55,17 +56,19 @@ class Row:
class CellLink(Cell):
url: str
hint: Optional[str]
html_suffix: Markup
def __init__(self, text: str, url: str, hint: Optional[str] = None):
def __init__(self, text: str, url: str, hint: Optional[str] = None, html_suffix: Markup = Markup("")):
Cell.__init__(self, text)
self.url = url
self.hint = hint
self.html_suffix = html_suffix
def to_html(self) -> str:
a = '<td><a href="' + escape(self.url) + '"'
if self.hint:
a += ' title="' + escape(self.hint) + '"'
return a + '>' + escape(self.text) + '</a>'
return a + '>' + escape(self.text) + '</a>' + str(self.html_suffix)
class CellCheckbox(Cell):
@@ -85,6 +88,20 @@ class CellCheckbox(Cell):
ch += ' checked'
return ch + '>'
class CellMarkup(Cell):
text: str
html: str
def __init__(self, text: str, html: Union[str, Markup]):
self.text = text
self.html = str(html)
def __str__(self) -> str:
return self.text
def to_html(self) -> str:
return self.html
class Table:
columns: Sequence[Column]
@@ -184,6 +201,9 @@ class Table:
def cell_email_link(user: db.User) -> CellLink:
return CellLink(user.email, 'mailto:' + urllib.parse.quote(user.email, safe='@'))
def cell_email_link_flags(user: db.User) -> CellLink:
return CellLink(user.email, 'mailto:' + urllib.parse.quote(user.email, safe='@'), html_suffix=user_html_flags(user))
def cell_user_link(user: db.User, text: str) -> CellLink:
return CellLink(text, url_for('org_user', id=user.user_id))
Loading