{% macro user_profile_link(user) -%} {{ user.get_display_name() }} {%- endmacro %} {% macro user_profile_link_short_name(user) -%} {{ user.get_short_name() }} {%- endmacro %} {% macro user_link_with_pict(user) -%} {{ user.get_mini_item()|safe }} {%- endmacro %} {% macro link_news_logo(news) -%} {%- if news.club.logo -%} {{ news.club.logo.url }} {%- else -%} {{ static("com/img/news.png") }} {%- endif -%} {%- endmacro %} {% macro user_mini_profile(user) %}
{{ user.get_full_name() }}
{% if user.nick_name %}
« {{ user.nick_name }} »
{% endif %} {% if user.pronouns %}
{{ user.pronouns }}
{% endif %} {% if user.date_of_birth %}
{{ user.date_of_birth|date("d/m/Y") }} ({{ user.age }})
{% endif %}
{% if user.promo and user.promo_has_logo() %}
Promo {{ user.promo }}
{% endif %}
{% if user.profile_pict %} {% trans %}Profile{% endtrans %} {% else %} {% trans %}Profile{% endtrans %} {% endif %}
{%- endmacro %} {% macro user_subscription(user) %} {% trans subscription_end=user.subscriptions.order_by('subscription_end').last().subscription_end %}Subscribed until {{ subscription_end }}{% endtrans %}
{% trans %}Account number: {% endtrans %}{{ user.customer.account_id }}
{%- endmacro %} {% macro show_tokens(user) %} {% if user.tokens.exists() %}
{% trans %}Tokens{% endtrans %}
{% endif %} {% endmacro %} {% macro paginate_alpine(page, nb_pages) %} {# Add pagination buttons for ajax based content with alpine Notes: This can only be used in the scope of your alpine datastore Notes: You might need to listen to the "popstate" event in your code to update the current page you are on when the user goes back in it's browser history with the back arrow Parameters: page (str): name of the alpine page variable in your datastore nb_page (str): call to a javascript function or variable returning the maximum number of pages to paginate #} {% endmacro %} {% macro paginate_jinja(request, current_page, paginator) %} {# Add pagination buttons for pages without Alpine. This must be coupled with a view that handles pagination with the Django Paginator object. Parameters: request (django.http.request.HttpRequest): the current django request current_page (django.core.paginator.Page): the current page object paginator (django.core.paginator.Paginator): the paginator object #} {{ paginate_server_side(request, current_page, paginator, "") }} {% endmacro %} {% macro paginate_htmx(request, current_page, paginator, htmx_target="#content") %} {# Add pagination buttons for pages without Alpine but supporting fragments. This must be coupled with a view that handles pagination with the Django Paginator object and supports fragments. The replaced fragment will be #content so make sure you are calling this macro inside your content block. Parameters: request (django.http.request.HttpRequest): the current django request current_page (django.core.paginator.Page): the current page object paginator (django.core.paginator.Paginator): the paginator object htmx_target (string): htmx target selector (default '#content') #} {{ paginate_server_side(request, current_page, paginator, htmx_target) }} {% endmacro %} {% macro paginate_server_side(request, current_page, paginator, htmx_target) %} {% endmacro %} {% macro select_all_checkbox(form_id) %} {% endmacro %} {% macro update_notifications(messages, clear) %} {# Update notification area from new messages sent by django backend This is useful when performing fragment swaps to keep messages up to date Without this, the fragment would need to take control of the notification area and this would be an issue when having more than one fragment Parameters: messages: messages from django.contrib clear : optional boolean that controls if notifications should be cleared first. True is the default #} {% set clear = clear|default(true) %} {% if messages %}
{% endif %} {% endmacro %} {% macro querystring(request) %} {%- set qs = request.GET.copy() -%} {%- do qs.update(kwargs) -%} {{- qs | urlencode -}} {% endmacro %}