Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Use base template modal confirmation for product class removal
Jakub Draganek629b41ee393c
diff --git a/saleor/dashboard/product/views.py b/saleor/dashboard/product/views.pyindex 30a09cdf72..9dfe4c9e5b 100644--- a/saleor/dashboard/product/views.py+++ b/saleor/dashboard/product/views.py@@ -86,7 +86,10 @@ def product_class_delete(request, pk):products = [str(p) for p in product_class.products.all()]context = {'product_class': product_class, 'products': products}- confirm_tmpl = 'dashboard/product/product_class/modal_confirm_delete.html'+ if products:+ confirm_tmpl = 'dashboard/product/product_class/modal_cannot_delete_class.html'+ else:+ confirm_tmpl = 'dashboard/product/product_class/modal_confirm_delete.html'return TemplateResponse(request, confirm_tmpl, context)diff --git a/templates/dashboard/modal_confirm_delete.html b/templates/dashboard/modal_confirm_delete.htmlindex 802d4c1bd1..ba1f7711ac 100644--- a/templates/dashboard/modal_confirm_delete.html+++ b/templates/dashboard/modal_confirm_delete.html@@ -1,6 +1,6 @@{% load i18n %}-<form action="{% block action_url %}{% endblock %}" method="post" novalidate>+<form action="{% block action_url %}#!{% endblock %}" method="post" novalidate>{% csrf_token %}<div class="modal-content"><div class="row">diff --git a/templates/dashboard/product/product_class/modal_confirm_delete.html b/templates/dashboard/product/product_class/modal_confirm_delete.htmlindex 2d6f241d9b..6a0b4d57d4 100644--- a/templates/dashboard/product/product_class/modal_confirm_delete.html+++ b/templates/dashboard/product/product_class/modal_confirm_delete.html@@ -1,55 +1,14 @@+{% extends "dashboard/modal_confirm_delete.html" %}+{% load i18n %}{% load prices_i18n %}{% load staticfiles %}-{% if has_products %}- <div class="modal-content">- <div class="row">- <div class="col s12">- <h5>- {% trans "Error" context "Dashboard error" %}- </h5>- </div>- </div>- <div class="row">- <div class="col s12 center-align">- <p>- {% blocktrans trimmed context "Modal delete product class with products text" %}- This type is base for created products. Cannot remove it.- {% endblocktrans %}- </p>- </div>- </div>- </div>- <div class="modal-footer">- <a href="#!" class="modal-action modal-close btn-flat">- {% trans "Cancel" context "Dashboard cancel action" %}- </a>- </div>-{% else %}- <form action="{% url "dashboard:product-class-delete" pk=product_class.pk %}" method="post" novalidate>- {% csrf_token %}- <div class="modal-content">- <div class="row">- <div class="col s12">- <h5>- {% trans "Are you sure?" context "Dashboard confirmation modal" %}- </h5>- </div>- </div>- <p>- {% blocktrans trimmed context "Modal delete product class text" %}- If you remove <strong>{{ product_class }}</strong> you will lose all data related to this product type.- {% endblocktrans %}- </p>- </div>- <div class="modal-footer">- <button type="submit" class="modal-action btn-flat">- {% trans "Delete" context "Dashboard delete action" %}- </button>- <a href="#!" class="modal-action modal-close btn-flat">- {% trans "Cancel" context "Dashboard cancel action" %}- </a>- </div>- </form>-{% endif %}+{% block action_url %}{% url "dashboard:product-class-delete" pk=product_class.pk %}{% endblock %}+{% block content %}+<p>+ {% blocktrans trimmed context "Modal delete product class text" %}+ If you remove <strong>{{ product_class }}</strong> you will lose all data related to this product type.+ {% endblocktrans %}+</p>+{% endblock %}