mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-06-13 10:49:23 +00:00
Add Status.page_image property
This commit is contained in:
parent
f7b4d9ea50
commit
ad56024ffe
|
@ -190,6 +190,15 @@ class Status(OrderedCollectionPageMixin, BookWyrmModel):
|
||||||
"""description of the page in meta tags when only this status is shown"""
|
"""description of the page in meta tags when only this status is shown"""
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@property
|
||||||
|
def page_image(self):
|
||||||
|
"""image to use as preview in meta tags when only this status is shown"""
|
||||||
|
if self.mention_books.exists():
|
||||||
|
book = self.mention_books.first()
|
||||||
|
return book.preview_image
|
||||||
|
else:
|
||||||
|
return self.user.preview_image
|
||||||
|
|
||||||
def to_replies(self, **kwargs):
|
def to_replies(self, **kwargs):
|
||||||
"""helper function for loading AP serialized replies to a status"""
|
"""helper function for loading AP serialized replies to a status"""
|
||||||
return self.to_ordered_collection(
|
return self.to_ordered_collection(
|
||||||
|
@ -313,6 +322,10 @@ class BookStatus(Status):
|
||||||
|
|
||||||
abstract = True
|
abstract = True
|
||||||
|
|
||||||
|
@property
|
||||||
|
def page_image(self):
|
||||||
|
return self.book.preview_image or super().page_image
|
||||||
|
|
||||||
|
|
||||||
class Comment(BookStatus):
|
class Comment(BookStatus):
|
||||||
"""like a review but without a rating and transient"""
|
"""like a review but without a rating and transient"""
|
||||||
|
|
Loading…
Reference in a new issue