Beispiel #1
0
def delete_old_image(sender, instance, **kwargs):
    old_images = []
    if hasattr(instance, '_current_image_file'):
        if instance._current_image_file != instance.image:
            old_images.append(instance._current_image_file)
    if hasattr(instance, '_current_logo_file'):
        if instance._current_logo_file != instance.logo:
            old_images.append(instance._current_logo_file)
    services.delete_images(old_images)
Beispiel #2
0
def delete_old_images_on_save(sender, instance, **kwargs):
    image_fields = getattr(instance, _IMAGE_FIELDS_ATTR, [])
    current_images = getattr(instance, _CURRENT_IMAGES_ATTR, ())

    delete_images = [current_image
                     for fieldname, current_image
                     in zip(image_fields, current_images)
                     if getattr(instance, fieldname, None) != current_image]
    services.delete_images(delete_images)

    backup_images_path(instance)
Beispiel #3
0
def delete_images_for_Idea(sender, instance, **kwargs):
    image_services.delete_images([instance.image])
Beispiel #4
0
def delete_old_image(sender, instance, **kwargs):
    if hasattr(instance, '_current_image_file'):
        if instance._current_image_file != instance.image:
            image_services.delete_images([instance._current_image_file])
Beispiel #5
0
def delete_images_for_User(sender, instance, **kwargs):
    services.delete_images([instance._avatar])
Beispiel #6
0
def delete_images_cascaded(sender, instance, **kwargs):
    image_fields = getattr(instance, _IMAGE_FIELDS_ATTR, [])
    images = [getattr(instance, fieldname) for fieldname in image_fields]
    services.delete_images(images)
Beispiel #7
0
def delete_images_for_organisation(sender, instance, **kwargs):
    services.delete_images([instance.image, instance.logo])