def hero_to_be_saved(sender, instance, **kwargs): if not instance.id: pass else: prev = Hero.objects.filter(id=instance.id) if prev.count() > 0 and prev[0].image.name != instance.image.name: delete_file_task.delay(prev[0].image.name)
def project_deleted(sender, instance, **kwargs): if instance.video.find("cloudinary.com") > -1: delete_file_task.delay(instance.video) elif instance.video.startswith("{0}://{1}".format( settings.DEFAULT_MEDIA_SERVER_PROTOCOL, settings.DEFAULT_MEDIA_SERVER_DOMAIN)): delete_file_task.delay(instance.video) # delete relevant publishing rule publish_rule_id = instance.publish.id PublishingRule.objects.filter(id=publish_rule_id).delete()
def admin_settings_to_be_saved(sender, instance, **kwargs): if not instance.id: pass else: prev = AdminSettings.objects.filter(id=instance.id) if prev.count() > 0: prev = prev[0] else: prev = None if prev and prev.header_logo.name and prev.header_logo.name != instance.header_logo.name: delete_file_task.delay(prev.header_logo.name) if prev and prev.footer_logo.name and prev.footer_logo.name != instance.footer_logo.name: delete_file_task.delay(prev.footer_logo.name)
def save_model(self, request, obj, form, change): if change: old = Project.objects.get(pk=obj.pk) super().save_model(request, obj, form, change) if change: new = Project.objects.get(pk=obj.pk) if old.video.find( "cloudinary.com") > -1 and old.video != new.video: delete_file_task.delay(old.video) elif old.video.startswith("{0}://{1}".format( settings.DEFAULT_MEDIA_SERVER_PROTOCOL, settings. DEFAULT_MEDIA_SERVER_DOMAIN)) and old.video != new.video: delete_file_task.delay(old.video) if project_changed(old, new): info = { "project_id": str(new.pk), "editor": request.user.username } activity_notification(["edited_project"], **info)
def admin_settings_to_be_deleted(sender, instance, **kwargs): if instance.header_logo.name: delete_file_task.delay(instance.header_logo.name) if instance.footer_logo.name: delete_file_task.delay(instance.footer_logo.name)
def hero_to_be_deleted(sender, instance, **kwargs): if instance.image.name: delete_file_task.delay(instance.image.name)
def image_to_be_deleted(sender, instance, **kwargs): delete_file_task.delay(instance.image_url)
def delete(self, name): delete_file_task.delay(name)