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

{% block page %}
  {% if g.is_editor %}
    <div class="btn-toolbar" role="toolbar">
      <a class="btn btn-primary" href="{{ url_for('new_drink') }}" role="button">
        <span class="fas fa-plus"></span> Drink
      </a>
    </div>
  {% endif %}
{% if not model.drinks %}
    There are no drinks.
  {% 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 %}

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

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

  {% endif %}
{% endblock %}