eboutic_main.jinja 2.08 KB
Newer Older
1
2
{% extends "core/base.jinja" %}

3
4
5
6
{% block title %}
{% trans %}Eboutic{% endtrans %}
{% endblock %}

Skia's avatar
Skia committed
7
8
{% macro add_product(id, content, class="") %}
<form method="post" action="{{ url('eboutic:main') }}" class="inline {{ class }}">
9
10
    {% csrf_token %}
    <input type="hidden" name="action" value="add_product">
Skia's avatar
Skia committed
11
    <button type="submit" name="product_id" value="{{ id }}"> {{ content|safe }} </button>
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
</form>
{% endmacro %}

{% macro del_product(id, content) %}
<form method="post" action="{{ url('eboutic:main') }}" class="inline" style="display:inline">
    {% csrf_token %}
    <input type="hidden" name="action" value="del_product">
    <button type="submit" name="product_id" value="{{ id }}"> {{ content }} </button>
</form>
{% endmacro %}

{% block content %}
<h3>{% trans %}Eboutic{% endtrans %}</h3>

<div id="basket">
    <p>{% trans %}Basket: {% endtrans %}</p>
    <ul>
Skia's avatar
Skia committed
29
30
31
        {% for i in basket.items.all()|sort(attribute='id') %}
        <li>{{ del_product(i.product_id, '-') }} {{ i.quantity }}
        {{ add_product(i.product_id, '+') }} {{ i.product_name }}: {{ "%0.2f"|format(i.product_unit_price*i.quantity) }}</li>
32
33
        {% endfor %}
    </ul>
Skia's avatar
Skia committed
34
    <p><strong>{% trans %}Total: {% endtrans %}{{ "%0.2f"|format(basket.get_total()) }}</strong></p>
35
36
37
38
39
40
    <form method="post" action="{{ url('eboutic:command') }}">
        {% csrf_token %}
        <input type="submit" value="{% trans %}Proceed to command{% endtrans %}" />
    </form>
</div>
<div>
41
42
43
44
    {% for t in categories %}
    {% if eboutic.products.filter(product_type=t).exists() %}
        <h5>{{ t }}</h5>
        {% for p in eboutic.products.filter(product_type=t).all() %}
Skia's avatar
Skia committed
45
46
47
48
49
50
51
52
            {% set file = None %}
            {% if p.icon %}
                {% set file = p.icon.url %}
            {% else %}
                {% set file = static('core/img/na.gif') %}
            {% endif %}
            {% set prod = '<strong>%s</strong><hr><img src="%s" /><span>%s €</span>' % (p.name, file, p.selling_price) %}
        {{ add_product(p.id, prod, "form_button") }}
53
54
        {% endfor %}
    {% endif %}
55
56
57
58
59
60
61
    {% endfor %}
</div>

{% endblock %}