Skip to content

Commit

Permalink
리뷰 이미지 delete 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
Gomnonix committed Sep 9, 2024
1 parent b03859a commit d9013d0
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions customk/reviews/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,17 +96,18 @@ def update(self, instance, validated_data):
instance.rating = validated_data.get("rating", instance.rating)
instance.save()


for image_instance in instance.images.all():
if image_instance.image_url:
obj = ObjectStorage()
obj_status_code = obj.delete_object(image_instance.image_url)

if obj_status_code != 204:
raise ValidationError(
{
"review_image": "Failed to delete existing image. Status code: {obj_status_code}"
"review_image": f"Failed to delete existing image. Status code: {obj_status_code}"
}
)
image_instance.delete()

for image_data64 in images_data64:
image_url = upload_image_to_object_storage(image_data64["image_url"])
Expand Down

0 comments on commit d9013d0

Please sign in to comment.