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
|
activity_serializer = activitypub.Quotation
|
||||||
pure_activity_serializer = activitypub.Note
|
pure_activity_serializer = activitypub.Note
|
||||||
|
|
||||||
class Progress(Status):
|
#class Progress(Status):
|
||||||
''' an update of where a user is in a book, using page number or % '''
|
# ''' an update of where a user is in a book, using page number or % '''
|
||||||
class ProgressMode(models.TextChoices):
|
# class ProgressMode(models.TextChoices):
|
||||||
PAGE = 'PG', 'page'
|
# PAGE = 'PG', 'page'
|
||||||
PERCENT = 'PCT', 'percent'
|
# PERCENT = 'PCT', 'percent'
|
||||||
|
#
|
||||||
progress = models.IntegerField()
|
# progress = models.IntegerField()
|
||||||
mode = models.TextChoices(max_length=3, choices=ProgessMode.choices, default=ProgressMode.PAGE)
|
# mode = models.TextChoices(max_length=3, choices=ProgessMode.choices, default=ProgressMode.PAGE)
|
||||||
book = models.ForeignKey('Edition', on_delete=models.PROTECT)
|
# book = models.ForeignKey('Edition', on_delete=models.PROTECT)
|
||||||
|
#
|
||||||
@property
|
# @property
|
||||||
def ap_pure_content(self):
|
# def ap_pure_content(self):
|
||||||
''' indicate the book in question for mastodon (or w/e) users '''
|
# ''' indicate the book in question for mastodon (or w/e) users '''
|
||||||
if self.mode == ProgressMode.PAGE:
|
# if self.mode == ProgressMode.PAGE:
|
||||||
return 'on page %d of %d in <a href="%s">"%s"</a>' % (
|
# return 'on page %d of %d in <a href="%s">"%s"</a>' % (
|
||||||
self.progress,
|
# self.progress,
|
||||||
self.book.pages,
|
# self.book.pages,
|
||||||
self.book.remote_id,
|
# self.book.remote_id,
|
||||||
self.book.title,
|
# self.book.title,
|
||||||
)
|
# )
|
||||||
else:
|
# else:
|
||||||
return '%d%% of the way through <a href="%s">"%s"</a>' % (
|
# return '%d%% of the way through <a href="%s">"%s"</a>' % (
|
||||||
self.progress,
|
# self.progress,
|
||||||
self.book.remote_id,
|
# self.book.remote_id,
|
||||||
self.book.title,
|
# self.book.title,
|
||||||
)
|
# )
|
||||||
|
#
|
||||||
activity_serializer = activitypub.Progress
|
# activity_serializer = activitypub.Progress
|
||||||
pure_activity_serializer = activitypub.Note
|
# pure_activity_serializer = activitypub.Note
|
||||||
|
|
||||||
class Review(Status):
|
class Review(Status):
|
||||||
''' a book review '''
|
''' a book review '''
|
||||||
|
|
|
@ -74,6 +74,9 @@
|
||||||
{% if readthrough.finish_date %}
|
{% if readthrough.finish_date %}
|
||||||
<dt>Finished reading:</dt>
|
<dt>Finished reading:</dt>
|
||||||
<dd>{{ readthrough.finish_date | naturalday }}</dd>
|
<dd>{{ readthrough.finish_date | naturalday }}</dd>
|
||||||
|
{% elif readthrough.pages_read %}
|
||||||
|
<dt>On page:</dt>
|
||||||
|
<dd>{{ readthrough.pages_read}} of {{ book.pages }}</dd>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</dl>
|
</dl>
|
||||||
<div class="field is-grouped">
|
<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" }}">
|
<input type="date" name="start_date" class="input" id="id_start_date-{{ readthrough.id }}" value="{{ readthrough.start_date | date:"Y-m-d" }}">
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</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">
|
<div class="field">
|
||||||
<label class="label">
|
<label class="label">
|
||||||
Finished reading
|
Finished reading
|
||||||
|
|
|
@ -729,4 +729,12 @@ def update_readthrough(request, book=None, create=True):
|
||||||
except ParserError:
|
except ParserError:
|
||||||
pass
|
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
|
return readthrough
|
||||||
|
|
Loading…
Reference in a new issue