From 164510b7b79d310a529e616b3fafafea2ffd562c Mon Sep 17 00:00:00 2001 From: Colin Powell Date: Sat, 5 Oct 2024 17:58:12 -0400 Subject: [PATCH] [tasks] Add media url link --- vrobbler/apps/scrobbles/models.py | 11 +++++++++++ vrobbler/templates/tasks/task_detail.html | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/vrobbler/apps/scrobbles/models.py b/vrobbler/apps/scrobbles/models.py index 7ecec62..c0b4867 100644 --- a/vrobbler/apps/scrobbles/models.py +++ b/vrobbler/apps/scrobbles/models.py @@ -934,6 +934,17 @@ class Scrobble(TimeStampedModel): last_page = pages[-1] return last_page + @property + def get_media_source_url(self) -> str: + url = "" + if self.media_type == "Website": + url = self.media_obj.url + if self.media_type == "Task" and self.logdata.source_id: + url = self.media_obj.source_url_pattern.format( + id=self.logdata.source_id + ) + return url + @classmethod def create_or_update( cls, media, user_id: int, scrobble_data: dict, **kwargs diff --git a/vrobbler/templates/tasks/task_detail.html b/vrobbler/templates/tasks/task_detail.html index b110c7d..65dc796 100644 --- a/vrobbler/templates/tasks/task_detail.html +++ b/vrobbler/templates/tasks/task_detail.html @@ -60,7 +60,7 @@ {% for scrobble in object.scrobble_set.all|dictsortreversed:"timestamp" %} {{scrobble.timestamp}} - {{scrobble.logdata.description}} + {{scrobble.logdata.description}} {{scrobble.source}} {% endfor %}