Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Add info about products count in a category when deleting

Marcin Gębala72bc552e01ff
diff --git a/saleor/dashboard/category/views.py b/saleor/dashboard/category/views.py
index 22770a38e7..a338179371 100644
--- a/saleor/dashboard/category/views.py
+++ b/saleor/dashboard/category/views.py
@@ -49,6 +49,7 @@ class CategoryDeleteView(StaffMemberOnlyMixin, DeleteView):
def get_context_data(self, **kwargs):
ctx = super(CategoryDeleteView, self).get_context_data(**kwargs)
ctx['descendants'] = list(self.get_object().get_descendants())
+ ctx['products_count'] = len(self.get_object().products.all())
return ctx
def post(self, request, *args, **kwargs):
diff --git a/saleor/dashboard/templates/dashboard/category/category_confirm_delete.html b/saleor/dashboard/templates/dashboard/category/category_confirm_delete.html
index aaed729303..12f763949d 100644
--- a/saleor/dashboard/templates/dashboard/category/category_confirm_delete.html
+++ b/saleor/dashboard/templates/dashboard/category/category_confirm_delete.html
@@ -18,9 +18,9 @@
</div>
</div>
- {% if descendants %}
- <div class="row">
- <div class="col-lg-12">
+ <div class="row">
+ <div class="col-lg-12">
+ {% if descendants %}
{% trans 'The following child categories will be deleted:' %}
<ul>
{% recursetree descendants %}
@@ -33,9 +33,17 @@
</li>
{% endrecursetree %}
</ul>
- </div>
+ {% endif %}
+
+ {% if products_count %}
+ {% blocktrans count counter=products_count %}
+ There is one product in this category that will be deleted.
+ {% plural %}
+ There are {{ counter }} products in this category that will be deleted.
+ {% endblocktrans %}
+ {% endif %}
</div>
- {% endif %}
+ </div>
<div class="form-group">
<div class="col-md-6">