From 00b8608a50d6125691ac03c616433b9cf949cfd9 Mon Sep 17 00:00:00 2001 From: Joel Bradshaw Date: Mon, 16 Nov 2020 23:53:17 -0800 Subject: [PATCH] Make ProgressUpdate attached to a readthrough --- bookwyrm/models/status.py | 2 +- bookwyrm/view_actions.py | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/bookwyrm/models/status.py b/bookwyrm/models/status.py index e5395bff..d52a1008 100644 --- a/bookwyrm/models/status.py +++ b/bookwyrm/models/status.py @@ -336,7 +336,7 @@ class ProgressMode(models.TextChoices): class ProgressUpdate(BookWyrmModel): ''' Store progress through a book in the database. ''' user = models.ForeignKey('User', on_delete=models.PROTECT) - book = models.ForeignKey('Book', on_delete=models.PROTECT) + readthrough = models.ForeignKey('ReadThrough', on_delete=models.PROTECT) progress = models.IntegerField() mode = models.CharField(max_length=3, choices=ProgressMode.choices, default=ProgressMode.PAGE) date = models.DateTimeField(auto_now_add=True) diff --git a/bookwyrm/view_actions.py b/bookwyrm/view_actions.py index 6a01ac5d..8b11f2ff 100644 --- a/bookwyrm/view_actions.py +++ b/bookwyrm/view_actions.py @@ -428,12 +428,10 @@ def edit_readthrough(request): # record the progress update individually # use default now for date field - progress_update = models.ProgressUpdate( + readthrough.progressupdate_set.create( user=request.user, - book=readthrough.book, progress=readthrough.pages_read, mode=models.ProgressMode.PAGE) - progress_update.save() return redirect(request.headers.get('Referer', '/'))