Skip to content

Commit

Permalink
use edition cover if mising work cover
Browse files Browse the repository at this point in the history
  • Loading branch information
Your Name authored and alphatownsman committed Jul 27, 2024
1 parent fc193ed commit 9763192
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions catalog/book/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,14 @@ def delete(self, using=None, keep_parents=False, soft=True, *args, **kwargs):
self.editions.clear()
return super().delete(using, keep_parents, soft, *args, **kwargs)

@property
def cover_image_url(self):
url = super().cover_image_url
if url:
return url
e = next(filter(lambda e: e.cover_image_url, self.editions.all()), None)
return e.cover_image_url if e else None

def update_linked_items_from_external_resource(self, resource):
"""add Edition from resource.metadata['required_resources'] if not yet"""
links = resource.required_resources + resource.related_resources
Expand Down

0 comments on commit 9763192

Please sign in to comment.