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 %}
+
+ {% for i in get_subscriber(user).slots.all() %}
+ - {{ i.get_type_display() }} - {{i.machine.launderette }}, {{ i.start_date|localtime|date("l j") }} : {{ i.start_date|localtime|time(DATETIME_FORMAT) }}
+ {% endfor %}
+
+ {% endif %}
+{% endmacro %}
+
+{% macro show_tokens(user) %}
+ {% if get_subscriber(user).tokens.exists() %}
+ {% trans %}Tokens{% endtrans %}
+
+ {% for i in get_subscriber(user).tokens.all() %}
+ - {{ i }}
+ {% endfor %}
+
+ {% 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 %}
-
- {% for i in get_subscriber(profile).tokens.all() %}
- - {{ i }}
- {% endfor %}
-
- {% endif %}
+ {{ show_tokens(profile) }}
{# Shows slots took by the user #}
- {% if get_subscriber(profile).slots.exists() %}
- {% trans %}Slot{% endtrans %}
-
- {% for i in get_subscriber(profile).slots.all() %}
- - {{ i.get_type_display() }} - {{i.machine.launderette }}, {{ i.start_date|localtime|date("l j") }} : {{ i.start_date|localtime|time(DATETIME_FORMAT) }}
- {% endfor %}
-
- {% 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 %}
-
-
-
-
-
-