From a1ff82bfec1d2ce8fe6555ee9129faed944769fb Mon Sep 17 00:00:00 2001 From: Colin Powell Date: Thu, 11 Sep 2025 18:55:45 -0400 Subject: [PATCH] [templates] Cleaning up templates and datalog forms --- vrobbler/apps/lifeevents/models.py | 1 - vrobbler/apps/locations/models.py | 13 +++++++++++-- vrobbler/apps/moods/models.py | 2 +- vrobbler/apps/moods/urls.py | 4 ++-- vrobbler/apps/podcasts/views.py | 1 + vrobbler/apps/scrobbles/notifications.py | 2 +- vrobbler/templates/boardgames/boardgame_detail.html | 4 ++-- vrobbler/templates/foods/food_detail.html | 4 ++++ .../templates/locations/geolocation_detail.html | 6 +++++- vrobbler/templates/podcasts/podcast_list.html | 10 +++++----- vrobbler/templates/scrobbles/_last_scrobbles.html | 11 ++++++++++- vrobbler/templates/webpages/webpage_detail.html | 2 ++ 12 files changed, 44 insertions(+), 16 deletions(-) diff --git a/vrobbler/apps/lifeevents/models.py b/vrobbler/apps/lifeevents/models.py index aa4ec2a..f1b7863 100644 --- a/vrobbler/apps/lifeevents/models.py +++ b/vrobbler/apps/lifeevents/models.py @@ -1,5 +1,4 @@ from dataclasses import dataclass -from typing import Optional from django.apps import apps from django.db import models from django.urls import reverse diff --git a/vrobbler/apps/locations/models.py b/vrobbler/apps/locations/models.py index 0036d66..548b730 100644 --- a/vrobbler/apps/locations/models.py +++ b/vrobbler/apps/locations/models.py @@ -1,11 +1,13 @@ -from decimal import Decimal, getcontext import logging +from dataclasses import dataclass +from decimal import Decimal from typing import Dict -from django.contrib.auth import get_user_model from django.conf import settings +from django.contrib.auth import get_user_model from django.db import models from django.urls import reverse +from scrobbles.dataclasses import BaseLogData, WithPeopleLogData from scrobbles.mixins import ScrobblableConstants, ScrobblableMixin logger = logging.getLogger(__name__) @@ -15,6 +17,9 @@ User = get_user_model() GEOLOC_ACCURACY = int(getattr(settings, "GEOLOC_ACCURACY", 4)) GEOLOC_PROXIMITY = Decimal(getattr(settings, "GEOLOC_PROXIMITY", "0.0001")) +@dataclass +class GeoLocationLogData(BaseLogData, WithPeopleLogData): + pass class GeoLocation(ScrobblableMixin): COMPLETION_PERCENT = getattr(settings, "LOCATION_COMPLETION_PERCENT", 100) @@ -39,6 +44,10 @@ class GeoLocation(ScrobblableMixin): "locations:geolocation_detail", kwargs={"slug": self.uuid} ) + @property + def logdata_cls(self): + return GeoLocationLogData + @classmethod def find_or_create(cls, data_dict: Dict) -> "GeoLocation": """Given a data dict from GPSLogger, does the heavy lifting of looking up diff --git a/vrobbler/apps/moods/models.py b/vrobbler/apps/moods/models.py index 70b0a2a..b3d9e00 100644 --- a/vrobbler/apps/moods/models.py +++ b/vrobbler/apps/moods/models.py @@ -42,7 +42,7 @@ class Mood(ScrobblableMixin): return str(self.uuid) def get_absolute_url(self): - return reverse("moods:mood-detail", kwargs={"slug": self.uuid}) + return reverse("moods:mood_detail", kwargs={"slug": self.uuid}) @property def subtitle(self) -> str: diff --git a/vrobbler/apps/moods/urls.py b/vrobbler/apps/moods/urls.py index 85f5e97..ad02987 100644 --- a/vrobbler/apps/moods/urls.py +++ b/vrobbler/apps/moods/urls.py @@ -5,10 +5,10 @@ app_name = "moods" urlpatterns = [ - path("moods/", views.MoodListView.as_view(), name="mood-list"), + path("moods/", views.MoodListView.as_view(), name="mood_list"), path( "moods//", views.MoodDetailView.as_view(), - name="mood-detail", + name="mood_detail", ), ] diff --git a/vrobbler/apps/podcasts/views.py b/vrobbler/apps/podcasts/views.py index 79486e8..08804cb 100644 --- a/vrobbler/apps/podcasts/views.py +++ b/vrobbler/apps/podcasts/views.py @@ -1,6 +1,7 @@ from django.views import generic from podcasts.models import Podcast +from scrobbles.views import ScrobbleableListView, ScrobbleableDetailView class PodcastListView(generic.ListView): model = Podcast diff --git a/vrobbler/apps/scrobbles/notifications.py b/vrobbler/apps/scrobbles/notifications.py index fa38f71..f3c62d8 100644 --- a/vrobbler/apps/scrobbles/notifications.py +++ b/vrobbler/apps/scrobbles/notifications.py @@ -72,7 +72,7 @@ class MoodNtfyNotification(BasicNtfyNotification): def __init__(self, profile, **kwargs): super().__init__(profile) self.ntfy_str: str = "Would you like to check in about your mood?" - self.click_url = self.url_tmpl.format(path=reverse("moods:mood-list")) + self.click_url = self.url_tmpl.format(path=reverse("moods:mood_list")) self.title = "Mood Check-in!" def send(self): diff --git a/vrobbler/templates/boardgames/boardgame_detail.html b/vrobbler/templates/boardgames/boardgame_detail.html index 1286247..a768cc1 100644 --- a/vrobbler/templates/boardgames/boardgame_detail.html +++ b/vrobbler/templates/boardgames/boardgame_detail.html @@ -55,7 +55,7 @@ Date - Publisher + Location Players @@ -63,7 +63,7 @@ {% for scrobble in scrobbles.all|dictsortreversed:"timestamp" %} {{scrobble.local_timestamp}} - {{scrobble.media_obj.publisher}} + {{scrobble.logdata.location }} {% if scrobble.logdata.player_log %}{{scrobble.logdata.player_log}}{% else %}No data{% endif %} {% endfor %} diff --git a/vrobbler/templates/foods/food_detail.html b/vrobbler/templates/foods/food_detail.html index 89c3b41..c2343be 100644 --- a/vrobbler/templates/foods/food_detail.html +++ b/vrobbler/templates/foods/food_detail.html @@ -17,12 +17,16 @@ Date + Calories + Notes {% for scrobble in scrobbles.all %} {{scrobble.local_timestamp}} + {% if scrobble.logdata.calories %}{{scrobble.logdata.calories}}{% else %}{{scrobble.media_obj.calories}}{% endif %} + {% for note in scrobble.logdata.notes %}{{note}}{% if not forloop.last %}; {% endif%}{% endfor %} {% endfor %} diff --git a/vrobbler/templates/locations/geolocation_detail.html b/vrobbler/templates/locations/geolocation_detail.html index cd047df..2cc95d1 100644 --- a/vrobbler/templates/locations/geolocation_detail.html +++ b/vrobbler/templates/locations/geolocation_detail.html @@ -57,12 +57,16 @@ Date + With + Notes - {% for scrobble in scrobbles.all|dictsortreversed:"timestamp" %} + {% for scrobble in object.scrobble_set.all|dictsortreversed:"timestamp" %} {{scrobble.local_timestamp}} + {% for person in scrobble.logdata.with_people%}{{person}}{% if not forloop.last %}, {% endif%}{% endfor %} + {% for note in scrobble.logdata.notes %}{{note}}{% if not forloop.last %}; {% endif%}{% endfor %} {% endfor %} diff --git a/vrobbler/templates/podcasts/podcast_list.html b/vrobbler/templates/podcasts/podcast_list.html index f966f42..3f63b14 100644 --- a/vrobbler/templates/podcasts/podcast_list.html +++ b/vrobbler/templates/podcasts/podcast_list.html @@ -1,5 +1,6 @@ {% extends "base_list.html" %} +{% block title %}Podcasts{% endblock %} {% block lists %}
@@ -7,20 +8,19 @@ - + - - {% for obj in object_list %} - {% for episode in obj.episode_set.all %} + {% for obj in object_list.all %} + {{obj.episodes}} + {% for episode in obj.podcastepisode_set.all %} - {% endfor %} {% endfor %} diff --git a/vrobbler/templates/scrobbles/_last_scrobbles.html b/vrobbler/templates/scrobbles/_last_scrobbles.html index 9b2e3b9..8591c4c 100644 --- a/vrobbler/templates/scrobbles/_last_scrobbles.html +++ b/vrobbler/templates/scrobbles/_last_scrobbles.html @@ -123,7 +123,7 @@ {% include "scrobbles/_scrobble_table.html" %} {% endwith %} {% else %} -

No books today

+

No books read today

{% endif %}

Locations

@@ -135,5 +135,14 @@

No locations visited today

{% endif %} +

Moods

+ {% if Mood %} + {% with scrobbles=Mood count=Mood_count time=Mood_time %} + {% include "scrobbles/_scrobble_table.html" %} + {% endwith %} + {% else %} +

No moods felt today

+ {% endif %} + diff --git a/vrobbler/templates/webpages/webpage_detail.html b/vrobbler/templates/webpages/webpage_detail.html index c82945f..6a20761 100644 --- a/vrobbler/templates/webpages/webpage_detail.html +++ b/vrobbler/templates/webpages/webpage_detail.html @@ -48,12 +48,14 @@ + {% for scrobble in scrobbles.all %} + {% endfor %}
Series EpisodePodcast ScrobblesAll time
{{episode}} {{obj}} {{episode.scrobble_set.count}}
DateNotes
{{scrobble.local_timestamp}}{% for note in scrobble.logdata.notes %}{{note}}{% if not forloop.last %}; {% endif%}{% endfor %}