Skip to content

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

Show info when no product class created

Krzysztof Wolskiab0317435b14
diff --git a/saleor/dashboard/product/views.py b/saleor/dashboard/product/views.py
index c7a22c8d33..972da376a7 100644
--- a/saleor/dashboard/product/views.py
+++ b/saleor/dashboard/product/views.py
@@ -83,7 +83,8 @@ def product_list(request):
return redirect('dashboard:product-add',
class_pk=form.cleaned_data['product_cls'])
products = get_paginator_items(products, 30, request.GET.get('page'))
- ctx = {'form': form, 'products': products}
+ ctx = {'form': form, 'products': products,
+ 'product_classes': product_classes}
return TemplateResponse(request, 'dashboard/product/list.html', ctx)
diff --git a/templates/dashboard/product/list.html b/templates/dashboard/product/list.html
index e93eae0b7c..af4e492b2d 100644
--- a/templates/dashboard/product/list.html
+++ b/templates/dashboard/product/list.html
@@ -12,23 +12,11 @@
{% block header_extra %}
<div class="fixed-action-btn">
- {% if form.product_cls.1 %}
+ {% if product_classes %}
<a class="btn-fab btn-floating btn-large waves-effect waves-light teal modal-trigger"
href="#modal-product-class" title="{% trans "Add product" %}">
<i class="material-icons">add</i>
</a>
- {% else %}
- <form method="post" novalidate>
- <div hidden>
- {% csrf_token %}
- {{ form }}
- </div>
-
- <button type="submit" class="btn-fab btn-floating btn-large waves-effect waves-light teal"
- title="{% trans "Add product" %}">
- <i class="material-icons">add</i>
- </button>
- </form>
{% endif %}
</div>
{% endblock %}
@@ -63,6 +51,9 @@
{% include "dashboard/includes/_pagination.html" with page_obj=products %}
{% else %}
<p>{% trans "No products found." %}</p>
+ {% if not product_classes %}
+ <p>{% trans "Create product class first." %}</p>
+ {% endif %}
{% endif %}
</div>
</div>