From 97e8d756df401228e3618300775f86cf692853d2 Mon Sep 17 00:00:00 2001 From: Deimos Date: Mon, 10 Feb 2020 18:43:48 -0700 Subject: [PATCH] Improve wrapping of content metadata for topics --- tildes/tildes/models/topic/topic.py | 8 ++++---- tildes/tildes/templates/macros/topics.jinja2 | 8 +++++--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/tildes/tildes/models/topic/topic.py b/tildes/tildes/models/topic/topic.py index 8864123..91c41e6 100644 --- a/tildes/tildes/models/topic/topic.py +++ b/tildes/tildes/models/topic/topic.py @@ -505,10 +505,10 @@ class Topic(DatabaseModel): return self.content_metadata.get(key) @property - def content_metadata_for_display(self) -> str: - """Return a string of the content's metadata, suitable for display.""" + def content_metadata_for_display(self) -> List[str]: + """Return a list of the content's metadata strings, suitable for display.""" if not self.content_type: - return "" + return [] metadata_strings = [] @@ -532,7 +532,7 @@ class Topic(DatabaseModel): metadata_strings.append(formatted_value) - return ", ".join(metadata_strings) + return metadata_strings @property def content_metadata_fields_for_display(self) -> Dict[str, str]: diff --git a/tildes/tildes/templates/macros/topics.jinja2 b/tildes/tildes/templates/macros/topics.jinja2 index 71e3086..e6a8150 100644 --- a/tildes/tildes/templates/macros/topics.jinja2 +++ b/tildes/tildes/templates/macros/topics.jinja2 @@ -49,9 +49,11 @@ {{ topic.content_type_for_display }} - {% if topic.content_metadata_for_display %} - {{ topic.content_metadata_for_display }} - {% endif %} + {% for metadata in topic.content_metadata_for_display %} + + {{ metadata }}{{ ", "|safe if not loop.last }} + + {% endfor %} {% if topic.unimportant_tags and request.user and request.user.show_tags_in_listings %}