From 07b5dc6a2c29627d195b2329871f358e6f3fd88e Mon Sep 17 00:00:00 2001 From: Colin Powell Date: Fri, 6 Jun 2025 09:49:08 -0400 Subject: [PATCH] [templates] Clean up dashboard --- vrobbler/apps/scrobbles/views.py | 8 +- .../templates/scrobbles/_last_scrobbles.html | 112 +++++++----------- .../templates/scrobbles/scrobble_list.html | 2 +- 3 files changed, 51 insertions(+), 71 deletions(-) diff --git a/vrobbler/apps/scrobbles/views.py b/vrobbler/apps/scrobbles/views.py index 0391642..4854ca2 100644 --- a/vrobbler/apps/scrobbles/views.py +++ b/vrobbler/apps/scrobbles/views.py @@ -4,6 +4,7 @@ import logging from datetime import datetime, timedelta import pendulum +from pendulum.parsing.exceptions import ParserError import pytz from django.apps import apps from django.contrib import messages @@ -115,8 +116,11 @@ class RecentScrobbleList(ListView): month = today.month day = today.day if date: - year, month, day = date.split("-") - data["date"] = pendulum.parse(date) + try: + data["date"] = pendulum.parse(date) + year, month, day = date.split("-") + except: + pass data = data | Scrobble.for_day_dict(user_id, year, month, day) diff --git a/vrobbler/templates/scrobbles/_last_scrobbles.html b/vrobbler/templates/scrobbles/_last_scrobbles.html index 55392c6..f326b41 100644 --- a/vrobbler/templates/scrobbles/_last_scrobbles.html +++ b/vrobbler/templates/scrobbles/_last_scrobbles.html @@ -4,51 +4,9 @@

Today {{counts.today}} | This Week {{counts.week}} | This Month {{counts.month}} | This Year {{counts.year}} | All Time {{counts.alltime}}

- -
-
@@ -64,7 +22,7 @@ {{Track|length}} {% for scrobble in Track %} - + {% if scrobble.track.album.cover_image %} {% else %} @@ -78,7 +36,9 @@
{% if scrobble.in_progress %}Listening now{% else %}{{scrobble.timestamp|naturaltime}}{% endif %}{% if scrobble.in_progress %}{{scrobble.media_obj.strings.verb}} now | Finish{% else %}{{scrobble.timestamp|naturaltime}}{% endif %}
+ {% endif %} + {% if Video %}
@@ -94,7 +54,7 @@ {% for scrobble in Video %} - {% if scrobble.in_progress %}Watching now{% else %}{{scrobble.timestamp|naturaltime}}{% endif %} + {% if scrobble.in_progress %}{{scrobble.media_obj.strings.verb}} now | Finish{% else %}{{scrobble.timestamp|naturaltime}}{% endif %} {% if scrobble.video.cover_image %} {% else %} @@ -109,7 +69,9 @@
+ {% endif %} + {% if SportEvent %}

Latest Sports

@@ -126,18 +88,20 @@ {% for scrobble in SportEvent %} - {% if scrobble.in_progress %}Watching now{% else %}{{scrobble.timestamp|naturaltime}}{% endif %} + {% if scrobble.in_progress %}{{scrobble.media_obj.strings.verb}} now | Finish{% else %}{{scrobble.timestamp|naturaltime}}{% endif %} {{scrobble.sport_event.title}} {{scrobble.sport_event.round.name}} {{scrobble.sport_event.round.season.league}} - {{scrobble.playback_position_seconds|natural_duration}} + {{scrobble.elapsed_time|natural_duration}} {% endfor %}
+ {% endif %} + {% if PodcastEpisode %}
@@ -152,7 +116,7 @@ {% for scrobble in PodcastEpisode %} - {% if scrobble.in_progress %}Listening now{% else %}{{scrobble.timestamp|naturaltime}}{% endif %} + {% if scrobble.in_progress %}{{scrobble.media_obj.strings.verb}} now | Finish{% else %}{{scrobble.timestamp|naturaltime}}{% endif %} {{scrobble.timestamp|naturaltime}} {{scrobble.podcast_episode.title}} {{scrobble.podcast_episode.podcast}} @@ -162,7 +126,10 @@
+ {% endif %} + {% if VideoGame %} +

Video games

