{% extends "orga/base.html" %}
{% load review_score %}
{% load i18n %}
{% load rules %}

{% block content %}

{% has_perm 'orga.change_settings' request.user request.event as can_see_settings %}
{% has_perm 'orga.view_reviews' request.user request.event as can_review %}
<div class="dashboard-list">
{% if request.event.reviews.count %}
    <div class="dashboard-block">
        <h1>{{ request.event.reviews.count  }}</h1>
        <div class="dashboard-description">
            {% trans "total reviews" %}
        </div>
    </div>
{% else %}
    <div class="dashboard-block">
        <h1>{% trans "Zero" %}</h1>
        <div class="dashboard-description">
            {% trans "total reviews" %}
        </div>
    </div>
{% endif %}
    <{% if can_see_settings %}a href="{{ request.event.orga_urls.review_settings }}"{% else %}div{% endif %} class="dashboard-block">
        <h1>{{ reviewers }}</h1>
        <div class="dashboard-description">
            {% trans "total reviewers" %}
        </div>
    </{% if can_see_settings %}a{% else %}div{% endif %}>
{% if can_review and next_submission %}
    <a class="dashboard-block" href="{{ next_submission.orga_urls.reviews }}">
        <h1>{% trans "Review!" %}</h1>
        <div class="dashboard-description">
        {% blocktrans with count=missing_reviews.count trimmed %}
                Click here to submit more reviews, there are still {{ count }} missing!
            {% endblocktrans %}
        </div>
    </a>
{% elif can_review %}
    <a class="dashboard-block" href="{{ next_submission.orga_urls.reviews }}">
        <h1>{% trans "Bravo!!" %}</h1>
        <div class="dashboard-description">
            {% trans "There are no submissions left to review!" %}
        </div>
    </a>
{% endif %}
</div>


<table class="table table-condensed review-table table-responsive-md">
    <thead>
        <tr>
            <th>{% trans "Score" %} <i class="fa fa-caret-down"></i></th>
            <th>{% trans "Reviews" %}</th>
            <th>{% trans "Title" %}</th>
            <th>{% trans "State" %}</th>
            <th>{% trans "Speakers" %}</th>
        </tr>
    </thead>
    <tbody>
    {% for submission in submissions %}
        {% has_perm 'submission.review_submission' request.user submission as can_review_submission %}
        {% has_perm 'submission.reject_submission' request.user submission as can_reject_submission %}
        <tr class="{{ submission.state }}">
            <td>
                {% if submission.avg_score != None %}
                    {% review_score submission %}
                {% else %}
                    –
                {% endif %}
            </td>
            <td>
                {% if submission.reviews.all.count %}
                    {{ submission.reviews.all.count }}
                {% else %}
                    –
                {% endif %}
            </td>
            <td>
                <a href="{% if can_review_submission %}{{ submission.orga_urls.reviews }}{% else %}{{ submission.orga_urls.base }}{% endif %}">
                    {{ submission.title }}
                </a>
            </td>
            <td>
                {% if can_reject_submission %}
                    <a class="btn btn-primary btn-xs" href="{{ submission.orga_urls.accept }}">{% trans "Accept" %}</a>
                    <a class="btn btn-danger btn-xs" href="{{ submission.orga_urls.reject }}">{% trans "Reject" %}</a>
                {% else %}
                    {% include "cfp/event/fragment_state.html" with state=submission.state %}
                {% endif %}
            </td>
            <td>{{ submission.display_speaker_names }}
        </tr>
    {% empty %}
        <tr>
            {% trans "You don't seem to have any reviews at the moment." %}
        </tr>
    {% endfor %}
    </tbody>
</table>
{% include "orga/pagination.html" %}
{% endblock %}
