1
0
Fork 0
mirror of https://codeberg.org/Mo8it/AdvLabDB.git synced 2024-09-17 18:31:15 +00:00

Deal with lists in str_formatters

This commit is contained in:
Mo 2022-07-01 18:49:29 +02:00
parent 0e8a3ca0cd
commit 966d51f94c

View file

@ -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):