Add scrobble to locations list

This commit is contained in:
2023-11-25 15:39:27 +01:00
parent 22ad340d43
commit 9ba9319885
2 changed files with 154 additions and 1 deletions

View File

@ -68,7 +68,7 @@
<tbody>
{% for location in object_list %}
<tr>
<td>{{location.scrobbles.count}}</td>
<td>{{location.scrobble_set.count}}</td>
<td><a href="{{location.get_absolute_url}}">{{location.lat}}x{{location.lon}}</a></td>
</tr>
{% endfor %}

View File

@ -0,0 +1,153 @@
{% extends "base_list.html" %}
{% load humanize %}
{% block title %}{{name}}{% endblock %}
{% block lists %}
<div class="row">
<div class="col-md">
<div class="tab-content" id="artistTabContent">
<div class="table-responsive">
<table class="table table-striped table-sm">
<thead>
<tr>
<th scope="col">Rank</th>
<th scope="col">Artist</th>
<th scope="col">Scrobbles</th>
</tr>
</thead>
<tbody>
{% for scrobble in object_list %}
<tr>
<td>{{scrobble.timestamp|naturaltime}}</td>
<td><a href="{{scrobble.media_obj.get_absolute_url}}">{{scrobble.media_obj}}</a></td>
<td>{{scrobble.media_type}}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
{% if track_charts %}
<div class="col-md">
<div class="tab-content" id="artistTabContent">
<div class="table-responsive">
<table class="table table-striped table-sm">
<thead>
<tr>
<th scope="col">Rank</th>
<th scope="col">Track</th>
<th scope="col">Scrobbles</th>
</tr>
</thead>
<tbody>
{% for chart in track_charts %}
<tr>
<td>{{chart.rank}}</td>
<td><a href="{{chart.media_obj.get_absolute_url}}">{{chart.media_obj.title}}</a></td>
<td>{{chart.count}}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
{% endif %}
{% if current_artist_charts %}
<div class="col-md">
<h2>Top Artists</h2>
<ul class="nav nav-tabs" id="artistTab" role="tablist">
{% for chart_name in current_artist_charts.keys %}
<li class="nav-item" role="presentation">
<button class="nav-link {% if forloop.first %}active{% endif %}" id="artist-{{chart_name}}-tab"
data-bs-toggle="tab" data-bs-target="#artist-{{chart_name}}" type="button" role="tab"
aria-controls="home" aria-selected="true">
{% if chart_name == "all" %}All Time{% else %}{% if chart_name != "today" %}This {% endif %}
%}{{chart_name|capfirst}}{% endif %}
</button>
</li>
{% endfor %}
</ul>
<div class="tab-content" id="artistTabContent">
{% for chart_name, artists in current_artist_charts.items %}
<div class="tab-pane fade {% if forloop.first %}show active{% endif %}" id="artist-{{chart_name}}"
role="tabpanel" aria-labelledby="artist-{[chart}}-tab">
<div class="table-responsive">
<table class="table table-striped table-sm">
<thead>
<tr>
<th scope="col">Artist</th>
<th scope="col">Scrobbles</th>
</tr>
</thead>
<tbody>
{% for artist in artists %}
<tr>
<td><a href="{{artist.get_absolute_url}}">{{artist}}</a></td>
<td>{{artist.num_scrobbles}}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
{% endfor %}
</div>
{% endif %}
</div>
{% if current_track_charts %}
<div class="col-md">
<h2>Top Tracks</h2>
<ul class="nav nav-tabs" id="artistTab" role="tablist">
{% for chart_name in current_track_charts.keys %}
<li class="nav-item" role="presentation">
<button class="nav-link {% if forloop.first %}active{% endif %}" id="track-{{chart_name}}-tab"
data-bs-toggle="tab" data-bs-target="#track-{{chart_name}}" type="button" role="tab"
aria-controls="home" aria-selected="true">
{% if chart_name == "all" %}All Time{% else %}{% if chart_name != "today" %}This {% endif %}
%}{{chart_name|capfirst}}{% endif %}
</button>
</li>
{% endfor %}
</ul>
<div class="tab-content" id="trackTabContent">
{% for chart_name, tracks in current_track_charts.items %}
<div class="tab-pane fade {% if forloop.first %}show active{% endif %}" id="track-{{chart_name}}"
role="tabpanel" aria-labelledby="track-{[chart_name}}-tab">
<div class="table-responsive">
<table class="table table-striped table-sm">
<thead>
<tr>
<th scope="col">Track</th>
<th scope="col">Artist</th>
<th scope="col">Scrobbles</th>
</tr>
</thead>
<tbody>
{% for track in tracks %}
<tr>
<td><a href="{{track.get_absolute_url}}">{{track.title}}</a></td>
<td><a href="{{track.artist.get_absolute_url}}">{{track.artist}}</a></td>
<td>{{track.num_scrobbles}}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
{% endfor %}
</div>
</div>
{% endif %}
</div>
{% endblock %}