AND %s = ANY(tags) \
ORDER BY published_at DESC LIMIT %s", tag, limit)
- def get_by_author(self, uid, limit=None):
+ def get_by_author(self, author, limit=None):
return self._get_posts("SELECT * FROM blog \
- WHERE author_uid = %s \
+ WHERE (author = %s OR author_uid = %s) \
AND published_at IS NOT NULL \
AND published_at <= NOW() \
- ORDER BY published_at DESC LIMIT %s", uid, limit)
+ ORDER BY published_at DESC LIMIT %s",
+ author.name, author.uid, limit)
def get_by_year(self, year):
return self._get_posts("SELECT * FROM blog \
if self.data.author_uid:
return self.backend.accounts.get_by_uid(self.data.author_uid)
+ return self.data.author
+
@property
def created_at(self):
return self.data.created_at
+{% import ipfire.accounts as accounts %}
+
<div class="blog-post {% if "lightningwirelabs.com" in post.tags %}lightning-wire-labs{% end %}">
<div class="blog-header">
<h5 class="mb-0">
</h5>
<p class="small text-muted">
- {{ _("by") }} <a href="/authors/{{ post.author.uid }}">{{ post.author.name }}</a>,
+ {{ _("by") }}
+
+ {% if isinstance(post.author, accounts.Account) %}
+ <a href="/authors/{{ post.author.uid }}">{{ post.author.name }}</a>
+ {% else %}
+ <strong>{{ post.author }}</strong>
+ {% end %},
+
{{ locale.format_date(post.published_at, shorter=True, relative=False) }}
</p>
</div>
raise tornado.web.HTTPError(404, "User is unknown")
# Get all posts from this author
- posts = self.backend.blog.get_by_author(author.uid)
+ posts = self.backend.blog.get_by_author(author)
if not posts:
raise tornado.web.HTTPError(404, "User has no posts")