mirror of
https://gitlab.science.ru.nl/technicie/MarietjeDjango.git
synced 2025-12-09 21:42:20 +01:00
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.
This commit is contained in:
@ -1,4 +1,6 @@
|
|||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
|
from django.urls import reverse
|
||||||
|
from django.utils.html import format_html
|
||||||
|
|
||||||
from .models import ReportNote, Song
|
from .models import ReportNote, Song
|
||||||
|
|
||||||
@ -32,4 +34,11 @@ class SongAdmin(admin.ModelAdmin):
|
|||||||
class ReportNoteAdmin(admin.ModelAdmin):
|
class ReportNoteAdmin(admin.ModelAdmin):
|
||||||
list_display = ('song', 'note', 'user')
|
list_display = ('song', 'note', 'user')
|
||||||
search_fields = ('song__artist', 'song__title', 'user__name')
|
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("<a href='{url}'>{song}</a>", url=url, song=note.song)
|
||||||
|
|
||||||
|
song_link.short_description = "Song link"
|
||||||
|
|||||||
Reference in New Issue
Block a user