From 263eb1bba07bdf3f18033b1c3a691463a11020b3 Mon Sep 17 00:00:00 2001 From: Deimos Date: Fri, 8 Mar 2019 15:46:02 -0700 Subject: [PATCH] Topic: add property to decide if user is "source" This isn't meaningful yet, but we'll attach more logic shortly. --- tildes/tildes/models/topic/topic.py | 5 +++++ tildes/tildes/templates/macros/topics.jinja2 | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/tildes/tildes/models/topic/topic.py b/tildes/tildes/models/topic/topic.py index cec0870..2ba8154 100644 --- a/tildes/tildes/models/topic/topic.py +++ b/tildes/tildes/models/topic/topic.py @@ -448,3 +448,8 @@ class Topic(DatabaseModel): return f"@{authors[0]}:
{tweet}
" return None + + @property + def is_user_treated_as_source(self) -> bool: + """Return whether the user that posted the topic is its "source".""" + return self.is_text_type diff --git a/tildes/tildes/templates/macros/topics.jinja2 b/tildes/tildes/templates/macros/topics.jinja2 index 1e7f580..035f7f9 100644 --- a/tildes/tildes/templates/macros/topics.jinja2 +++ b/tildes/tildes/templates/macros/topics.jinja2 @@ -79,9 +79,9 @@ - {% if topic.is_text_type %} + {% if topic.is_user_treated_as_source %}
{{ username_linked(topic.user.username) }}
- {% elif topic.is_link_type %} + {% else %}
{{ topic.link_domain }}
{% endif %}