optimize: product list views

This commit is contained in:
imperosol
2024-10-13 12:32:50 +02:00
parent 40c623b202
commit 15ae24f0bd
3 changed files with 43 additions and 51 deletions

View File

@ -8,25 +8,17 @@
{% if current_tab == "products" %}
<p><a href="{{ url('counter:new_product') }}">{% trans %}New product{% endtrans %}</a></p>
{% endif %}
{% if product_list %}
<h3>{% trans %}Product list{% endtrans %}</h3>
{% for t in ProductType.objects.all().order_by('name') %}
<h4>{{ t }}</h4>
<ul>
{% for p in product_list.filter(product_type=t).all().order_by('name') %}
<li><a href="{{ url('counter:product_edit', product_id=p.id) }}">{{ p }} ({{ p.code }})</a></li>
{% endfor %}
</ul>
{% endfor %}
<h4>{% trans %}Uncategorized{% endtrans %}</h4>
<h3>{% trans %}Product list{% endtrans %}</h3>
{%- for product_type, products in object_list -%}
<h4>{{ product_type or _("Uncategorized") }}</h4>
<ul>
{% for p in product_list.filter(product_type=None).all().order_by('name') %}
<li><a href="{{ url('counter:product_edit', product_id=p.id) }}">{{ p }} ({{ p.code }})</a></li>
{% endfor %}
{%- for product in products -%}
<li><a href="{{ url('counter:product_edit', product_id=product.id) }}">{{ product }} ({{ product.code }})</a></li>
{%- endfor -%}
</ul>
{% else %}
{%- else -%}
{% trans %}There is no products in this website.{% endtrans %}
{% endif %}
{%- endfor -%}
{% endblock %}