Catches straggler preview_image signal

This commit is contained in:
Mouse Reeve 2021-06-18 15:28:43 -07:00
parent 59938e2d46
commit 60626eaca1

View file

@ -13,6 +13,7 @@ from model_utils.managers import InheritanceManager
from bookwyrm import activitypub from bookwyrm import activitypub
from bookwyrm.preview_images import generate_edition_preview_image_task from bookwyrm.preview_images import generate_edition_preview_image_task
from bookwyrm.settings import ENABLE_PREVIEW_IMAGES
from .activitypub_mixin import ActivitypubMixin, ActivityMixin from .activitypub_mixin import ActivitypubMixin, ActivityMixin
from .activitypub_mixin import OrderedCollectionPageMixin from .activitypub_mixin import OrderedCollectionPageMixin
from .base_model import BookWyrmModel from .base_model import BookWyrmModel
@ -405,12 +406,15 @@ class Boost(ActivityMixin, Status):
# unique_together = ('user', 'boosted_status') # unique_together = ('user', 'boosted_status')
@receiver(models.signals.post_save)
# pylint: disable=unused-argument # pylint: disable=unused-argument
@receiver(models.signals.post_save)
def preview_image(instance, sender, *args, **kwargs): def preview_image(instance, sender, *args, **kwargs):
if sender in (Review, ReviewRating): """Updates book previews if the rating has changed"""
changed_fields = instance.field_tracker.changed() if not ENABLE_PREVIEW_IMAGES or sender not in (Review, ReviewRating):
return
if len(changed_fields) > 0: changed_fields = instance.field_tracker.changed()
edition = instance.book
generate_edition_preview_image_task.delay(edition.id) if len(changed_fields) > 0:
edition = instance.book
generate_edition_preview_image_task.delay(edition.id)