{% extends "cruds/base.html" %}
{% load i18n %}
{% load crud_tags %}

{% block body %}
  <h1>{{ model_verbose_name }}</h1>

  {% if url_create %}
    <p>
      <a href="{{ url_create }}" class="btn btn-default">{% trans "New" %}</a>
    </p>
  {% endif %}

  {% if object_list %}

  <table class="table">
    <thead>
      <tr>
        {% for field, field_name in fields.items %}
          <th>{{ field_name }}</th>
        {% endfor %}
        <th></th>
      </tr>
    </thead>
    <tbody>
      {% for object in object_list %}
        <tr>
          {% for field in fields.keys %}
          <td>
            {{ object|format_value:field }}
          </td>
          {% endfor %}
          <td>
            {% crud_url object "detail" as url %}
            {% if url %}
              <a href="{{ url }}">{% trans "View" %}</a>
            {% endif %}
          </td>
        </tr>
      {% endfor %}
    </tbody>
  </table>

  {% else %}
    <p>{% trans "List is empty" %}</p>
  {% endif %}
{% endblock %}
