From bca8dc039a3202e837d18b1406aa5745eca9eb12 Mon Sep 17 00:00:00 2001 From: klmp200 Date: Wed, 7 Sep 2016 23:06:38 +0200 Subject: [PATCH] Added macros for slots and tokens display --- core/templates/core/macros.jinja | 22 +++++++++++++++++++ core/templates/core/user_detail.jinja | 19 +++------------- .../launderette/launderette_book.jinja | 9 +++----- 3 files changed, 28 insertions(+), 22 deletions(-) diff --git a/core/templates/core/macros.jinja b/core/templates/core/macros.jinja index ac930514..9a048636 100644 --- a/core/templates/core/macros.jinja +++ b/core/templates/core/macros.jinja @@ -33,3 +33,25 @@ {%- endmacro %} + +{% macro show_slots(user) %} + {% if get_subscriber(user).slots.exists() %} +
{% trans %}Slot{% endtrans %}
+ + {% endif %} +{% endmacro %} + +{% macro show_tokens(user) %} + {% if get_subscriber(user).tokens.exists() %} +
{% trans %}Tokens{% endtrans %}
+ + {% endif %} +{% endmacro %} \ No newline at end of file diff --git a/core/templates/core/user_detail.jinja b/core/templates/core/user_detail.jinja index 0fa804f4..8bf4075c 100644 --- a/core/templates/core/user_detail.jinja +++ b/core/templates/core/user_detail.jinja @@ -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 %}
{% trans %}Account number: {% endtrans %}{{ profile.customer.account_id }}
{# Shows tokens bought by the user #} - {% if get_subscriber(profile).tokens.exists() %} -
{% trans %}Tokens{% endtrans %}
- - {% endif %} + {{ show_tokens(profile) }} {# Shows slots took by the user #} - {% if get_subscriber(profile).slots.exists() %} -
{% trans %}Slot{% endtrans %}
- - {% endif %} + {{ show_slots(profile) }} {% else %} {% trans %}Not subscribed{% endtrans %} {% if user.is_in_group(settings.SITH_MAIN_BOARD_GROUP) %} diff --git a/launderette/templates/launderette/launderette_book.jinja b/launderette/templates/launderette/launderette_book.jinja index 6eca751a..5f3e9bc2 100644 --- a/launderette/templates/launderette/launderette_book.jinja +++ b/launderette/templates/launderette/launderette_book.jinja @@ -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 %} +{{ show_slots(user) }} +{{ show_tokens(user) }} {% endblock %} - - - - - -