Added food api endpoints prep for mcp
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
from django.db import transaction
|
||||
from django.db.models.signals import post_delete
|
||||
from django.dispatch import receiver
|
||||
|
||||
from .models import FoodLogAttachment
|
||||
|
||||
|
||||
@receiver(post_delete, sender=FoodLogAttachment)
|
||||
def delete_attachment_file(sender, instance, **kwargs):
|
||||
if instance.image:
|
||||
storage, name = instance.image.storage, instance.image.name
|
||||
transaction.on_commit(lambda: storage.delete(name))
|
||||
Reference in New Issue
Block a user