{% extends 'events/registration/emails/base_registration_details.html' %}
{% block subject_name %}{% endblock %}

{% block subject_message -%}
    {% trans title=event.title %}Registration for {{ title }}{% endtrans %}
{%- endblock %}

{% block registration_header -%}
    {% set event = registration.registration_form.event %}
    <p>{% trans name=registration.full_name %}Dear {{ name }},{% endtrans %}</p>
    <p>
        {% block registration_header_text %}
            {%- set strong %}<a href="{{ event.external_url }}"><strong>{% endset -%}
            {%- set endstrong %}</a></strong>{% endset -%}
            {% trans title=event.title, at_time=render_registration_info() -%}
                Thank you! Your registration for the event {{ strong }}{{ title }}{{ endstrong }} {{ at_time }}
                has been received.
            {%- endtrans %}
            {{ render_text_pending() }}
            {{ render_text_unpaid() }}
        {% endblock %}
    </p>
    {% block registration_header_state_message %}
        {% if registration.state.name == 'pending' %}
            {{ registration.registration_form.message_pending | markdown }}
        {% elif registration.state.name == 'unpaid' %}
            {{ registration.registration_form.message_unpaid | markdown }}
        {% elif registration.state.name == 'complete' %}
            {{ registration.registration_form.message_complete | markdown }}
        {% endif %}
    {% endblock %}
{%- endblock %}

{% block registration_footer %}
    <p>
        {% trans %}To manage your registration follow this link:{% endtrans %}
        <a href="{{ url_for('event_registration.display_regform', registration.locator.registrant, _external=true) }}">
            {% trans %}Manage my registration{% endtrans %}
        </a>
    </p>
{% endblock %}


{% macro render_registration_info() %}
    {% if event.start_dt_local.date() == event.end_dt_local.date() %}
        ({{ event.start_dt|format_datetime(timezone=event.tzinfo) }}
        -
        {{ event.end_dt|format_time(timezone=event.tzinfo) }})
    {% else %}
        ({{ event.start_dt|format_datetime(timezone=event.tzinfo) }}
        -
        {{ event.end_dt|format_datetime(timezone=event.tzinfo) }})
    {% endif %}
{% endmacro %}


{% macro render_rejection_reason() %}
    {% if registration.state.name == 'rejected' and registration.rejection_reason %}
        <br>{% trans %}Rejection reason:{% endtrans %} {{ registration.rejection_reason }}<br>
    {% endif %}
{% endmacro %}


{% macro render_text_pending() %}
    {% if registration.state.name == 'pending' %}
        {% trans -%}Please note that this event requires manual approval.{%- endtrans %}
        {% trans -%}You will be notified when the registration process is complete.{%- endtrans %}
    {% endif %}
{% endmacro %}


{% macro render_text_unpaid() %}
    {% if registration.state.name == 'unpaid' %}
        {% trans link='<a href="%s">'|format(registration.display_regform_url)|safe, endlink='</a>'|safe -%}
            Please proceed to the checkout {{ link }}here{{ endlink }} in order to complete it.
        {%- endtrans %}
    {% endif %}
{% endmacro %}
