forked from mirrors/bookwyrm
Make ProgressUpdate attached to a readthrough
This commit is contained in:
parent
13229ea937
commit
00b8608a50
2 changed files with 2 additions and 4 deletions
|
@ -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)
|
||||
|
|
|
@ -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', '/'))
|
||||
|
||||
|
|
Loading…
Reference in a new issue