mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-28 04:21:07 +00:00
Use name field only for author name
It feels janky to remove a more granular name designation, but all these first/last name fields were algorithmically populated by a dubious process of splitting the name by a space character. If it makes sense to have first/last name fields, it should be re-added with some consideration.
This commit is contained in:
parent
5cf9e24ae5
commit
31a407d74a
7 changed files with 35 additions and 20 deletions
|
@ -178,8 +178,7 @@ class AbstractConnector(AbstractMinimalConnector):
|
|||
author_text = []
|
||||
for author in self.get_authors_from_data(data):
|
||||
book.authors.add(author)
|
||||
if author.display_name:
|
||||
author_text.append(author.display_name)
|
||||
author_text.append(author.name)
|
||||
book.author_text = ', '.join(author_text)
|
||||
book.save()
|
||||
|
||||
|
|
30
bookwyrm/migrations/0022_auto_20201212_1744.py
Normal file
30
bookwyrm/migrations/0022_auto_20201212_1744.py
Normal file
|
@ -0,0 +1,30 @@
|
|||
# Generated by Django 3.0.7 on 2020-12-12 17:44
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
def set_author_name(app_registry, schema_editor):
|
||||
db_alias = schema_editor.connection.alias
|
||||
authors = app_registry.get_model('bookwyrm', 'Author')
|
||||
for author in authors.objects.using(db_alias):
|
||||
if not author.name:
|
||||
author.name = '%s %s' % (author.first_name, author.last_name)
|
||||
author.save()
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('bookwyrm', '0021_merge_20201212_1737'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(set_author_name),
|
||||
migrations.RemoveField(
|
||||
model_name='author',
|
||||
name='first_name',
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='author',
|
||||
name='last_name',
|
||||
),
|
||||
]
|
|
@ -21,8 +21,6 @@ class Author(ActivitypubMixin, BookWyrmModel):
|
|||
born = fields.DateTimeField(blank=True, null=True)
|
||||
died = fields.DateTimeField(blank=True, null=True)
|
||||
name = fields.CharField(max_length=255)
|
||||
last_name = models.CharField(max_length=255, blank=True, null=True)
|
||||
first_name = models.CharField(max_length=255, blank=True, null=True)
|
||||
aliases = fields.ArrayField(
|
||||
models.CharField(max_length=255), blank=True, default=list
|
||||
)
|
||||
|
@ -42,14 +40,4 @@ class Author(ActivitypubMixin, BookWyrmModel):
|
|||
''' editions and works both use "book" instead of model_name '''
|
||||
return 'https://%s/author/%s' % (DOMAIN, self.id)
|
||||
|
||||
@property
|
||||
def display_name(self):
|
||||
''' Helper to return a displayable name'''
|
||||
if self.name:
|
||||
return self.name
|
||||
# don't want to return a spurious space if all of these are None
|
||||
if self.first_name and self.last_name:
|
||||
return self.first_name + ' ' + self.last_name
|
||||
return self.last_name or self.first_name
|
||||
|
||||
activity_serializer = activitypub.Author
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
{% load fr_display %}
|
||||
{% block content %}
|
||||
<div class="block">
|
||||
<h1 class="title">{{ author.display_name }}</h1>
|
||||
<h1 class="title">{{ author.name }}</h1>
|
||||
|
||||
{% if author.bio %}
|
||||
<p>
|
||||
|
@ -12,7 +12,7 @@
|
|||
</div>
|
||||
|
||||
<div class="block">
|
||||
<h3 class="title is-4">Books by {{ author.display_name }}</h3>
|
||||
<h3 class="title is-4">Books by {{ author.name }}</h3>
|
||||
{% include 'snippets/book_tiles.html' with books=books %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
|
|
@ -1 +1 @@
|
|||
<a href="/author/{{ book.authors.first.id }}" class="author">{{ book.authors.first.display_name }}</a>
|
||||
<a href="/author/{{ book.authors.first.id }}" class="author">{{ book.authors.first.name }}</a>
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
<a href="/book/{{ book.id }}">{{ book.title }}</a>
|
||||
</td>
|
||||
<td>
|
||||
{{ book.authors.first.display_name }}
|
||||
{{ book.authors.first.name }}
|
||||
</td>
|
||||
<td>
|
||||
{% if book.first_published_date %}{{ book.first_published_date }}{% endif %}
|
||||
|
|
|
@ -12,8 +12,6 @@ class Author(TestCase):
|
|||
)
|
||||
self.author = models.Author.objects.create(
|
||||
name='Author fullname',
|
||||
first_name='Auth',
|
||||
last_name='Or',
|
||||
aliases=['One', 'Two'],
|
||||
bio='bio bio bio',
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue