{% extends "base.html" %}
{% set active_page = "seasons" %}
{% block title %}{{ model.title }} {{ super() }}{% endblock %}

{% block content %}
<div class="container">
  <div class="row">
    {# Overview #}
    <div class="col-4">
      <div class="card">
        <div class="card-header text-center">
          {{ model.title }}
        </div>
        <div class="card-body">
          <h5 class="card-title">Infos</h5>
          {% for item in model.season_info %}
            <div class="card-text">
              <ul class="list-group list-group-flush">
                <li class="list-group-item">
                  <span class="font-weight-bold">{{ item }}:</span>
                  {{ model.season_info[item] }}
                </li>
              </ul>
            </div>
          {% endfor %}
        </div>
      </div>
    </div>

    {# Episode List #}
    <div class="col">
      <div class="card">
        <div class="card-header text-center">Episodes</div>
        <div class="card-body">
        {% if not model.episodes %}
          <div class="alert alert-info">No Episodes in this Season</div>
        {% else %}

          <table class="table table-striped table-bordered">
            <thead>
              <tr>
                <th scope="col" class="col-sm-auto text-center">#</th>
                <th scope="col" class="col-sm-auto text-center">Date</th>
                <th scope="col" class="col-sm-auto text-center">Title</th>

                <th scope="col" class="col-sm-auto text-center">View</th>
                {% if g.is_editor %}
                  <th scope="col" class="col-sm-auto text-center">Editor</th>
                {% endif %}
              </tr>
            </thead>
            <tbody>
              {% for item in model.episodes %}
              <tr>
                  <td class="col-sm-auto text-center">{{ item.code }}</td>
                  <td class="col-sm-auto text-center">{{ item.date }}</td>
                  <td class="col-sm-auto text-center">{{ item.title }}</td>

                  <td class="col-sm-auto text-center">
                    <a class="btn btn-default" href="{{ url_for('episode_detail', season_id = item.season_id, episode_id = item.id) }}">
                      <span class="fas fa-eye"></span></a>
                  </td>

                {% if g.is_editor %}
                  <td class="col-sm-auto text-center">
                    <a class="btn btn-default" href="{{ url_for('episode_edit', season_id = item.season_id, episode_id = item.id) }}">
                      <span class="fas fa-pencil-alt"></span>
                    </a>
                  </td>
                {% endif %}
              </tr>
            {% endfor %}
            </tbody>
          </table>

        {% endif %}
        </div>
      </div>
    </div>

  </div>
</div>
{% endblock %}