{% 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="/newepisode" role="button">New Episode</a>
    </div>
  {% endif %}
  {% if not model.player_list %}
    There are no episodes.
  {% else %}
      <table class="table table-hover table-striped table-bordered">
        <thead>
          <tr>
            {% for prop, caption in model.columns %}
              <th scope="col" class="col-sm-auto text-center">{{ caption }}</th>
            {% endfor %}

            <th scope="col" class="col-sm-auto text-center"></th>
            {% if g.is_editor %}
                <th scope="col" class="col-sm-auto text-center"></th>
            {% endif %}
          </tr>
        </thead>
        <tbody>
          {% for ep in model.episodes %}
          <tr>
            {% for prop, _ in model.columns %}
              <td class="col-sm-auto text-center">{{ ep[prop] }}</td>
            {% endfor %}

            <a class="btn btn-default" href="/episodes/{{ ep['id'] }}">Show</a>
            {% if g.is_editor %}
                <td class="col-sm-auto text-center">
                  <a class="btn btn-default" href="/editepisode/{{ ep['id'] }}">Edit</a>
                </td>
            {% endif %}
          </tr>
        {% endfor %}
        </tbody>
      </table>

  {% endif %}
{% endblock %}