{% load urlreplace %}
{% load naturalduration %}

<table class="table table-striped table-sm">
    <thead>
        <tr>
            <th scope="col">Latest</th>
            <th scope="col">Title</th>
            <th scope="col">Time</th>
            <th scope="col">Scrobbles</th>
            <th scope="col">Complete</th>
            <th scope="col">Start</th>
            <th scope="col">Finish</th>
        </tr>
    </thead>
    <tbody>
        {% for obj in object_list %}
        {% if obj.title %}
        {% with last=obj.scrobble_set.last %}
        <tr>
            <td><a href="{{last.get_absolute_url}}">{{last.local_timestamp}}
            <td><a href="{{obj.get_absolute_url}}">{{obj}}</a></td>
            {% if request.user.is_authenticated %}
            <td>{% if last.long_play_seconds %}{{ last.long_play_seconds|natural_duration }}{% elif last.elapsed_time %}{{ last.elapsed_time|natural_duration }}{% endif %}</td>
            <td>{{obj.scrobble_count}}</td>
            <td>{% if obj.scrobble_set.last.long_play_complete == True %}Yes{% else %}No{% endif %}</td>
            <td><a type="button" class="btn btn-sm btn-primary" href="{{obj.start_url}}">Scrobble</a></td>
            <td><a type="button" class="btn btn-sm btn-warning" href="{{obj.get_longplay_finish_url}}">Finish</a></td>
            {% endif %}
        </tr>
        {% endwith %}
        {% endif %}
        {% endfor %}
    </tbody>
</table>

<p class="pagination">
    <span class="page-links">
        {% if page_obj.has_previous %}
            <a href="?{% urlreplace page=page_obj.previous_page_number %}">prev</a>
        {% endif %}
            <span class="page-current">
                Page {{ page_obj.number }} of {{ page_obj.paginator.num_pages }}
            </span>
        {% if page_obj.has_next %}
            <a href="?{% urlreplace page=page_obj.next_page_number %}">next</a>
        {% endif %}
    </span>
</p>
