Added macros for slots and tokens display

This commit is contained in:
Antoine Bartuccio 2016-09-07 23:06:38 +02:00
parent 61c77a7877
commit bca8dc039a
3 changed files with 28 additions and 22 deletions

View File

@ -33,3 +33,25 @@
</div>
</div>
{%- endmacro %}
{% macro show_slots(user) %}
{% if get_subscriber(user).slots.exists() %}
<h5>{% trans %}Slot{% endtrans %}</h5>
<ul>
{% for i in get_subscriber(user).slots.all() %}
<li>{{ i.get_type_display() }} - {{i.machine.launderette }}, {{ i.start_date|localtime|date("l j") }} : {{ i.start_date|localtime|time(DATETIME_FORMAT) }}</li>
{% endfor %}
</ul>
{% endif %}
{% endmacro %}
{% macro show_tokens(user) %}
{% if get_subscriber(user).tokens.exists() %}
<h5>{% trans %}Tokens{% endtrans %}</h5>
<ul>
{% for i in get_subscriber(user).tokens.all() %}
<li>{{ i }}</li>
{% endfor %}
</ul>
{% endif %}
{% endmacro %}

View File

@ -1,4 +1,5 @@
{% extends "core/base.jinja" %}
{% from "core/macros.jinja" import show_slots, show_tokens %}
{% block title %}
{% trans user_name=profile.get_display_name() %}{{ user_name }}'s profile{% endtrans %}
@ -58,23 +59,9 @@
{% trans subscription_end=get_subscriber(profile).subscriptions.last().subscription_end %}Subscribed until {{ subscription_end }}{% endtrans %}<br/>
{% trans %}Account number: {% endtrans %}{{ profile.customer.account_id }}<br/>
{# Shows tokens bought by the user #}
{% if get_subscriber(profile).tokens.exists() %}
<h5>{% trans %}Tokens{% endtrans %}</h5>
<ul>
{% for i in get_subscriber(profile).tokens.all() %}
<li>{{ i }}</li>
{% endfor %}
</ul>
{% endif %}
{{ show_tokens(profile) }}
{# Shows slots took by the user #}
{% if get_subscriber(profile).slots.exists() %}
<h5>{% trans %}Slot{% endtrans %}</h5>
<ul>
{% for i in get_subscriber(profile).slots.all() %}
<li>{{ i.get_type_display() }} - {{i.machine.launderette }}, {{ i.start_date|localtime|date("l j") }} : {{ i.start_date|localtime|time(DATETIME_FORMAT) }}</li>
{% endfor %}
</ul>
{% endif %}
{{ show_slots(profile) }}
{% else %}
{% trans %}Not subscribed{% endtrans %}
{% if user.is_in_group(settings.SITH_MAIN_BOARD_GROUP) %}

View File

@ -1,4 +1,5 @@
{% extends "core/base.jinja" %}
{% from "core/macros.jinja" import show_slots, show_tokens %}
{% block title %}
{% trans %}Launderette{% endtrans %}
@ -52,10 +53,6 @@
{% endfor %}
</tbody>
</table>
{{ show_slots(user) }}
{{ show_tokens(user) }}
{% endblock %}