From 7ffc3114a6f4fcf3ef08de2df2911ed610dd5d6d Mon Sep 17 00:00:00 2001 From: Joel Bradshaw Date: Mon, 16 Nov 2020 22:47:55 -0800 Subject: [PATCH] Add display and form for existing pages_read Commented out the new update type because it was breaking and I don't need it quite yet --- bookwyrm/models/status.py | 58 ++++++++++++++++++------------------ bookwyrm/templates/book.html | 9 ++++++ bookwyrm/view_actions.py | 8 +++++ 3 files changed, 46 insertions(+), 29 deletions(-) diff --git a/bookwyrm/models/status.py b/bookwyrm/models/status.py index c56fa395..91906b13 100644 --- a/bookwyrm/models/status.py +++ b/bookwyrm/models/status.py @@ -201,35 +201,35 @@ class Quotation(Status): activity_serializer = activitypub.Quotation pure_activity_serializer = activitypub.Note -class Progress(Status): - ''' an update of where a user is in a book, using page number or % ''' - class ProgressMode(models.TextChoices): - PAGE = 'PG', 'page' - PERCENT = 'PCT', 'percent' - - progress = models.IntegerField() - mode = models.TextChoices(max_length=3, choices=ProgessMode.choices, default=ProgressMode.PAGE) - book = models.ForeignKey('Edition', on_delete=models.PROTECT) - - @property - def ap_pure_content(self): - ''' indicate the book in question for mastodon (or w/e) users ''' - if self.mode == ProgressMode.PAGE: - return 'on page %d of %d in "%s"' % ( - self.progress, - self.book.pages, - self.book.remote_id, - self.book.title, - ) - else: - return '%d%% of the way through "%s"' % ( - self.progress, - self.book.remote_id, - self.book.title, - ) - - activity_serializer = activitypub.Progress - pure_activity_serializer = activitypub.Note +#class Progress(Status): +# ''' an update of where a user is in a book, using page number or % ''' +# class ProgressMode(models.TextChoices): +# PAGE = 'PG', 'page' +# PERCENT = 'PCT', 'percent' +# +# progress = models.IntegerField() +# mode = models.TextChoices(max_length=3, choices=ProgessMode.choices, default=ProgressMode.PAGE) +# book = models.ForeignKey('Edition', on_delete=models.PROTECT) +# +# @property +# def ap_pure_content(self): +# ''' indicate the book in question for mastodon (or w/e) users ''' +# if self.mode == ProgressMode.PAGE: +# return 'on page %d of %d in "%s"' % ( +# self.progress, +# self.book.pages, +# self.book.remote_id, +# self.book.title, +# ) +# else: +# return '%d%% of the way through "%s"' % ( +# self.progress, +# self.book.remote_id, +# self.book.title, +# ) +# +# activity_serializer = activitypub.Progress +# pure_activity_serializer = activitypub.Note class Review(Status): ''' a book review ''' diff --git a/bookwyrm/templates/book.html b/bookwyrm/templates/book.html index b0064e1f..db386442 100644 --- a/bookwyrm/templates/book.html +++ b/bookwyrm/templates/book.html @@ -74,6 +74,9 @@ {% if readthrough.finish_date %}
Finished reading:
{{ readthrough.finish_date | naturalday }}
+ {% elif readthrough.pages_read %} +
On page:
+
{{ readthrough.pages_read}} of {{ book.pages }}
{% endif %}
@@ -104,6 +107,12 @@
+
+ +