Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Show proper image when deleting images
Marcin Gębalaa8b76979f7fb
diff --git a/saleor/dashboard/product/views.py b/saleor/dashboard/product/views.pyindex 00bf7f7928..b9fc305381 100644--- a/saleor/dashboard/product/views.py+++ b/saleor/dashboard/product/views.py@@ -291,16 +291,16 @@ def product_image_edit(request, product_pk, img_pk=None):@staff_member_requireddef product_image_delete(request, product_pk, img_pk):product = get_object_or_404(Product, pk=product_pk)- product_image = get_object_or_404(product.images, pk=img_pk)+ image = get_object_or_404(product.images, pk=img_pk)if request.method == 'POST':- product_image.delete()+ image.delete()messages.success(request,pgettext_lazy('Dashboard message',- 'Deleted image %s') % product_image.image.name)+ 'Deleted image %s') % image.image.name)return redirect('dashboard:product-image-list', product_pk=product.pk)- ctx = {'product': product, 'product_image': product_image}+ ctx = {'product': product, 'image': image}return TemplateResponse(request,'dashboard/product/modal_product_image_confirm_delete.html', ctx)diff --git a/templates/dashboard/product/modal_product_image_confirm_delete.html b/templates/dashboard/product/modal_product_image_confirm_delete.htmlindex 019e5b9a5e..c0a609cbfc 100644--- a/templates/dashboard/product/modal_product_image_confirm_delete.html+++ b/templates/dashboard/product/modal_product_image_confirm_delete.html@@ -1,7 +1,7 @@{% load i18n %}{% load product_first_image from product_images %}-<form action="{% url 'dashboard:product-image-delete' product_pk=product.pk img_pk=product_image.pk %}" method="post" novalidate>+<form action="{% url 'dashboard:product-image-delete' product_pk=product.pk img_pk=image.pk %}" method="post" novalidate>{% csrf_token %}<div class="modal-content"><div class="row">@@ -12,9 +12,7 @@</div></div><div class="center-align">- <img class="responsive-img" src="{% product_first_image product size="255x255" method="crop" %}"- srcset="{% product_first_image product size="255x255" method="crop" %} 1x, {% product_first_image product size="510x510" method="crop" %} 2x"- alt="">+ <img class="responsive-img" src="{{ image.image.crop.255x255 }}" srcset="{{ image.image.crop.255x255 }} 1x, {{ image.image.crop.510x510 }} 2x" alt=""></div><p>{% blocktrans trimmed context "Modal delete image text" %}