macros.jinja 2.82 KB
Newer Older
Skia's avatar
Skia committed
1
2
3
{% macro user_profile_link(user) -%}
<a href="{{ url("core:user_profile", user_id=user.id) }}">{{ user.get_display_name() }}</a>
{%- endmacro %}
Skia's avatar
Skia committed
4

Skia's avatar
Skia committed
5
6
7
8
{% macro user_profile_link_short_name(user) -%}
<a href="{{ url("core:user_profile", user_id=user.id) }}">{{ user.get_short_name() }}</a>
{%- endmacro %}

Skia's avatar
Skia committed
9
10
{% macro user_link_with_pict(user) -%}
<a href="{{ url("core:user_profile", user_id=user.id) }}" class="mini_profile_link" >
11
12
    {{ user.get_mini_item()|safe }}
</a>
Skia's avatar
Skia committed
13
{%- endmacro %}
14
15
16

{% macro user_mini_profile(user) %}
<div id="user_profile">
Skia's avatar
Skia committed
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35

    <div id="right_column">
        <div id="pictures">
            {% if user.profile_pict %}
            <img src="{{ user.profile_pict.get_download_url() }}" alt="{% trans %}Profile{% endtrans %}" />
            {% endif %}
        </div>
    </div>
    <div id="left_column">
        <p>{{ user.get_full_name() }}</p>
        {% if user.nick_name %}
        <p id="nickname">&laquo; {{ user.nick_name }} &raquo;</p>
        {% endif %}
        {% if user.date_of_birth %}
            <p>{% trans %}Born: {% endtrans %}{{ user.date_of_birth|date("d/m/Y") }} ({{ user.get_age() }})</p>
        {% endif %}
        {% if user.promo %}
        <p><img src="{{ static('core/img/promo_%02d.png' % user.promo) }}" alt="Promo {{ user.promo }}" class="promo_pict" />
        {% trans %}Promo: {% endtrans %}{{ user.promo }}</p>
36
37
38
39
        {% endif %}
    </div>
</div>
{%- endmacro %}
40

41
{% macro user_subscription(user) %}
Skia's avatar
Skia committed
42
        {% trans subscription_end=user.subscriptions.last().subscription_end %}Subscribed until {{ subscription_end }}{% endtrans %}<br/>
43
44
45
        {% trans %}Account number: {% endtrans %}{{ user.customer.account_id }}<br/>
{%- endmacro %}

46
{% macro show_slots(user) %}
Skia's avatar
Skia committed
47
    {% if user.slots.filter(start_date__gte=timezone.now()).exists() %}
48
49
        <h5>{% trans %}Slot{% endtrans %}</h5>
        <ul>
Skia's avatar
Skia committed
50
        {% for i in user.slots.filter(start_date__gte=timezone.now().replace(tzinfo=None)).all() %}
Skia's avatar
Skia committed
51
52
53
            <li>{{ i.get_type_display() }} - {{i.machine.launderette }}, {{ i.start_date|date("l j") }} :
            {{ i.start_date|time(DATETIME_FORMAT) }} |
            <a href="{{ url('launderette:delete_slot', slot_id=i.id) }}">{% trans %}Delete{% endtrans %}</a></li>
54
55
56
57
58
59
        {% endfor %}
        </ul>
    {% endif %}
{% endmacro %}

{% macro show_tokens(user) %}
Skia's avatar
Skia committed
60
    {% if user.tokens.exists() %}
61
62
        <h5>{% trans %}Tokens{% endtrans %}</h5>
        <ul>
Skia's avatar
Skia committed
63
        {% for i in user.tokens.all() %}
64
65
66
67
            <li>{{ i }}</li>
        {% endfor %}
        </ul>
    {% endif %}
Skia's avatar
Skia committed
68
{% endmacro %}
Sli's avatar
Sli committed
69
70
71
72
73

{% macro delete_godfather(user, profile, godfather, is_father) %}
    {% if user == profile or user.is_root or user.is_board_member %}
    <a href="{{ url("core:user_godfathers_delete", user_id=profile.id, godfather_id=godfather.id, is_father=is_father) }}">{% trans %}Delete{% endtrans %}</a>
    {% endif %}
Skia's avatar
Skia committed
74
{% endmacro %}