Improved reporting on failed href building.
This commit is contained in:
parent
de5e5b4a43
commit
eef7428c2f
2 changed files with 5 additions and 5 deletions
|
|
@ -82,10 +82,12 @@ def _build_href(spec: Dict[str, Any], row: Dict[str, Any], obj) -> Optional[str]
|
||||||
else:
|
else:
|
||||||
params[k] = v
|
params[k] = v
|
||||||
if any(v is None for v in params.values()):
|
if any(v is None for v in params.values()):
|
||||||
|
print(f"[render_table] url_for failed: endpoint={spec}: params={params}")
|
||||||
return None
|
return None
|
||||||
try:
|
try:
|
||||||
return url_for(spec["endpoint"], **params)
|
return url_for(spec["endpoint"], **params)
|
||||||
except Exception:
|
except Exception as e:
|
||||||
|
print(f"[render_table] url_for failed: endpoint={spec['endpoint']} params={params} err={e}")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def _humanize(field: str) -> str:
|
def _humanize(field: str) -> str:
|
||||||
|
|
@ -144,8 +146,6 @@ def render_table(objects: List[Any], columns: Optional[List[Dict[str, Any]]] = N
|
||||||
cells.append({"text": text, "href": href, "class": cls})
|
cells.append({"text": text, "href": href, "class": cls})
|
||||||
disp_rows.append({"id": rd.get("id"), "cells": cells})
|
disp_rows.append({"id": rd.get("id"), "cells": cells})
|
||||||
|
|
||||||
print(disp_rows)
|
|
||||||
|
|
||||||
return template.render(columns=cols, rows=disp_rows)
|
return template.render(columns=cols, rows=disp_rows)
|
||||||
|
|
||||||
def render_form(model_cls, values, session=None):
|
def render_form(model_cls, values, session=None):
|
||||||
|
|
|
||||||
|
|
@ -30,9 +30,9 @@ def init_index_routes(app):
|
||||||
columns = [
|
columns = [
|
||||||
{"field": "start_time", "label": "Start", "format": "date"},
|
{"field": "start_time", "label": "Start", "format": "date"},
|
||||||
{"field": "contact.last_name", "label": "Contact",
|
{"field": "contact.last_name", "label": "Contact",
|
||||||
"link": {"endpoint": "contact.entry", "params": {"id": "{contact.id}"}}},
|
"link": {"endpoint": "user.get_item", "params": {"id": "{contact.id}"}}},
|
||||||
{"field": "work_item.name", "label": "Work Item",
|
{"field": "work_item.name", "label": "Work Item",
|
||||||
"link": {"endpoint": "work_item.entry", "params": {"id": "{work_item.id}"}}},
|
"link": {"endpoint": "inventory.get_item", "params": {"id": "{work_item.id}"}}},
|
||||||
{"field": "complete", "label": "Status",
|
{"field": "complete", "label": "Status",
|
||||||
"format": "yesno", "classes": {"true":"badge bg-success","false":"badge bg-warning","none":"text-muted"}},
|
"format": "yesno", "classes": {"true":"badge bg-success","false":"badge bg-warning","none":"text-muted"}},
|
||||||
]
|
]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue