mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-15 02:33:22 +00:00
optimize product pages again
This commit is contained in:
parent
b9cbba2309
commit
db6a871854
@ -13,7 +13,7 @@
|
|||||||
<h4>{{ product_type or _("Uncategorized") }}</h4>
|
<h4>{{ product_type or _("Uncategorized") }}</h4>
|
||||||
<ul>
|
<ul>
|
||||||
{%- for product in products -%}
|
{%- for product in products -%}
|
||||||
<li><a href="{{ url('counter:product_edit', product_id=product.id) }}">{{ product }} ({{ product.code }})</a></li>
|
<li><a href="{{ url('counter:product_edit', product_id=product.id) }}">{{ product.name }} ({{ product.code }})</a></li>
|
||||||
{%- endfor -%}
|
{%- endfor -%}
|
||||||
</ul>
|
</ul>
|
||||||
{%- else -%}
|
{%- else -%}
|
||||||
|
@ -17,7 +17,7 @@ import re
|
|||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from datetime import timezone as tz
|
from datetime import timezone as tz
|
||||||
from http import HTTPStatus
|
from http import HTTPStatus
|
||||||
from operator import attrgetter
|
from operator import itemgetter
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
from urllib.parse import parse_qs
|
from urllib.parse import parse_qs
|
||||||
|
|
||||||
@ -801,7 +801,7 @@ class ProductTypeEditView(CounterAdminTabsMixin, CounterAdminMixin, UpdateView):
|
|||||||
|
|
||||||
class ProductListView(CounterAdminTabsMixin, CounterAdminMixin, ListView):
|
class ProductListView(CounterAdminTabsMixin, CounterAdminMixin, ListView):
|
||||||
model = Product
|
model = Product
|
||||||
queryset = Product.objects.annotate(type_name=F("product_type__name"))
|
queryset = Product.objects.values("id", "name", "code", "product_type__name")
|
||||||
template_name = "counter/product_list.jinja"
|
template_name = "counter/product_list.jinja"
|
||||||
ordering = [
|
ordering = [
|
||||||
F("product_type__priority").desc(nulls_last=True),
|
F("product_type__priority").desc(nulls_last=True),
|
||||||
@ -812,7 +812,7 @@ class ProductListView(CounterAdminTabsMixin, CounterAdminMixin, ListView):
|
|||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
res = super().get_context_data(**kwargs)
|
res = super().get_context_data(**kwargs)
|
||||||
res["object_list"] = itertools.groupby(
|
res["object_list"] = itertools.groupby(
|
||||||
res["object_list"], key=attrgetter("type_name")
|
res["object_list"], key=itemgetter("product_type__name")
|
||||||
)
|
)
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user