@@ -170,7 +137,7 @@ Date - Cover/Screenshot + Cover Title Time played Percent complete @@ -179,16 +146,12 @@ {% for scrobble in VideoGame %} - {% if scrobble.in_progress %}Sessioning now{% else %}{{scrobble.timestamp|naturaltime}}{% endif %} - {% if scrobble.screenshot %} - - {% else %} + {% if scrobble.in_progress %}{{scrobble.media_obj.strings.verb}} now | Finish{% else %}{{scrobble.timestamp|naturaltime}}{% endif %} {% if scrobble.media_obj.hltb_cover %} {% endif %} - {% endif %} {{scrobble.media_obj.title}} - {{scrobble.playback_position_seconds|natural_duration}} + {{scrobble.elapsed_time|natural_duration}} {{scrobble.percent_played}} {% endfor %} @@ -196,8 +159,11 @@
+ {% endif %} + {% if BoardGame %} +

Board games

@@ -213,17 +179,20 @@ {% for scrobble in BoardGame %} - {% if scrobble.in_progress %}Tabling now{% else %}{{scrobble.timestamp|naturaltime}}{% endif %} + {% if scrobble.in_progress %}{{scrobble.media_obj.strings.verb}} now | Finish{% else %}{{scrobble.timestamp|naturaltime}}{% endif %} {{scrobble.media_obj.title}} - {{scrobble.playback_position_seconds|natural_duration}} + {{scrobble.elapsed_time|natural_duration}} {% endfor %}
+ {% endif %} + {% if WebPage %} +

Web pages

@@ -231,7 +200,6 @@ Date - Cover Title Time browsing @@ -239,17 +207,19 @@ {% for scrobble in WebPage %} - {% if scrobble.in_progress %}Browsing now{% else %}{{scrobble.timestamp|naturaltime}}{% endif %} - + {% if scrobble.in_progress %}{{scrobble.media_obj.strings.verb}} now | Finish{% else %}{{scrobble.timestamp|naturaltime}}{% endif %} {{scrobble.media_obj.title}} - {{scrobble.playback_position_seconds|natural_duration}} + {{scrobble.elapsed_time|natural_duration}} {% endfor %}
+ {% endif %} + {% if Beer %} +

Beers

@@ -265,17 +235,20 @@ {% for scrobble in Beer %} - {% if scrobble.in_progress %}Drinking now{% else %}{{scrobble.timestamp|naturaltime}}{% endif %} + {% if scrobble.in_progress %}{{scrobble.media_obj.strings.verb}} now | Finish{% else %}{{scrobble.timestamp|naturaltime}}{% endif %} {{scrobble.media_obj.title}} - {{scrobble.playback_position_seconds|natural_duration}} + {{scrobble.elapsed_time|natural_duration}} {% endfor %}
+ {% endif %} + {% if Book %} +

Books

@@ -291,17 +264,19 @@ {% for scrobble in Book %} - {% if scrobble.in_progress %}Reading now{% else %}{{scrobble.timestamp|naturaltime}}{% endif %} + {% if scrobble.in_progress %}{{scrobble.media_obj.strings.verb}} now | Finish{% else %}{{scrobble.timestamp|naturaltime}}{% endif %} {{scrobble.media_obj.title}} - {{scrobble.playback_position_seconds|natural_duration}} + {{scrobble.elapsed_time|natural_duration}} {% endfor %}
+ {% endif %} + {% if Task %}
@@ -316,15 +291,16 @@ {% for scrobble in Task %} - {% if scrobble.in_progress %}Doing now{% else %}{{scrobble.timestamp|naturaltime}}{% endif %} + {% if scrobble.in_progress %}{{scrobble.media_obj.strings.verb}} now | Finish{% else %}{{scrobble.timestamp|naturaltime}}{% endif %} {{scrobble.media_obj.title}} - {{scrobble.playback_position_seconds|natural_duration}} + {{scrobble.elapsed_time|natural_duration}} {% endfor %}
+ {% endif %}
diff --git a/vrobbler/templates/scrobbles/scrobble_list.html b/vrobbler/templates/scrobbles/scrobble_list.html index 3914052..80f941b 100644 --- a/vrobbler/templates/scrobbles/scrobble_list.html +++ b/vrobbler/templates/scrobbles/scrobble_list.html @@ -49,7 +49,7 @@
-

Dashboard

+

{% if date %}{{date|naturaltime}}{% else %}Today{% endif %}

{% if user.is_authenticated %}