handle unset default editions
This commit is contained in:
parent
72c7829bab
commit
dfd730757d
4 changed files with 32 additions and 2 deletions
|
@ -86,6 +86,7 @@ class Book(ActivitypubMixin, BookWyrmModel):
|
|||
|
||||
ActivityMapping('lccn', 'lccn'),
|
||||
ActivityMapping('editions', 'editions'),
|
||||
ActivityMapping('defaultEdition', 'default_edition'),
|
||||
ActivityMapping('cover', 'cover'),
|
||||
]
|
||||
|
||||
|
@ -125,6 +126,10 @@ class Work(OrderedCollectionPageMixin, Book):
|
|||
null=True
|
||||
)
|
||||
|
||||
def get_default_edition(self):
|
||||
''' in case the default edition is not set '''
|
||||
return self.default_edition or self.editions.first()
|
||||
|
||||
activity_serializer = activitypub.Work
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue