From dbbb2b43a8f01e352d9099c6884bb93c062dd9bf Mon Sep 17 00:00:00 2001 From: Colin Powell Date: Wed, 24 May 2023 19:31:16 -0400 Subject: [PATCH] Add scrobble list to import detail view --- vrobbler/apps/scrobbles/models.py | 8 +++++++ .../templates/scrobbles/import_detail.html | 24 ++++++++++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/vrobbler/apps/scrobbles/models.py b/vrobbler/apps/scrobbles/models.py index c899817..3bd9b2d 100644 --- a/vrobbler/apps/scrobbles/models.py +++ b/vrobbler/apps/scrobbles/models.py @@ -99,6 +99,14 @@ class BaseFileImportMixin(TimeStampedModel): ] ) + def scrobbles(self) -> models.QuerySet: + scrobble_ids = [] + for line in self.process_log.split("\n"): + sid = line.split("\t")[0] + if sid: + scrobble_ids.append(sid) + return Scrobble.objects.filter(id__in=scrobble_ids) + def mark_started(self): self.processing_started = timezone.now() self.save(update_fields=["processing_started"]) diff --git a/vrobbler/templates/scrobbles/import_detail.html b/vrobbler/templates/scrobbles/import_detail.html index f3094a9..a26abb7 100644 --- a/vrobbler/templates/scrobbles/import_detail.html +++ b/vrobbler/templates/scrobbles/import_detail.html @@ -8,6 +8,28 @@

Import started: {{object.processing_started}}

Import finished: {{object.processed_finished}}

Imported {{object.process_count}} scrobbles

+ +

Scrobbles

+
+ + + + + + + + + + {% for scrobble in object.scrobbles %} + + + + + {% endfor %} + +
DateMedia TypeMedia
{{scrobble.timestamp}}{{scrobble.media_type}}{{scrobble.media_obj}} +
+
-{% endblock %} \ No newline at end of file +{% endblock %}