{% extends 'events/papers/_base.html' %}

{% from 'events/management/_lists.html' import render_displayed_entries_fragment %}
{% from 'events/papers/display/_common.html' import render_cfp_infoline %}
{% from 'events/papers/display/_paper_list.html' import render_user_papers_list %}
{% from 'events/reviews/_common.html' import render_timeline_section %}
{% from 'message_box.html' import message_box %}

{% block content %}
    <div class="call-for-papers">
        {% set cfp = event.cfp %}
        {% if cfp.start_dt %}
            {{ render_timeline_section(cfp) }}
        {% endif %}
        {% if cfp.announcement %}
            <section>
                <div class="cfp-announcement">{{ cfp.announcement }}</div>
            </section>
        {% endif %}
        {% if contributions or not cfp.can_submit_proceedings(session.user) %}
            <section class="cfp-infoline-section">
                {{ render_cfp_infoline(event, cfp, contributions) }}
            </section>
        {% endif %}
        {% if event.paper_templates %}
            <section>
                <div class="header">
                    <div class="header-row">
                        <h3>{% trans %}Paper templates{% endtrans %}</h3>
                    </div>
                </div>
                <ul class="template-list">
                    {% for tpl in event.paper_templates|sort(attribute='id')|sort(attribute='name') %}
                        <li>
                            <a href="{{ url_for('.download_template', tpl) }}"
                               class="attachment {{ icon_from_mimetype(tpl.content_type, 'icon-file') }}">
                                <span>{{ tpl.name }}</span>
                            </a>
                            {% if tpl.description %}
                                <i class="info icon-info" title="{{ tpl.description }}"></i>
                            {% endif %}
                        </li>
                    {% endfor %}
                </ul>
            </section>
        {% endif %}
        <section>
            <div class="header">
                <div class="header-row">
                    <h3>{% trans %}My papers{% endtrans %}</h3>
                    <div class="toolbar thin">
                        <div class="group">
                            <div id="filter-statistics" class="group">
                                {{- render_displayed_entries_fragment(papers|length, papers|length) -}}
                            </div>
                            <div class="group">
                                <span class="i-button label icon-search"></span>
                                <input type="text" id="search-input" placeholder="{% trans %}Enter #id or search string{% endtrans %}">
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            {% if papers %}
                {{ render_user_papers_list(event, papers) }}
            {% else %}
                {% call message_box('info', fixed_width=true) %}
                    {% trans %}You haven't submitted any paper.{% endtrans %}
                {% endcall %}
            {% endif %}
            <div id="filter-placeholder"></div>
        </section>
    </div>
    <script>
        setupCallForPapersPage({
            hasPapers: {{ papers|bool|tojson }}
        });
    </script>
{% endblock %}
