Generate author_text field dynamically

This commit is contained in:
Mouse Reeve
2020-12-21 11:57:45 -08:00
parent 7081c0bb00
commit aac264c998
4 changed files with 32 additions and 7 deletions

View File

@ -51,7 +51,6 @@ class Book(ActivitypubMixin, BookWyrmModel):
# TODO: include an annotation about the type of authorship (ie, translator)
authors = fields.ManyToManyField('Author')
# preformatted authorship string for search and easier display
author_text = models.CharField(max_length=255, blank=True, null=True)
cover = fields.ImageField(
upload_to='covers/', blank=True, null=True, alt_field='alt_text')
first_published_date = fields.DateTimeField(blank=True, null=True)
@ -59,6 +58,11 @@ class Book(ActivitypubMixin, BookWyrmModel):
objects = InheritanceManager()
@property
def author_text(self):
''' format a list of authors '''
return ', '.join(a.name for a in self.authors.all())
@property
def edition_info(self):
''' properties of this edition, as a string '''