From 1b5b5106bafc24f5c2c1096b722fb9544d467a28 Mon Sep 17 00:00:00 2001 From: Daan Sprenkels Date: Mon, 15 Jun 2020 15:18:37 +0200 Subject: [PATCH 1/3] report-note: admin: Add a link to relevant song Previously, the admin could not directly move from a report note to its corresponding song. This commit adds a link that will go directly to the "change" page for the corresponding song. --- marietje/songs/admin.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/marietje/songs/admin.py b/marietje/songs/admin.py index 79f456a..b6b1b6c 100644 --- a/marietje/songs/admin.py +++ b/marietje/songs/admin.py @@ -1,4 +1,6 @@ from django.contrib import admin +from django.urls import reverse +from django.utils.html import format_html from .models import ReportNote, Song @@ -32,4 +34,11 @@ class SongAdmin(admin.ModelAdmin): class ReportNoteAdmin(admin.ModelAdmin): list_display = ('song', 'note', 'user') search_fields = ('song__artist', 'song__title', 'user__name') - readonly_fields = ('song',) + readonly_fields = ('song_link',) + + @staticmethod + def song_link(note): + url = reverse("admin:songs_song_change", args=(note.song.id,)) + return format_html("{song}", url=url, song=note.song) + + song_link.short_description = "Song link" From 61fa646353ffa17ad3f86752a24df03f350db9ad Mon Sep 17 00:00:00 2001 From: Daan Sprenkels Date: Mon, 15 Jun 2020 16:19:58 +0200 Subject: [PATCH 2/3] ci: Freeze pylint version This will prevent the CI from "randomly" breaking every now and then, because of added lints in pylint. From now on, pylint is updated manually. --- .gitlab-ci.yml | 2 +- requirements.txt | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b4c9495..065533f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -9,7 +9,7 @@ pylint: - apt-get -qq install -y python3 python3-venv python3-pip - python3 -m venv venv - source venv/bin/activate - - pip install -r requirements.txt pylint + - pip install -r requirements.txt script: - pylint marietje/marietje marietje/metrics marietje/playerapi marietje/queues marietje/songs marietje/stats diff --git a/requirements.txt b/requirements.txt index 0900ae6..d08bad3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,3 +2,4 @@ django>=2.2,<2.3 mutagen argon2-cffi prometheus_client +pylint==2.5.3 From b604ac995511b20632bf0933b5deadb8f21774d8 Mon Sep 17 00:00:00 2001 From: Daan Sprenkels Date: Mon, 15 Jun 2020 17:07:53 +0200 Subject: [PATCH 3/3] admin: reports: Hide song list In 1b5b510, the complete list of songs was re-added. Loading this list is super slow and should not happen. --- marietje/songs/admin.py | 1 + 1 file changed, 1 insertion(+) diff --git a/marietje/songs/admin.py b/marietje/songs/admin.py index b6b1b6c..86beb11 100644 --- a/marietje/songs/admin.py +++ b/marietje/songs/admin.py @@ -32,6 +32,7 @@ class SongAdmin(admin.ModelAdmin): @admin.register(ReportNote) class ReportNoteAdmin(admin.ModelAdmin): + exclude = ('song',) list_display = ('song', 'note', 'user') search_fields = ('song__artist', 'song__title', 'user__name') readonly_fields = ('song_link',)