Commit 7702f795 authored by Laurent Peuch's avatar Laurent Peuch
Browse files

[enh] factorize templates

parent 6449619a
......@@ -51,52 +51,14 @@
=order
.col-md-6
.panel.panel-default
.panel-heading
Default components
%table.table.table-bordered
%colgroup
%col
%col{width: "10px"}
%col{width: "15px", style: "text-align: right"}
%tr
%th Name
%th Stock
%th Price
-for component in components
-if component.in_default_pack
%tr
%td
%a{href: "{{ component.url }}"}= component.reference
%i= component.full_name
%td= component.stock
%td.price= component.current_price
.panel.panel-default
.panel-heading
Other components
%table.table.table-bordered
%colgroup
%col
%col{width: "10px"}
%col{width: "15px", style: "text-align: right"}
%tr
%th Name
%th Stock
%th Price
-for component in components
-if not component.in_default_pack
%tr
%td
%a{href: "{{ component.url }}"}= component.reference
%i= component.full_name
%td= component.stock
%td.price= component.current_price
-regroup components by in_default_pack as component_group
-for cg in component_group
-if cg.grouper
-with title="Default components" components=cg.list
-include "admin2/home/stock.haml"
-else
-with title="Other components" components=cg.list
-include "admin2/home/stock.haml"
:css
td.price {
......
.panel.panel-default
.panel-heading
=title
%table.table.table-bordered
%colgroup
%col
%col{width: "10px"}
%col{width: "15px", style: "text-align: right"}
%tr
%th Name
%th Stock
%th Price
-for component in components
%tr
%td
%a{href: "{{ component.url }}"}= component.reference
%i= component.full_name
%td= component.stock
%td.price= component.current_price
......@@ -7,7 +7,7 @@ from ordering.models import Component, GroupOrder, Order
def dashboard(request):
return render(request, "admin2/home.haml", {
"group_orders": GroupOrder.objects.all().order_by("-launched_on"),
"components": Component.objects.all().order_by("full_name"),
"components": Component.objects.all().order_by("in_default_pack", "full_name"),
"orders": Order.objects.all().order_by("group_order", "id"),
})
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment