mirror of
https://github.com/seanmorley15/AdventureLog.git
synced 2025-08-05 05:05:17 +02:00
added-fix-image-deletion
This commit is contained in:
parent
71ff217323
commit
0a3ca75dd0
1 changed files with 4 additions and 0 deletions
|
@ -9,6 +9,7 @@ from adventures.serializers import AdventureImageSerializer
|
||||||
from integrations.models import ImmichIntegration
|
from integrations.models import ImmichIntegration
|
||||||
import uuid
|
import uuid
|
||||||
import requests
|
import requests
|
||||||
|
import os
|
||||||
|
|
||||||
class AdventureImageViewSet(viewsets.ModelViewSet):
|
class AdventureImageViewSet(viewsets.ModelViewSet):
|
||||||
serializer_class = AdventureImageSerializer
|
serializer_class = AdventureImageSerializer
|
||||||
|
@ -150,6 +151,9 @@ class AdventureImageViewSet(viewsets.ModelViewSet):
|
||||||
|
|
||||||
def perform_destroy(self, instance):
|
def perform_destroy(self, instance):
|
||||||
print("perform_destroy")
|
print("perform_destroy")
|
||||||
|
if instance.image:
|
||||||
|
if os.path.isfile(instance.image.path):
|
||||||
|
os.remove(instance.image.path)
|
||||||
return super().perform_destroy(instance)
|
return super().perform_destroy(instance)
|
||||||
|
|
||||||
def destroy(self, request, *args, **kwargs):
|
def destroy(self, request, *args, **kwargs):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue