mirror of
https://codeberg.org/Mo8it/AdvLabDB.git
synced 2025-04-10 20:48:36 +00:00
Deal with lists in str_formatters
This commit is contained in:
parent
0e8a3ca0cd
commit
966d51f94c
1 changed files with 16 additions and 6 deletions
|
@ -37,18 +37,28 @@ def missing_formatter(view, context, model, name):
|
|||
|
||||
def str_without_semester_formatter(view, context, model, name):
|
||||
attr = deep_getattr(model, name)
|
||||
if attr is not None:
|
||||
return attr.str_without_semester()
|
||||
|
||||
return attr
|
||||
if attr is None:
|
||||
return ""
|
||||
|
||||
if hasattr(attr, "__iter__") and not isinstance(attr, str):
|
||||
# List of attributes
|
||||
return ", ".join([a.str_without_semester() for a in attr])
|
||||
|
||||
return attr.str_without_semester()
|
||||
|
||||
|
||||
def str_formatter(view, context, model, name):
|
||||
attr = deep_getattr(model, name)
|
||||
if attr is not None:
|
||||
return attr.str()
|
||||
|
||||
return attr
|
||||
if attr is None:
|
||||
return ""
|
||||
|
||||
if hasattr(attr, "__iter__") and not isinstance(attr, str):
|
||||
# List of attributes
|
||||
return ", ".join([a.str() for a in attr])
|
||||
|
||||
return attr.str()
|
||||
|
||||
|
||||
def _details_link(url, attr, attr_formatter):
|
||||
|
|
Loading…
Add table
Reference in a new issue