mirror of
https://gitlab.science.ru.nl/technicie/MarietjeDjango.git
synced 2025-12-09 18:12:20 +01:00
Merge branch 'notes-song-link' into 'marietje-zuid'
Add a link to relevant song in ReportNote admin interface See merge request dsprenkels/MarietjeDjango!51
This commit is contained in:
@ -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("<a href='{url}'>{song}</a>", url=url, song=note.song)
|
||||
|
||||
song_link.short_description = "Song link"
|
||||
|
||||
Reference in New Issue
Block a user