mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-12-27 02:20:31 +00:00
pure_content()
refactor: shorter conditionals
This commit is contained in:
parent
a09b2ab45c
commit
25fd7276ea
1 changed files with 11 additions and 21 deletions
|
@ -320,17 +320,14 @@ class Comment(BookStatus):
|
|||
@property
|
||||
def pure_content(self):
|
||||
"""indicate the book in question for mastodon (or w/e) users"""
|
||||
if self.progress_mode == "PG" and self.progress and (self.progress > 0):
|
||||
return_value = (
|
||||
f'{self.content}<p>(comment on <a href="{self.book.remote_id}">'
|
||||
f'"{self.book.title}"</a>, page {self.progress})</p>'
|
||||
)
|
||||
else:
|
||||
return_value = (
|
||||
f'{self.content}<p>(comment on <a href="{self.book.remote_id}">'
|
||||
f'"{self.book.title}"</a>)</p>'
|
||||
)
|
||||
return return_value
|
||||
progress = self.progress or 0
|
||||
citation = (
|
||||
f'comment on <a href="{self.book.remote_id}">'
|
||||
f'"{self.book.title}"</a>'
|
||||
)
|
||||
if self.progress_mode == "PG" and progress > 0:
|
||||
citation += f", page {progress}"
|
||||
return f"{self.content}<p>({citation})</p>"
|
||||
|
||||
activity_serializer = activitypub.Comment
|
||||
|
||||
|
@ -359,17 +356,10 @@ class Quotation(BookStatus):
|
|||
"""indicate the book in question for mastodon (or w/e) users"""
|
||||
quote = re.sub(r"^<p>", '<p>"', self.quote)
|
||||
quote = re.sub(r"</p>$", '"</p>', quote)
|
||||
citation = f'-- <a href="{self.book.remote_id}">"{self.book.title}"</a>'
|
||||
if self.position_mode == "PG" and self.position and (self.position > 0):
|
||||
return_value = (
|
||||
f'{quote} <p>-- <a href="{self.book.remote_id}">'
|
||||
f'"{self.book.title}"</a>, page {self.position}</p>{self.content}'
|
||||
)
|
||||
else:
|
||||
return_value = (
|
||||
f'{quote} <p>-- <a href="{self.book.remote_id}">'
|
||||
f'"{self.book.title}"</a></p>{self.content}'
|
||||
)
|
||||
return return_value
|
||||
citation += f", page {self.position}"
|
||||
return f"{quote} <p>{citation}</p>{self.content}"
|
||||
|
||||
activity_serializer = activitypub.Quotation
|
||||
|
||||
|
|
Loading…
Reference in a new issue