mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2025-01-02 13:28:43 +00:00
Merge pull request #186 from loganmhb/author-display-name
Add Author.display_name to decide which name to display
This commit is contained in:
commit
564d9627bc
4 changed files with 15 additions and 4 deletions
|
@ -184,3 +184,14 @@ class Author(FedireadsModel):
|
||||||
@property
|
@property
|
||||||
def activitypub_serialize(self):
|
def activitypub_serialize(self):
|
||||||
return activitypub.get_author(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
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
{% load fr_display %}
|
{% load fr_display %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="content-container">
|
<div class="content-container">
|
||||||
<h2>{{ author.name }}</h2>
|
<h2>{{ author.display_name }}</h2>
|
||||||
|
|
||||||
{% if author.bio %}
|
{% if author.bio %}
|
||||||
<p>
|
<p>
|
||||||
|
@ -12,7 +12,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="content-container">
|
<div class="content-container">
|
||||||
<h2>Books by {{ author.name }}</h2>
|
<h2>Books by {{ author.display_name }}</h2>
|
||||||
<div class="book-grid row shrink wrap">
|
<div class="book-grid row shrink wrap">
|
||||||
{% for book in books %}
|
{% for book in books %}
|
||||||
<div class="book-preview">
|
<div class="book-preview">
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
<a href="/author/{{ book.authors.first.id }}" class="author">{{ book.authors.first.name }}</a>
|
<a href="/author/{{ book.authors.first.id }}" class="author">{{ book.authors.first.display_name }}</a>
|
||||||
|
|
|
@ -42,7 +42,7 @@
|
||||||
<a href="/book/{{ book.id }}">{{ book.title }}</a>
|
<a href="/book/{{ book.id }}">{{ book.title }}</a>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{{ book.authors.first.name }}
|
{{ book.authors.first.display_name }}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{% if book.first_published_date %}{{ book.first_published_date }}{% endif %}
|
{% if book.first_published_date %}{{ book.first_published_date }}{% endif %}
|
||||||
|
|
Loading…
Reference in a new issue