[templates] Add counts and durations to new tables
This commit is contained in:
@ -635,6 +635,14 @@ class Scrobble(TimeStampedModel):
|
|||||||
|
|
||||||
for scrobble in scrobble_qs:
|
for scrobble in scrobble_qs:
|
||||||
scrobbles_by_type[scrobble.media_type].append(scrobble)
|
scrobbles_by_type[scrobble.media_type].append(scrobble)
|
||||||
|
if not scrobbles_by_type.get(scrobble.media_type + "_count"):
|
||||||
|
scrobbles_by_type[scrobble.media_type + "_count"] = 0
|
||||||
|
scrobbles_by_type[scrobble.media_type + "_count"] += 1
|
||||||
|
if not scrobbles_by_type.get(scrobble.media_type + "_time"):
|
||||||
|
scrobbles_by_type[scrobble.media_type + "_time"] = 0
|
||||||
|
scrobbles_by_type[scrobble.media_type + "_time"] += int(
|
||||||
|
(scrobble.elapsed_time)
|
||||||
|
)
|
||||||
|
|
||||||
return scrobbles_by_type
|
return scrobbles_by_type
|
||||||
|
|
||||||
|
|||||||
@ -9,7 +9,7 @@
|
|||||||
<div class="col-md">
|
<div class="col-md">
|
||||||
{% if Track %}
|
{% if Track %}
|
||||||
<h2>Music</h2>
|
<h2>Music</h2>
|
||||||
{% with scrobbles=Track %}
|
{% with scrobbles=Track count=Track_count time=Track_time %}
|
||||||
{% include "scrobbles/_scrobble_table.html" %}
|
{% include "scrobbles/_scrobble_table.html" %}
|
||||||
{% endwith %}
|
{% endwith %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@ -18,63 +18,63 @@
|
|||||||
|
|
||||||
{% if Task %}
|
{% if Task %}
|
||||||
<h2>Latest tasks</h2>
|
<h2>Latest tasks</h2>
|
||||||
{% with scrobbles=Task %}
|
{% with scrobbles=Task count=Task_count time=Task_time %}
|
||||||
{% include "scrobbles/_scrobble_table.html" %}
|
{% include "scrobbles/_scrobble_table.html" %}
|
||||||
{% endwith %}
|
{% endwith %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if Video %}
|
{% if Video %}
|
||||||
<h2>Videos</h2>
|
<h2>Videos</h2>
|
||||||
{% with scrobbles=Video %}
|
{% with scrobbles=Video count=Video_count time=Video_time %}
|
||||||
{% include "scrobbles/_scrobble_table.html" %}
|
{% include "scrobbles/_scrobble_table.html" %}
|
||||||
{% endwith %}
|
{% endwith %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if WebPage %}
|
{% if WebPage %}
|
||||||
<h4>Web pages</h4>
|
<h4>Web pages</h4>
|
||||||
{% with scrobbles=WebPage %}
|
{% with scrobbles=WebPage count=WebPage_count time=WebPage_time %}
|
||||||
{% include "scrobbles/_scrobble_table.html" %}
|
{% include "scrobbles/_scrobble_table.html" %}
|
||||||
{% endwith %}
|
{% endwith %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if SportEvent %}
|
{% if SportEvent %}
|
||||||
<h2>Sports</h2>
|
<h2>Sports</h2>
|
||||||
{% with scrobbles=SportEvent %}
|
{% with scrobbles=SportEvent count=SportEvent_count time=SportEvent_time %}
|
||||||
{% include "scrobbles/_scrobble_table.html" %}
|
{% include "scrobbles/_scrobble_table.html" %}
|
||||||
{% endwith %}
|
{% endwith %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if PodcastEpisode %}
|
{% if PodcastEpisode %}
|
||||||
<h2>Latest podcasts</h2>
|
<h2>Latest podcasts</h2>
|
||||||
{% with scrobbles=PodcastEpisode %}
|
{% with scrobbles=PodcastEpisode count=PodcastEpisode_count time=PodcastEpisode_time %}
|
||||||
{% include "scrobbles/_scrobble_table.html" %}
|
{% include "scrobbles/_scrobble_table.html" %}
|
||||||
{% endwith %}
|
{% endwith %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if VideoGame %}
|
{% if VideoGame %}
|
||||||
<h4>Video games</h4>
|
<h4>Video games</h4>
|
||||||
{% with scrobbles=VideoGame %}
|
{% with scrobbles=VideoGame count=VideoGame_count time=VideoGame_time %}
|
||||||
{% include "scrobbles/_scrobble_table.html" %}
|
{% include "scrobbles/_scrobble_table.html" %}
|
||||||
{% endwith %}
|
{% endwith %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if BoardGame %}
|
{% if BoardGame %}
|
||||||
<h4>Board games</h4>
|
<h4>Board games</h4>
|
||||||
{% with scrobbles=BoardGame %}
|
{% with scrobbles=BoardGame count=BoardGame_count time=BoardGame_time %}
|
||||||
{% include "scrobbles/_scrobble_table.html" %}
|
{% include "scrobbles/_scrobble_table.html" %}
|
||||||
{% endwith %}
|
{% endwith %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if Beer %}
|
{% if Beer %}
|
||||||
<h4>Beers</h4>
|
<h4>Beers</h4>
|
||||||
{% with scrobbles=Beer %}
|
{% with scrobbles=Beer count=Beer_count time=Beer_time %}
|
||||||
{% include "scrobbles/_scrobble_table.html" %}
|
{% include "scrobbles/_scrobble_table.html" %}
|
||||||
{% endwith %}
|
{% endwith %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if Book %}
|
{% if Book %}
|
||||||
<h4>Books</h4>
|
<h4>Books</h4>
|
||||||
{% with scrobbles=Book %}
|
{% with scrobbles=Book count=Book_count time=Book_time %}
|
||||||
{% include "scrobbles/_scrobble_table.html" %}
|
{% include "scrobbles/_scrobble_table.html" %}
|
||||||
{% endwith %}
|
{% endwith %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
{% load humanize %}
|
{% load humanize %}
|
||||||
{% load naturalduration %}
|
{% load naturalduration %}
|
||||||
<tr>
|
<tr {% if scrobble.in_progress %}class="in-progress"{% endif %}>
|
||||||
<td>{% if scrobble.in_progress %}{{scrobble.media_obj.strings.verb}} now | <a class="right" href="{% url "scrobbles:finish" scrobble.uuid %}">Finish</a>{% else %}{{scrobble.timestamp|naturaltime}}{% endif %}</td>
|
<td>{% if scrobble.in_progress %}{{scrobble.media_obj.strings.verb}} now | <a class="right" href="{% url "scrobbles:finish" scrobble.uuid %}">Finish</a>{% else %}{{scrobble.timestamp|naturaltime}}{% endif %}</td>
|
||||||
<td><a href="{{scrobble.media_obj.get_absolute_url}}">{{scrobble.media_obj|truncatechars_html:50}}</a></td>
|
<td><a href="{{scrobble.media_obj.get_absolute_url}}">{{scrobble.media_obj|truncatechars_html:45}}</a></td>
|
||||||
<td>{{scrobble.elapsed_time|natural_duration}}</td>
|
<td>{{scrobble.elapsed_time|natural_duration}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
@ -4,6 +4,7 @@
|
|||||||
<div class="tab-pane fade show" id="latest-beers" role="tabpanel"
|
<div class="tab-pane fade show" id="latest-beers" role="tabpanel"
|
||||||
aria-labelledby="latest-beers-tab">
|
aria-labelledby="latest-beers-tab">
|
||||||
<div class="table-responsive">
|
<div class="table-responsive">
|
||||||
|
{{count}} scrobble {% if time %}| {{time|natural_duration}}{% endif %}
|
||||||
<table class="table table-striped table-sm">
|
<table class="table table-striped table-sm">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
|||||||
@ -43,6 +43,10 @@
|
|||||||
background:rgba(0,0,0,0.4);
|
background:rgba(0,0,0,0.4);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
.in-progress {
|
||||||
|
background: #CCFFFF;
|
||||||
|
}
|
||||||
|
.in-progress a { color: black }
|
||||||
</style>
|
</style>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|||||||
Reference in New Issue
Block a user