forked from mirrors/bookwyrm
Resolves merge weirdness
This commit is contained in:
parent
ddaf949c94
commit
c3ff7fcf9b
1 changed files with 3 additions and 34 deletions
|
@ -360,7 +360,8 @@ def populate_streams_on_account_create(sender, instance, created, *args, **kwarg
|
||||||
if not created or not instance.local:
|
if not created or not instance.local:
|
||||||
return
|
return
|
||||||
|
|
||||||
populate_streams_task.delay(instance.id)
|
for stream in streams.values():
|
||||||
|
populate_stream_task.delay(stream, instance.id)
|
||||||
|
|
||||||
|
|
||||||
@receiver(signals.pre_save, sender=models.ShelfBook)
|
@receiver(signals.pre_save, sender=models.ShelfBook)
|
||||||
|
@ -393,28 +394,6 @@ def remove_statuses_on_shelve(sender, instance, *args, **kwargs):
|
||||||
BooksStream().remove_book_statuses(instance.user, instance.book)
|
BooksStream().remove_book_statuses(instance.user, instance.book)
|
||||||
|
|
||||||
|
|
||||||
@receiver(signals.pre_save, sender=models.ShelfBook)
|
|
||||||
# pylint: disable=unused-argument
|
|
||||||
def add_statuses_on_shelve(sender, instance, *args, **kwargs):
|
|
||||||
"""update books stream when user shelves a book"""
|
|
||||||
if not instance.user.local:
|
|
||||||
return
|
|
||||||
book = None
|
|
||||||
if hasattr(instance, "book"):
|
|
||||||
book = instance.book
|
|
||||||
elif instance.mention_books.exists():
|
|
||||||
book = instance.mention_books.first()
|
|
||||||
if not book:
|
|
||||||
return
|
|
||||||
|
|
||||||
# check if the book is already on the user's shelves
|
|
||||||
editions = book.parent_work.editions.all()
|
|
||||||
if models.ShelfBook.objects.filter(user=instance.user, book__in=editions).exists():
|
|
||||||
return
|
|
||||||
|
|
||||||
BooksStream().add_book_statuses(instance.user, book)
|
|
||||||
|
|
||||||
|
|
||||||
@receiver(signals.post_delete, sender=models.ShelfBook)
|
@receiver(signals.post_delete, sender=models.ShelfBook)
|
||||||
# pylint: disable=unused-argument
|
# pylint: disable=unused-argument
|
||||||
def remove_statuses_on_unshelve(sender, instance, *args, **kwargs):
|
def remove_statuses_on_unshelve(sender, instance, *args, **kwargs):
|
||||||
|
@ -439,16 +418,6 @@ def remove_statuses_on_unshelve(sender, instance, *args, **kwargs):
|
||||||
|
|
||||||
# ---- TASKS
|
# ---- TASKS
|
||||||
|
|
||||||
# TODO: merge conflict: reconcile these tasks
|
|
||||||
|
|
||||||
@app.task
|
|
||||||
def populate_streams_task(user_id):
|
|
||||||
"""create a user's streams"""
|
|
||||||
user = models.User.objects.get(id=user_id)
|
|
||||||
for stream in streams.values():
|
|
||||||
stream.populate_streams(user)
|
|
||||||
|
|
||||||
|
|
||||||
@app.task
|
@app.task
|
||||||
def populate_stream_task(stream, user_id):
|
def populate_stream_task(stream, user_id):
|
||||||
"""background task for populating an empty activitystream"""
|
"""background task for populating an empty activitystream"""
|
||||||
|
@ -495,4 +464,4 @@ def add_user_statuses_task(viewer_id, user_id, stream_list=None):
|
||||||
viewer = models.User.objects.get(id=viewer_id)
|
viewer = models.User.objects.get(id=viewer_id)
|
||||||
user = models.User.objects.get(id=user_id)
|
user = models.User.objects.get(id=user_id)
|
||||||
for stream in stream_list:
|
for stream in stream_list:
|
||||||
stream.add_user_statuses(viewer, user)
|
stream.add_user_statuses(viewer, user)
|
||||||
|
|
Loading…
Reference in a new issue