mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-16 19:23:27 +00:00
66 lines
2.2 KiB
Django/Jinja
66 lines
2.2 KiB
Django/Jinja
{% extends "core/base.jinja" %}
|
|
|
|
{% block title %}
|
|
{% trans %}Eboutic{% endtrans %}
|
|
{% endblock %}
|
|
|
|
{% macro add_product(id, content, class="") %}
|
|
<form method="post" action="{{ url('eboutic:main') }}" class="inline {{ class }}">
|
|
{% csrf_token %}
|
|
<input type="hidden" name="action" value="add_product">
|
|
<button type="submit" name="product_id" value="{{ id }}"> {{ content|safe }} </button>
|
|
</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>
|
|
{% 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>
|
|
{% endfor %}
|
|
</ul>
|
|
<p><strong>{% trans %}Total: {% endtrans %}{{ "%0.2f"|format(basket.get_total()) }} €</strong></p>
|
|
<form method="post" action="{{ url('eboutic:command') }}">
|
|
{% csrf_token %}
|
|
<input type="submit" value="{% trans %}Proceed to command{% endtrans %}" />
|
|
</form>
|
|
</div>
|
|
<div>
|
|
{% for t in categories %}
|
|
{% if eboutic.products.filter(product_type=t).exists() %}
|
|
<h5>{{ t }}</h5>
|
|
{% if t.comment %}
|
|
<p>{{ t.comment }}</p>
|
|
{% endif %}
|
|
<br />
|
|
{% for p in eboutic.products.filter(product_type=t).all() %}
|
|
{% 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") }}
|
|
{% endfor %}
|
|
{% endif %}
|
|
{% endfor %}
|
|
</div>
|
|
|
|
{% endblock %}
|
|
|
|
|
|
|