{% extends 'admin.html' %}
{% from '_macros.html' import render_pagination %}
    {% macro render_obj_table(headings,objs) %}
        <table class="table table-hover">
            <thead>
                <tr>
                    <th><input class="checkbox" type="checkbox" id="check-all" /></th>
                    {% for itm in headings %}
                        <th>{{itm}}</th>
                    {% endfor %}
                    {% if is_page(obj) %}
                        <th>View on site</th>
                    {% endif %}
                    <th>show</th>
                    <th>edit</th>
                </tr>
            </thead>
            <tbody>
                {% for obj in objs %}
                    <tr>
                        <td><input class="checkbox" type="checkbox" id="{{ obj.id }}" /></td>
                        {% for itm in columns %}
                            <td>{{obj|attr(itm)}}</td>
                        {% endfor %}
                        {% if is_page(obj) %}
                                <td>
                                <a class="btn btn-default" href="{{ obj._get_page_url() }}">
                                    <span class="glyphicon glyphicon-eye-open">
                                    </span>
                                </a>
                            </td>
                        {% endif %}
                    <td>
                        <a class="btn btn-primary" href="{{ obj.absolute_url }}">
                        
                                    <span class="glyphicon glyphicon-picture">
                                    </span>
                                </a>
                            </td>
                            <td>
                                <a class="btn btn-danger" href="{{ obj._get_edit_url() }}">
                                    <span class="glyphicon glyphicon-pencil">
                                    </span>
                                </a>
                            </td>
                        </tr>
                        {% endfor %}
                    </tbody>
                </table>
    {% endmacro %}
    {% macro render_admin_nav(objs) %}
        {% set create_url = '#' %}
        {% if objs|count > 0 %}
            {% if objs[0]._get_create_url %}
               {% set create_url = objs[0]._get_create_url() %}
            {% endif %}
        {% endif %}
        <ul class="nav nav-tabs" role="tablist">
            <li class="active"><a href="#">List</a></li>
            <li><a href="{{ create_url }}">Create</a></li>
            <li><a href="#">Mass Edit</a></li>
        </ul>
    {% endmacro %}
    {% block content %}
    {% if objs %}
        {{ render_admin_nav(objs) }}
        {% if headings is defined and objs is defined %}
            {{ render_obj_table(headings,objs) }}
        {% endif %}
        {% if pagination %}
            {{ render_pagination(pagination) }}
        {% endif %}
    {% endif %}
    {% endblock %}

