Commit bca8dc03 authored by Sli's avatar Sli
Browse files

Added macros for slots and tokens display

parent 61c77a78
Pipeline #197 failed with stage
in 3 minutes and 2 seconds
...@@ -33,3 +33,25 @@ ...@@ -33,3 +33,25 @@
</div> </div>
</div> </div>
{%- endmacro %} {%- 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 %}
\ No newline at end of file
{% extends "core/base.jinja" %} {% extends "core/base.jinja" %}
{% from "core/macros.jinja" import show_slots, show_tokens %}
{% block title %} {% block title %}
{% trans user_name=profile.get_display_name() %}{{ user_name }}'s profile{% endtrans %} {% trans user_name=profile.get_display_name() %}{{ user_name }}'s profile{% endtrans %}
...@@ -58,23 +59,9 @@ ...@@ -58,23 +59,9 @@
{% trans subscription_end=get_subscriber(profile).subscriptions.last().subscription_end %}Subscribed until {{ subscription_end }}{% endtrans %}<br/> {% 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/> {% trans %}Account number: {% endtrans %}{{ profile.customer.account_id }}<br/>
{# Shows tokens bought by the user #} {# Shows tokens bought by the user #}
{% if get_subscriber(profile).tokens.exists() %} {{ show_tokens(profile) }}
<h5>{% trans %}Tokens{% endtrans %}</h5>
<ul>
{% for i in get_subscriber(profile).tokens.all() %}
<li>{{ i }}</li>
{% endfor %}
</ul>
{% endif %}
{# Shows slots took by the user #} {# Shows slots took by the user #}
{% if get_subscriber(profile).slots.exists() %} {{ show_slots(profile) }}
<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 %}
{% else %} {% else %}
{% trans %}Not subscribed{% endtrans %} {% trans %}Not subscribed{% endtrans %}
{% if user.is_in_group(settings.SITH_MAIN_BOARD_GROUP) %} {% if user.is_in_group(settings.SITH_MAIN_BOARD_GROUP) %}
......
{% extends "core/base.jinja" %} {% extends "core/base.jinja" %}
{% from "core/macros.jinja" import show_slots, show_tokens %}
{% block title %} {% block title %}
{% trans %}Launderette{% endtrans %} {% trans %}Launderette{% endtrans %}
...@@ -52,10 +53,6 @@ ...@@ -52,10 +53,6 @@
{% endfor %} {% endfor %}
</tbody> </tbody>
</table> </table>
{{ show_slots(user) }}
{{ show_tokens(user) }}
{% endblock %} {% endblock %}
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