mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-26 11:31:08 +00:00
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
This commit is contained in:
parent
3beebe4727
commit
7ffc3114a6
3 changed files with 46 additions and 29 deletions
|
@ -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 <a href="%s">"%s"</a>' % (
|
||||
self.progress,
|
||||
self.book.pages,
|
||||
self.book.remote_id,
|
||||
self.book.title,
|
||||
)
|
||||
else:
|
||||
return '%d%% of the way through <a href="%s">"%s"</a>' % (
|
||||
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 <a href="%s">"%s"</a>' % (
|
||||
# self.progress,
|
||||
# self.book.pages,
|
||||
# self.book.remote_id,
|
||||
# self.book.title,
|
||||
# )
|
||||
# else:
|
||||
# return '%d%% of the way through <a href="%s">"%s"</a>' % (
|
||||
# self.progress,
|
||||
# self.book.remote_id,
|
||||
# self.book.title,
|
||||
# )
|
||||
#
|
||||
# activity_serializer = activitypub.Progress
|
||||
# pure_activity_serializer = activitypub.Note
|
||||
|
||||
class Review(Status):
|
||||
''' a book review '''
|
||||
|
|
|
@ -74,6 +74,9 @@
|
|||
{% if readthrough.finish_date %}
|
||||
<dt>Finished reading:</dt>
|
||||
<dd>{{ readthrough.finish_date | naturalday }}</dd>
|
||||
{% elif readthrough.pages_read %}
|
||||
<dt>On page:</dt>
|
||||
<dd>{{ readthrough.pages_read}} of {{ book.pages }}</dd>
|
||||
{% endif %}
|
||||
</dl>
|
||||
<div class="field is-grouped">
|
||||
|
@ -104,6 +107,12 @@
|
|||
<input type="date" name="start_date" class="input" id="id_start_date-{{ readthrough.id }}" value="{{ readthrough.start_date | date:"Y-m-d" }}">
|
||||
</label>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label class="label">
|
||||
On page
|
||||
<input type="number" name="pages_read" class="input" id="id_pages_read-{{ readthrough.id }}" value="{{ readthrough.pages_read }}">
|
||||
</label>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label class="label">
|
||||
Finished reading
|
||||
|
|
|
@ -729,4 +729,12 @@ def update_readthrough(request, book=None, create=True):
|
|||
except ParserError:
|
||||
pass
|
||||
|
||||
pages_read = request.POST.get('pages_read')
|
||||
if pages_read:
|
||||
try:
|
||||
pages_read = int(pages_read)
|
||||
readthrough.pages_read = pages_read
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
return readthrough
|
||||
|
|
Loading…
Reference in a new issue