diff --git a/fedireads/models/book.py b/fedireads/models/book.py index ca1985845..a68777398 100644 --- a/fedireads/models/book.py +++ b/fedireads/models/book.py @@ -184,3 +184,14 @@ class Author(FedireadsModel): @property def activitypub_serialize(self): return activitypub.get_author(self) + + @property + def display_name(self): + ''' Helper to return a displayable name''' + if self.name: + return name + # don't want to return a spurious space if all of these are None + elif self.first_name and self.last_name: + return self.first_name + ' ' + self.last_name + else: + return self.last_name or self.first_name diff --git a/fedireads/templates/author.html b/fedireads/templates/author.html index f9da61d07..39148909a 100644 --- a/fedireads/templates/author.html +++ b/fedireads/templates/author.html @@ -2,7 +2,7 @@ {% load fr_display %} {% block content %}
-

{{ author.name }}

+

{{ author.display_name }}

{% if author.bio %}

@@ -12,7 +12,7 @@

-

Books by {{ author.name }}

+

Books by {{ author.display_name }}

{% for book in books %}
diff --git a/fedireads/templates/snippets/authors.html b/fedireads/templates/snippets/authors.html index e8106f5d6..165c4cdaa 100644 --- a/fedireads/templates/snippets/authors.html +++ b/fedireads/templates/snippets/authors.html @@ -1 +1 @@ -{{ book.authors.first.name }} +{{ book.authors.first.display_name }} diff --git a/fedireads/templates/snippets/shelf.html b/fedireads/templates/snippets/shelf.html index 990e11bc1..7f0942329 100644 --- a/fedireads/templates/snippets/shelf.html +++ b/fedireads/templates/snippets/shelf.html @@ -42,7 +42,7 @@ {{ book.title }} - {{ book.authors.first.name }} + {{ book.authors.first.display_name }} {% if book.first_published_date %}{{ book.first_published_date }}{% endif %}