diff --git a/vrobbler/apps/scrobbles/models.py b/vrobbler/apps/scrobbles/models.py index fc407b2..ebcc6dc 100644 --- a/vrobbler/apps/scrobbles/models.py +++ b/vrobbler/apps/scrobbles/models.py @@ -792,6 +792,12 @@ class Scrobble(TimeStampedModel): except TypeError as e: return logdata_cls() + @property + def notes(self): + if self.logdata: + return self.logdata.notes or [] + return [] + def redirect_url(self, user_id) -> str: user = User.objects.filter(id=user_id).first() redirect_url = self.media_obj.get_absolute_url() diff --git a/vrobbler/apps/webpages/views.py b/vrobbler/apps/webpages/views.py index 3856f83..85b09e8 100644 --- a/vrobbler/apps/webpages/views.py +++ b/vrobbler/apps/webpages/views.py @@ -22,18 +22,8 @@ class WebPageDetailView(ScrobbleableDetailView): latest = self.object.scrobbles(self.request.user).first() if latest: context["latest_scrobble_uuid"] = str(latest.uuid) - context["latest_scrobble_notes"] = ( - latest.log.get("notes", []) if latest.log else [] - ) - print( - f"DEBUG: Found scrobble {latest.uuid} for user {self.request.user}" - ) - else: - print( - f"DEBUG: No scrobble found for user {self.request.user} on webpage {self.object.uuid}" - ) - else: - print(f"DEBUG: User not authenticated") + notes = latest.log.get("notes", []) if latest.log else [] + context["latest_scrobble_notes"] = notes return context @@ -62,7 +52,6 @@ class WebPageReadView( webpage = WebPage.objects.get(uuid=self.kwargs.get("slug")) latest_scrobble = webpage.scrobbles(user).last() if not latest_scrobble.played_to_completion: - latest_scrobble.stop() latest_scrobble.log["notes"] = self.request.POST.get("notes") diff --git a/vrobbler/templates/scrobbles/scrobble_detail.html b/vrobbler/templates/scrobbles/scrobble_detail.html index f245792..541147d 100644 --- a/vrobbler/templates/scrobbles/scrobble_detail.html +++ b/vrobbler/templates/scrobbles/scrobble_detail.html @@ -11,6 +11,17 @@
Rate: {{object.logdata.avg_seconds_per_page}}s per page
diff --git a/vrobbler/templates/webpages/webpage_detail.html b/vrobbler/templates/webpages/webpage_detail.html index cbfa807..0561ea7 100644 --- a/vrobbler/templates/webpages/webpage_detail.html +++ b/vrobbler/templates/webpages/webpage_detail.html @@ -17,9 +17,7 @@ {% endblock %} @@ -131,7 +144,7 @@ {% for scrobble in scrobbles.all %}