Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 3
0
def delete_images_for_Idea(sender, instance, **kwargs):
    image_services.delete_images([instance.image])
Exemplo n.º 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])
Exemplo n.º 5
0
def delete_images_for_User(sender, instance, **kwargs):
    services.delete_images([instance._avatar])
Exemplo n.º 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)
Exemplo n.º 7
0
def delete_images_for_organisation(sender, instance, **kwargs):
    services.delete_images([instance.image, instance.logo])