From 92c0c668b3d2ade5aca90c6c20dfa73b66e45304 Mon Sep 17 00:00:00 2001 From: Colin Powell Date: Thu, 11 Sep 2025 18:29:28 -0400 Subject: [PATCH] [locations] Add locations to dashboard --- vrobbler/apps/locations/models.py | 2 +- vrobbler/apps/locations/urls.py | 4 ++-- vrobbler/apps/scrobbles/models.py | 7 +++++++ vrobbler/templates/locations/geolocation_list.html | 8 +------- vrobbler/templates/scrobbles/_last_scrobbles.html | 9 +++++++++ 5 files changed, 20 insertions(+), 10 deletions(-) diff --git a/vrobbler/apps/locations/models.py b/vrobbler/apps/locations/models.py index c7c1672..0036d66 100644 --- a/vrobbler/apps/locations/models.py +++ b/vrobbler/apps/locations/models.py @@ -36,7 +36,7 @@ class GeoLocation(ScrobblableMixin): def get_absolute_url(self): return reverse( - "locations:geo_location_detail", kwargs={"slug": self.uuid} + "locations:geolocation_detail", kwargs={"slug": self.uuid} ) @classmethod diff --git a/vrobbler/apps/locations/urls.py b/vrobbler/apps/locations/urls.py index 4cf8258..d84054e 100644 --- a/vrobbler/apps/locations/urls.py +++ b/vrobbler/apps/locations/urls.py @@ -8,11 +8,11 @@ urlpatterns = [ path( "locations/", views.GeoLocationListView.as_view(), - name="geo_locations_list", + name="geolocation_list", ), path( "locations//", views.GeoLocationDetailView.as_view(), - name="geo_location_detail", + name="geolocation_detail", ), ] diff --git a/vrobbler/apps/scrobbles/models.py b/vrobbler/apps/scrobbles/models.py index cb1ac98..b7e6096 100644 --- a/vrobbler/apps/scrobbles/models.py +++ b/vrobbler/apps/scrobbles/models.py @@ -655,6 +655,13 @@ class Scrobble(TimeStampedModel): (scrobble.elapsed_time) ) + # Remove any locations without titles + if "GeoLocation" in scrobbles_by_type.keys(): + for loc_scrobble in scrobbles_by_type["GeoLocation"]: + if not loc_scrobble.media_obj.title: + scrobbles_by_type["GeoLocation"].remove(loc_scrobble) + scrobbles_by_type["GeoLocation_count"] -= 1 + return scrobbles_by_type @classmethod diff --git a/vrobbler/templates/locations/geolocation_list.html b/vrobbler/templates/locations/geolocation_list.html index 06003aa..e43375d 100644 --- a/vrobbler/templates/locations/geolocation_list.html +++ b/vrobbler/templates/locations/geolocation_list.html @@ -67,13 +67,7 @@ - {% for location in object_list %} - - {{location.scrobble_set.count}} - {{location.title}} - {{location.lat}}x{{location.lon}} - - {% endfor %} + {% include "_scrobblable_list.html" %} diff --git a/vrobbler/templates/scrobbles/_last_scrobbles.html b/vrobbler/templates/scrobbles/_last_scrobbles.html index d452c92..9b2e3b9 100644 --- a/vrobbler/templates/scrobbles/_last_scrobbles.html +++ b/vrobbler/templates/scrobbles/_last_scrobbles.html @@ -126,5 +126,14 @@

No books today

{% endif %} +

Locations

+ {% if GeoLocation %} + {% with scrobbles=GeoLocation count=GeoLocation_count time=GeoLocation_time %} + {% include "scrobbles/_scrobble_table.html" %} + {% endwith %} + {% else %} +

No locations visited today

+ {% endif %} +