diff --git a/bookwyrm/models/status.py b/bookwyrm/models/status.py index b92685da4..2a9a4be14 100644 --- a/bookwyrm/models/status.py +++ b/bookwyrm/models/status.py @@ -292,13 +292,21 @@ class Boost(Status): # unique_together = ('user', 'boosted_status') +class ProgressMode(models.TextChoices): + PAGE = 'PG', 'page' + PERCENT = 'PCT', 'percent' + class ReadThrough(BookWyrmModel): ''' Store a read through a book in the database. ''' user = models.ForeignKey('User', on_delete=models.PROTECT) book = models.ForeignKey('Book', on_delete=models.PROTECT) - pages_read = models.IntegerField( + progress = models.IntegerField( null=True, blank=True) + progress_mode = models.CharField( + max_length=3, + choices=ProgressMode.choices, + default=ProgressMode.PAGE) start_date = models.DateTimeField( blank=True, null=True) @@ -312,9 +320,13 @@ class ReadThrough(BookWyrmModel): self.user.save() super().save(*args, **kwargs) -class ProgressMode(models.TextChoices): - PAGE = 'PG', 'page' - PERCENT = 'PCT', 'percent' + def create_update(self): + if self.progress: + return self.progressupdate_set.create( + user=self.user, + progress=self.progress, + mode=self.progress_mode) + class ProgressUpdate(BookWyrmModel): ''' Store progress through a book in the database. ''' diff --git a/bookwyrm/templates/book.html b/bookwyrm/templates/book.html index 2bd9fc778..aeafaafb7 100644 --- a/bookwyrm/templates/book.html +++ b/bookwyrm/templates/book.html @@ -74,9 +74,13 @@ {% if readthrough.finish_date %}
Finished reading:
{{ readthrough.finish_date | naturalday }}
- {% elif readthrough.pages_read %} -
On page:
-
{{ readthrough.pages_read }} of {{ book.pages }}
+ {% elif readthrough.progress %} +
Progress:
+ {% if readthrough.progress_mode == 'PG' %} +
on page {{ readthrough.progress }} of {{ book.pages }}
+ {% else %} +
{{ readthrough.progress }}%
+ {% endif %} {% endif %}
@@ -93,12 +97,22 @@
{% if show_progress %} Progress Updates: -
+
+
  • {{ readthrough.start_date | naturalday }}: started
  • + {% elif readthrough.progress_updates|length %} Show {{ readthrough.progress_updates|length }} Progress Updates {% endif %} @@ -118,11 +132,27 @@ -
    - +
    +
    +
    + +
    +
    +
    +
    + + +
    +