{% 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 gen_news_metatags(news) -%} {%- endmacro %} {% macro facebook_share(news) -%} {% trans %}Share on Facebook{% endtrans %} {%- endmacro %} {% macro tweet(news) -%} {% trans %}Tweet{% endtrans %} {%- 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_slots(user) %} {% if user.slots.filter(start_date__gte=timezone.now()).exists() %}
{% trans %}Slot{% endtrans %}
{% endif %} {% endmacro %} {% macro show_tokens(user) %} {% if user.tokens.exists() %}
{% trans %}Tokens{% endtrans %}
{% endif %} {% endmacro %} {% macro delete_godfather(user, profile, godfather, is_father) %} {% if user == profile or user.is_root or user.is_board_member %} {% trans %}Delete{% 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(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: current_page (django.core.paginator.Page): the current page object paginator (django.core.paginator.Paginator): the paginator object #} {{ paginate_server_side(current_page, paginator, False) }} {% endmacro %} {% macro paginate_htmx(current_page, paginator) %} {# 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: current_page (django.core.paginator.Page): the current page object paginator (django.core.paginator.Paginator): the paginator object #} {{ paginate_server_side(current_page, paginator, True) }} {% endmacro %} {% macro paginate_server_side(current_page, paginator, use_htmx) %} {% endmacro %} {% macro select_all_checkbox(form_id) %} {% endmacro %} {% macro tabs(tab_list, attrs = "") %} {# Tab component Parameters: tab_list: list[tuple[str, str]] The list of tabs to display. Each element of the list is a tuple which first element is the title of the tab and the second element its content attrs: str Additional attributes to put on the enclosing div Example: A basic usage would be as follow : {{ tabs([("title 1", "content 1"), ("title 2", "content 2")]) }} If you want to display more complex logic, you can define macros and use those macros in parameters : {{ tabs([("title", my_macro())]) }} It's also possible to get and set the currently selected tab using Alpine. Here, the title of the currently selected tab will be displayed. Moreover, on page load, the tab will be opened on "tab 2".

{{ tabs([("tab 1", "Hello"), ("tab 2", "World")], "x-model=current_tab") }}
If you want to have translated tab titles, you can enclose the macro call in a with block : {% with title=_("title"), content=_("Content") %} {{ tabs([(tab1, content)]) }} {% endwith %} #}
{% for title, _ in tab_list %} {% endfor %}
{% for title, content in tab_list %}
{{ content }}
{% endfor %}
{% endmacro %}