<commit_before>from django.db.models.signals import post_delete, post_init, post_save
from django.dispatch import receiver

from adhocracy4.images import services

from .models import Project


@receiver(post_init, sender=Project)
def backup_image_path(sender, instance, **kwargs):
    instance._current_image_file = instance.image


@receiver(post_save, sender=Project)
def delete_old_image(sender, instance, **kwargs):
    if hasattr(instance, '_current_image_file'):
        if instance._current_image_file != instance.image:
            services.delete_images([instance._current_image_file])


@receiver(post_delete, sender=Project)
def delete_images_for_project(sender, instance, **kwargs):
    services.delete_images([instance.image])<commit_msg>Enable signals for inheriting projects.<commit_after>from django.db.models.signals import post_delete, post_init, post_save
from django.dispatch import receiver

from adhocracy4.images import services

from .models import Project


@receiver(post_init)
def backup_image_path(sender, instance, **kwargs):
    if issubclass(sender, Project):
        instance._current_image_file = instance.image


@receiver(post_save)
def delete_old_image(sender, instance, **kwargs):
    if issubclass(sender, Project):
        if hasattr(instance, '_current_image_file'):
            if instance._current_image_file != instance.image:
                services.delete_images([instance._current_image_file])


@receiver(post_delete)
def delete_images_for_project(sender, instance, **kwargs):
    if issubclass(sender, Project):
        services.delete_images([instance.image])
{'fraction_non_alphanumeric': 0.09503105590062112, 'fraction_numerical': 0.0012422360248447205, 'mean_word_length': 5.548780487804878, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3491965', 'n_tokens_mistral': 464, 'n_tokens_neox': 454, 'n_words': 101}