[locations] Add locations to dashboard

This commit is contained in:
2025-09-11 18:29:28 -04:00
parent 3b77feda45
commit 92c0c668b3
5 changed files with 20 additions and 10 deletions

View File

@ -36,7 +36,7 @@ class GeoLocation(ScrobblableMixin):
def get_absolute_url(self): def get_absolute_url(self):
return reverse( return reverse(
"locations:geo_location_detail", kwargs={"slug": self.uuid} "locations:geolocation_detail", kwargs={"slug": self.uuid}
) )
@classmethod @classmethod

View File

@ -8,11 +8,11 @@ urlpatterns = [
path( path(
"locations/", "locations/",
views.GeoLocationListView.as_view(), views.GeoLocationListView.as_view(),
name="geo_locations_list", name="geolocation_list",
), ),
path( path(
"locations/<slug:slug>/", "locations/<slug:slug>/",
views.GeoLocationDetailView.as_view(), views.GeoLocationDetailView.as_view(),
name="geo_location_detail", name="geolocation_detail",
), ),
] ]

View File

@ -655,6 +655,13 @@ class Scrobble(TimeStampedModel):
(scrobble.elapsed_time) (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 return scrobbles_by_type
@classmethod @classmethod

View File

@ -67,13 +67,7 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{% for location in object_list %} {% include "_scrobblable_list.html" %}
<tr>
<td>{{location.scrobble_set.count}}</td>
<td>{{location.title}}</td>
<td><a href="{{location.get_absolute_url}}">{{location.lat}}x{{location.lon}}</a></td>
</tr>
{% endfor %}
</tbody> </tbody>
</table> </table>
</div> </div>

View File

@ -126,5 +126,14 @@
<p>No books today</p> <p>No books today</p>
{% endif %} {% endif %}
<h3><a href="{% url 'locations:geolocation_list' %}">Locations</a></h3>
{% if GeoLocation %}
{% with scrobbles=GeoLocation count=GeoLocation_count time=GeoLocation_time %}
{% include "scrobbles/_scrobble_table.html" %}
{% endwith %}
{% else %}
<p>No locations visited today</p>
{% endif %}
</div> </div>
</div> </div>