{% extends '_layout.html'|pjax:request %}
{% load i18n %}

{% block page_title %}{{ block.super }} | {{ item.name }}{% endblock %}

{% block main_content %}
<div class="container">
    {% if USER_IS_STAFF and USER_CONFIG.show_admin_links %}
    <div class="text-right">
        <a class="btn btn-info" href="{% url 'admin:manga_series_change' item.pk %}">{% trans "Edit in admin" %}</a>
    </div>
    <br />
    {% endif %}
    <div class="row">
        <div class="col-md-3">
            <div class="panel panel-warning">
                {% if item.last_volume_cover %}
                <div class="panel-body text-center">
                    <img src="{{ item.last_volume_cover.url }}" class="max-width-80" />
                </div>
                {% endif %}
                <ul class="list-group">
                    {% if item.for_review and user.is_staff %}
                    <a class="list-group-item list-group-item-warning text-center">
                        {% trans "Requires review" %}
                    </a>
                    {% endif %}
                    <li class="list-group-item">
                        <strong>{% trans "Status" %}</strong>
                        {% if item.finished %}
                        <span class="badge badge-success">{% trans "Finished" %}
                        {% else %}
                        <span class="badge badge-warning">{% trans "Open" %}
                        {% endif %}
                    </li>
                </ul>
            </div>
            {% if item.art.count %}
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h2 class="panel-title text-center">{% trans "Art" %}</h2>
                </div>
                <ul class="list-group">
                    {% for person in item.art.all %}
                    <li class="list-group-item">
                        {{ person.name }}
                    </li>
                    {% endfor %}
                </ul>
            </div>
            {% endif %}

            {% if item.story.count %}
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h2 class="panel-title text-center">{% trans "Story" %}</h2>
                </div>
                <ul class="list-group">
                    {% for person in item.story.all %}
                    <li class="list-group-item">
                        {{ person.name }}
                    </li>
                    {% endfor %}
                </ul>
            </div>
            {% endif %}

            <div class="panel panel-default">
                <div class="panel-heading">
                    <h2 class="panel-title text-center">{% trans "Publishers" %}</h2>
                </div>
                <ul class="list-group">
                    {% if item.original_publisher %}
                    <li class="list-group-item">
                        {% trans "Original publisher" %}:
                        {% if publisher.slug %}
                        <a href="{% url 'publishers.detail' item.original_publisher.pk item.original_publisher.slug %}" data-pjax>{{ item.original_publisher.name }}</a>
                        {% else %}
                        <a href="{% url 'publishers.detail' item.original_publisher.pk %}" data-pajax>{{ item.original_publisher.name }}</a>
                        {% endif %}
                    </li>
                    {% endif %}
                    {% if item.publishers %}
                        {% for publisher in item.publishers %}
                        <li class="list-group-item">
                            <span class="badge badge-default">{{ publisher.series_volumes.count }}</span>
                            {% if publisher.slug %}
                            <a href="{% url 'publishers.detail' publisher.pk publisher.slug %}" data-pjax>{{ publisher.name }}</a>
                            {% else %}
                            <a href="{% url 'publishers.detail' publisher.pk %}" data-pajax>{{ publisher.name }}</a>
                            {% endif %}
                        </li>
                        {% endfor %}
                    {% endif %}
                </ul>
            </div>
        </div>
        <div class="col-md-9">
            <div class="panel panel-primary">
                <div class="panel-heading">
                    <h1 class="panel-title panel-title-alt text-center">{{ item.name }}</h1>
                </div>
            </div>
            {% if item.summary %}
            <div class="well">
                {{ item.summary|linebreaks }}
            </div>
            {% endif %}
            <div class="row">
                {% for volume in item.volumes_by_publisher.all %}
                <div class="col-sm-3" data-pjax-container="v{{ volume.pk }}">
                    {% include "manga/series/includes/volume.html" with volume=volume user=user %}
                </div>
                {% if forloop.counter|divisibleby:4 %}
                </div>
                <div class="row">
                {% endif %}
                {% endfor %}
            </div>
        </div>
    </div>
</div>
{% endblock %}
