Improve wrapping of content metadata for topics

This commit is contained in:
Deimos
2020-02-10 18:43:48 -07:00
parent 4371f9cef6
commit 97e8d756df
2 changed files with 9 additions and 7 deletions

View File

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

View File

@@ -49,9 +49,11 @@
<span class="topic-content-type">{{ topic.content_type_for_display }}</span>
{% if topic.content_metadata_for_display %}
<span class="topic-content-metadata">{{ topic.content_metadata_for_display }}</span>
{% endif %}
{% for metadata in topic.content_metadata_for_display %}
<span class="topic-content-metadata">
{{ metadata }}{{ ",&nbsp;"|safe if not loop.last }}
</span>
{% endfor %}
{% if topic.unimportant_tags and request.user and request.user.show_tags_in_listings %}
<ul class="topic-tags">