mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-12-20 23:26:42 +00:00
Create and store reading progress when shelving books.
This commit is contained in:
parent
8e12071b99
commit
5a8a57523e
1 changed files with 20 additions and 0 deletions
|
@ -1,4 +1,5 @@
|
|||
''' handles all the activity coming out of the server '''
|
||||
from datetime import datetime
|
||||
from urllib.parse import urlencode
|
||||
|
||||
from django.db import IntegrityError, transaction
|
||||
|
@ -138,6 +139,25 @@ def handle_shelve(user, book, shelf):
|
|||
status.status_type = 'Update'
|
||||
status.save()
|
||||
|
||||
if shelf.identifier == 'reading':
|
||||
read = models.ReadThrough(
|
||||
user=user,
|
||||
book=book,
|
||||
start_date=datetime.now())
|
||||
read.save()
|
||||
elif shelf.identifier == 'read':
|
||||
read = models.ReadThrough.objects.filter(
|
||||
user=user,
|
||||
book=book,
|
||||
finish_date=None).order_by('-created_date').first()
|
||||
if not read:
|
||||
read = models.ReadThrough(
|
||||
user=user,
|
||||
book=book,
|
||||
start_date=datetime.now())
|
||||
read.finish_date = datetime.now()
|
||||
read.save()
|
||||
|
||||
activity = activitypub.get_status(status)
|
||||
create_activity = activitypub.get_create(user, activity)
|
||||
|
||||
|
|
Loading…
Reference in a new issue