{% extends "base.html" %}
{% set active_page = "seasons" %}
{% block title %}{{ model.season_code }} - Episodes{% endblock %}

{% block content %}
  {% if g.is_editor %}
    <div class="btn-toolbar" role="toolbar">
      <a class="btn btn-primary" href="{{ url_for("episode_new", season_id = model.season_id)}}" role="button">
        <span class="fas fa-plus"></span>Episode
      </a>
    </div>
  {% endif %}
  {% if not model.player_list %}
    <div class="alert alert-info">There are no episodes.</div>
  {% else %}
      <table class="table table-hover 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">Title</th>
            <th scope="col" class="col-sm-auto text-center">Date</th>
            <th scope="col" class="col-sm-auto text-center">From - To</th>
            <th scope="col" class="col-sm-auto text-center">Playtime</th>

            <th scope="col" class="col-sm-auto text-center">Stats</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.title }}</td>
            <td class="col-sm-auto text-center">{{ item.date }}</td>
            <td class="col-sm-auto text-center">{{ item.start }} - {{ item.end }}</td>
            <td class="col-sm-auto text-center">{{ item.duration }}</td>

            <td class="col-sm-auto text-center">
                  <a class="btn btn-default" href="{{ url_for("episode_stats", 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", episode_id = item.id, season_id = model.season_id) }}">
                    <span class="fas fa-pencil-alt"></span>
                  </a>
                </td>
            {% endif %}
          </tr>
        {% endfor %}
        </tbody>
      </table>

  {% endif %}
{% endblock %}