{% extends "cfp/event/base.html" %}
{% load compress %}
{% load html_signal %}
{% load i18n %}
{% load rich_text %}
{% load rules %}
{% load static %}

{% block title %}{% translate "Your proposals" %} :: {% endblock %}

{% block content %}
    {% if information %}
        <h2>{% translate "Important Information" %}</h2>
        {% for info in information %}
            <h4>{{ info.title }}</h4>
            {{ info.text|rich_text }}
            {% if info.resource %}
                <a href="{{ info.resource.url }}"><i class="fa fa-file-o"></i> {{ info.resource.name }}</a>
            {% endif %}
            {% if not forloop.last %}<hr>{% endif %}
        {% endfor %}
    {% endif %}
    {% html_signal "pretalx.cfp.signals.html_above_submission_list" sender=request.event request=request %}
    {% if drafts %}
        <h2>{% translate "Your drafts" %}</h2>
        <div class="table-responsive">
            <table class="table table-sm table-flip">
                <thead>
                    <tr>
                        <th>{% translate "Title" %}</th>
                        <th></th>
                    </tr>
                </thead>
                <tbody>
                    {% for submission in drafts %}
                        <tr>
                            <td>
                                <a href="{{ submission.urls.user_base }}">
                                    {{ submission.title }}
                                </a>
                            </td>
                            <td class="flip text-right">
                                {% if submission.review_code %}
                                    <button data-destination="{{ submission.urls.review.full }}"
                                            class="btn btn-sm btn-info"
                                            data-toggle="tooltip"
                                            data-placement="top"
                                            title="{% translate 'Copy code for review' %}"
                                            target="_blank" rel="noopener">
                                        <i class="fa fa-link"></i>
                                    </button>
                                {% endif %}
                                <a href="{{ submission.urls.user_base }}" class="btn btn-sm btn-success">
                                    <i class="fa fa-{{ submission.editable|yesno:'edit,eye' }}"></i>
                                </a>
                            </td>
                        </tr>
                    {% endfor %}
                </tbody>
            </table>
        </div>
    {% endif %}
    <h2>{% translate "Your proposals" %}</h2>
    {% if submissions %}
        <div class="table-responsive">
            <table class="table table-sm table-flip">
                <thead>
                    <tr>
                        <th>{% translate "Title" %}</th>
                        <th>{% translate "State" %}</th>
                        <th></th>
                        <th></th>
                    </tr>
                </thead>
                <tbody>
                    {% for submission in submissions %}
                        <tr>
                            <td>
                                <a href="{{ submission.urls.user_base }}">
                                    {{ submission.title }}
                                </a>
                            </td>
                            <td>
                                {% include "cfp/event/fragment_state.html" with state=submission.user_state %}
                            </td>
                            <td class="flip text-right">
                                {% if submission.public_slots %}
                                    <a href="{{ submission.urls.public }}">
                                        {% for talk in submission.public_slots %}
                                            {{ talk.start|date:DAY_MONTH_DATE_FORMAT }}, {{ talk.start|date:"TIME_FORMAT" }}–{{ talk.end|date:"TIME_FORMAT" }}, {{ talk.room.name }} {% if not forloop.last %}<br>{% endif %}
                                        {% endfor %}
                                    </a>
                                {% endif %}
                            </td>
                            <td class="flip text-right">
                                {% if submission.review_code %}
                                    <button data-destination="{{ submission.urls.review.full }}"
                                            class="btn btn-sm btn-info"
                                            data-toggle="tooltip"
                                            data-placement="top"
                                            title="{% translate 'Copy code for review' %}"
                                            target="_blank" rel="noopener">
                                        <i class="fa fa-link"></i>
                                    </button>
                                {% endif %}
                                <a href="{{ submission.urls.user_base }}" class="btn btn-sm btn-info">
                                    <i class="fa fa-{{ submission.editable|yesno:'edit,eye' }}"></i>
                                </a>
                                {% if submission.state == 'accepted' %}
                                    <a href="{{ submission.urls.confirm }}"
                                       class="btn btn-sm btn-success">
                                        <i class="fa fa-check"></i> {% translate "Confirm" %}
                                    </a>
                                {% endif %}
                                {% if request.event.feature_flags.use_feedback and submission.does_accept_feedback %}
                                    <a href="{{ submission.urls.feedback }}"
                                       class="btn btn-sm btn-info">
                                        <i class="fa fa-comments"></i> {% translate "Feedback" %}{% if submission.feedback.count %}  ({{ submission.feedback.count }}){% endif %}
                                    </a>
                                {% endif %}
                            </td>
                        </tr>
                    {% endfor %}
                </tbody>
            </table>
        </div>
        <p>
            {% if request.event.cfp.is_open %}
                <a class="btn btn-success btn-lg"
                   href="{{ request.event.urls.submit }}">
                    {% translate "Create a new proposal" %}
                </a>
            {% endif %}
        </p>
    {% else %}
        <p class="text-center">
            {% translate "It seems like you haven't submitted anything to this event yet." %}
        </p>
        <p class="text-center">
            {% translate "If you did, maybe you used a different account? Check your emails!" %}
        </p>
        {% if request.event.cfp.is_open %}
            <p class="text-center">
                {% translate "If you did not, why not go ahead and create a proposal now? We'd love to hear from you!" %}
            </p>
            <p class="text-center">
                <a class="btn btn-success btn-lg btn-block"
                   href="{{ request.event.urls.submit }}">
                    {% translate "Submit something now!" %}
                </a>
            </p>
        {% endif %}
    {% endif %}
    {% compress js %}
        <script defer src="{% static "common/js/copy.js" %}"></script>
    {% endcompress %}
{% endblock %}
