From 8c970e4848b9cedd5251082c1a64dfcc907e1afa Mon Sep 17 00:00:00 2001 From: Mike Dingjan Date: Fri, 10 Feb 2017 17:29:02 +0100 Subject: [PATCH] Update documentation --- CHANGELOG.txt | 1 + .../images/custom_image_model.rst | 13 ++---------- docs/releases/1.10.rst | 21 +++++++++++++++++++ 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 7c4b7f8d1a..f152a4d589 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -8,6 +8,7 @@ Changelog * Hooks can now specify the order in which they are run (Gagaro) * Added a `submit_buttons` block to login template (Gagaro) * The homepage created in the project template is now titled "Home" rather than "Homepage" (Karl Hobley) + * Signal receivers for custom `Image` and `Rendition` models are connected automatically (Mike Dingjan) * Fix: Marked 'Date from' / 'Date to' strings in wagtailforms for translation (Vorlif) * Fix: Unreliable preview is now reliable by always opening in a new window (Kjartan Sverrisson) * Fix: Fixed placement of `{{ block.super }}` in `snippets/type_index.html` (LB (Ben Johnston)) diff --git a/docs/advanced_topics/images/custom_image_model.rst b/docs/advanced_topics/images/custom_image_model.rst index a214ba5be5..4f0e001a43 100644 --- a/docs/advanced_topics/images/custom_image_model.rst +++ b/docs/advanced_topics/images/custom_image_model.rst @@ -22,8 +22,6 @@ Here's an example: # models.py from django.db import models - from django.db.models.signals import post_delete - from django.dispatch import receiver from wagtail.wagtailimages.models import Image, AbstractImage, AbstractRendition @@ -49,16 +47,9 @@ Here's an example: ) - # Delete the source image file when an image is deleted - @receiver(post_delete, sender=CustomImage) - def image_delete(sender, instance, **kwargs): - instance.file.delete(False) +.. versionchanged:: 1.10 - - # Delete the rendition image file when a rendition is deleted - @receiver(post_delete, sender=CustomRendition) - def rendition_delete(sender, instance, **kwargs): - instance.file.delete(False) + In previous versions of Wagtail it was necessary to connect signal handlers to handle deletion of image files. As of Wagtail 1.10 this is now handled automatically. .. note:: diff --git a/docs/releases/1.10.rst b/docs/releases/1.10.rst index 0092bd9dce..d14ebe880f 100644 --- a/docs/releases/1.10.rst +++ b/docs/releases/1.10.rst @@ -18,6 +18,8 @@ Other features * Hooks can now specify the order in which they are run (Gagaro) * Added a ``submit_buttons`` block to login template (Gagaro) * The homepage created in the project template is now titled "Home" rather than "Homepage" (Karl Hobley) + * Signal receivers for custom ``Image`` and ``Rendition`` models are connected automatically (Mike Dingjan) + Bug fixes ~~~~~~~~~ @@ -30,3 +32,22 @@ Bug fixes Upgrade considerations ====================== + + +Signals on custom ``Image`` and ``Rendition`` models connected automatically +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Projects using :ref:`custom image models ` no longer need to set up signal receivers to handle deletion of image files, as this is now handled automatically by Wagtail. The following lines of code should be removed: + +.. code-block:: python + + # Delete the source image file when an image is deleted + @receiver(post_delete, sender=CustomImage) + def image_delete(sender, instance, **kwargs): + instance.file.delete(False) + + + # Delete the rendition image file when a rendition is deleted + @receiver(post_delete, sender=CustomRendition) + def rendition_delete(sender, instance, **kwargs): + instance.file.delete(False)