{% extends base_change_form_template %}
{% comment %}

  This template is automatically selected by django-fluent-pages for the "blogpage" model.
  It displays the associated blog entries which the current "BlogPage" model displays.

{% endcomment %}
{% load i18n fluent_blogs_tags fluent_blogs_admin_tags static %}

{% block extrahead %}{{ block.super }}
    <style type="text/css">
      #published-entries .paginator {
          margin: 0;
          padding: 5px;  /* plus 5px from td */
      }
    </style>
{% endblock %}

{% block after_first_fieldset %}
  {% get_static_prefix as STATIC_URL %}{# Can't expect Django project to use context processors #}

  {% if change %}
    <div class="inline-group" id="published-entries">
        <div class="tabular inline-related">
            <fieldset class="module">
                <h2>
                    {% trans "Latest blog entries at this page" %}
                </h2>

                {# TODO: when a site filters objects by overriding .published(), the objects here still have a link in the admin. #}
                <table>
                    <thead>
                        <tr>
                            <th>{% trans "Blog entry" %}</th>
                            <th width="80">{% trans "status" as t %}{{ t|title }}</th>
                            <th width="160">{% trans "publication date" as t %}{{ t|title }}</th>
                            <th width="120">{% trans "actions" as t %}{{ t|title }}</th>
                        </tr>
                    </thead>
                    <tbody>
                        {% for entry in original.entries.all|slice:":15" %}
                        <tr class="{% cycle 'row1' 'row2' %}">
                            <td>
                                <span class="inline_label">
                                    <a href="{% blog_entry_admin_change_url entry %}" target="_blank">{{ entry }}</a>
                                </span>
                            </td>
                            <td>{% status_column entry %}</td>
                            <td class="nowrap">{{ entry.publication_date }}</td>
                            <td class="nowrap">{% actions_column entry %}</td>
                        </tr>
                        {% empty %}
                            <tr>
                              <td>
                                  <p class="paginator">
                                      0 {% trans "Blog entries" %}
                                  </p>
                            </tr>
                        {% endfor %}
                    </tbody>
                </table>
            </fieldset>
        </div>
    </div>

  {% endif %}

{% endblock %}
