{% macro _render_ticket_dropdown() %}
    {% if registrations_with_tickets %}
        <div class="group">
            <button class="i-button icon-file-download js-dropdown arrow" data-toggle="dropdown">
                {%- trans %}Get ticket{% endtrans -%}
            </button>
            <ul class="i-dropdown">
                {% for registration in registrations_with_tickets -%}
                    {% set regform = registration.registration_form %}
                    <li>
                        <a href="{{ url_for('event_registration.ticket_download', regform) }}"
                           class="icon-file-pdf"
                           title="{% trans title=regform.title -%}Download ticket for the '{{ title }}' registration form{%- endtrans %}">
                            {{ regform.title }} - PDF
                        </a>
                    </li>
                    {% if regform.is_google_wallet_available %}
                        <li>
                            <a href="{{ url_for('event_registration.ticket_google_wallet', regform) }}"
                               class="icon-ticket"
                               title="{% trans title=regform.title -%}Add ticket for the '{{ title }}' registration form to Google Wallet{%- endtrans %}">
                                {{ regform.title }} - {% trans %}Google Wallet{% endtrans %}
                            </a>
                        </li>
                    {% endif %}
                    {% if regform.is_apple_wallet_available %}
                        <li>
                            <a href="{{ url_for('event_registration.ticket_apple_wallet', regform) }}"
                               class="icon-ticket"
                               title="{% trans title=regform.title -%}Download ticket for the '{{ title }}' registration form for Apple Wallet/Passbook{%- endtrans %}">
                                {{ regform.title }} - {% trans %}Apple Pass/Passbook{% endtrans %}
                            </a>
                        </li>
                    {% endif %}
                {%- endfor %}
            </ul>
        </div>
    {% endif %}
{% endmacro %}

{% if not g.static_site %}
    {% set single_regform = regforms|first if regforms|length == 1 else none %}
    {% set is_form_moderated = single_regform.moderation_enabled if single_regform %}
    {% set is_number_published = single_regform.publish_registration_count if single_regform %}
    <div class="action-box highlight">
        <div class="section">
            <span class="icon icon-ticket"></span>
            <div class="text">
                <div class="label">
                    {% block form_label_title %}
                        {%- if is_form_moderated %}
                            {%- trans %}Application{% endtrans %}
                        {%- else %}
                            {%- trans %}Registration{% endtrans %}
                        {%- endif -%}
                    {% endblock %}
                </div>
                {% if user_registrations %}
                    {% if user_registrations < regforms|length %}
                        <div>
                            {% trans %}
                                You are registered for this event, but there are more registration forms available.
                            {% endtrans %}
                        </div>
                    {% else %}
                        <div>{% trans %}You are registered for this event.{% endtrans %}</div>
                    {%  endif %}
                {% else %}
                    <div>
                        {% block form_label_description %}
                            {%- if is_form_moderated %}
                                {%- trans %}Application for this event is currently open.{% endtrans %}
                            {%- else %}
                                {%- trans %}Registration for this event is currently open.{% endtrans %}
                            {%- endif -%}
                        {% endblock %}
                    </div>
                {% endif %}
            </div>
            <div class="toolbar">
                {% if is_number_published %}
                    <span class="i-label icon-user" title="{% trans %}Total registrations{% endtrans %}">
                        {{- single_regform.active_registration_count }}
                        {%- if single_regform.registration_limit %}
                            / {{ single_regform.registration_limit }}
                        {%- endif -%}
                    </span>
                {%  endif %}
                {% if user_registrations %}
                    {{ _render_ticket_dropdown() }}
                    <a class="i-button next highlight"
                       href="{{ url_for('event_registration.display_regform', single_regform) if single_regform else
                                url_for('event_registration.display_regform_list', event) }}">
                        {% trans %}See details{% endtrans %}
                    </a>
                {% else %}
                    <a href="{{ url_for('event_registration.display_regform_list', event) }}"
                       class="i-button next highlight">
                        {% block register_now_button_text %}
                            {%- if is_form_moderated %}
                                {%- trans %}Apply now{% endtrans %}
                            {%- else %}
                                {%- trans %}Register now{% endtrans %}
                            {%- endif -%}
                        {% endblock %}
                    </a>
                {% endif %}
            </div>
        </div>
    </div>
{% endif %}
