diff --git a/api/funkwhale_api/favorites/admin.py b/api/funkwhale_api/favorites/admin.py new file mode 100644 index 0000000000000000000000000000000000000000..e8f29fac452f23f5ba544395dca248a41afe3cfe --- /dev/null +++ b/api/funkwhale_api/favorites/admin.py @@ -0,0 +1,12 @@ +from django.contrib import admin + +from . import models + + +@admin.register(models.TrackFavorite) +class TrackFavoriteAdmin(admin.ModelAdmin): + list_display = ['user', 'track', 'creation_date'] + list_select_related = [ + 'user', + 'track' + ] diff --git a/api/funkwhale_api/history/admin.py b/api/funkwhale_api/history/admin.py index f8f587a017d8a5e65f8537b286a312367d3837ae..6d0480e73b4209629499c7ae26b8c5efa8348999 100644 --- a/api/funkwhale_api/history/admin.py +++ b/api/funkwhale_api/history/admin.py @@ -6,3 +6,7 @@ from . import models class ListeningAdmin(admin.ModelAdmin): list_display = ['track', 'end_date', 'user', 'session_key'] search_fields = ['track__name', 'user__username'] + list_select_related = [ + 'user', + 'track' + ] diff --git a/api/funkwhale_api/music/admin.py b/api/funkwhale_api/music/admin.py index 524b85386a6c4b41482d2733719757b2fdb18dbf..219b40a91deeeb9d06dd55d3292aa5ca22ccc654 100644 --- a/api/funkwhale_api/music/admin.py +++ b/api/funkwhale_api/music/admin.py @@ -25,13 +25,26 @@ class TrackAdmin(admin.ModelAdmin): @admin.register(models.ImportBatch) class ImportBatchAdmin(admin.ModelAdmin): - list_display = ['creation_date', 'status'] - + list_display = [ + 'submitted_by', + 'creation_date', + 'import_request', + 'status'] + list_select_related = [ + 'submitted_by', + 'import_request', + ] + list_filter = ['status'] + search_fields = [ + 'import_request__name', 'source', 'batch__pk', 'mbid'] @admin.register(models.ImportJob) class ImportJobAdmin(admin.ModelAdmin): list_display = ['source', 'batch', 'track_file', 'status', 'mbid'] - list_select_related = True + list_select_related = [ + 'track_file', + 'batch', + ] search_fields = ['source', 'batch__pk', 'mbid'] list_filter = ['status'] @@ -50,3 +63,19 @@ class LyricsAdmin(admin.ModelAdmin): list_select_related = True search_fields = ['url', 'work__title'] list_filter = ['work__language'] + + +@admin.register(models.TrackFile) +class TrackFileAdmin(admin.ModelAdmin): + list_display = [ + 'track', + 'audio_file', + 'source', + 'duration', + 'mimetype', + ] + list_select_related = [ + 'track' + ] + search_fields = ['source', 'acoustid_track_id'] + list_filter = ['mimetype'] diff --git a/api/funkwhale_api/radios/admin.py b/api/funkwhale_api/radios/admin.py new file mode 100644 index 0000000000000000000000000000000000000000..6d5abadaff79fcbff2a32e6713800146b6edf05f --- /dev/null +++ b/api/funkwhale_api/radios/admin.py @@ -0,0 +1,48 @@ +from django.contrib import admin + +from . import models + + +@admin.register(models.Radio) +class RadioAdmin(admin.ModelAdmin): + list_display = [ + 'user', 'name', 'is_public', 'creation_date', 'config'] + list_select_related = [ + 'user', + ] + list_filter = [ + 'is_public', + ] + search_fields = ['name', 'description'] + + +@admin.register(models.RadioSession) +class RadioSessionAdmin(admin.ModelAdmin): + list_display = [ + 'user', + 'custom_radio', + 'radio_type', + 'creation_date', + 'related_object'] + + list_select_related = [ + 'user', + 'custom_radio' + ] + list_filter = [ + 'radio_type', + ] + + +@admin.register(models.RadioSessionTrack) +class RadioSessionTrackAdmin(admin.ModelAdmin): + list_display = [ + 'id', + 'session', + 'position', + 'track',] + + list_select_related = [ + 'track', + 'session' + ] diff --git a/api/funkwhale_api/requests/admin.py b/api/funkwhale_api/requests/admin.py new file mode 100644 index 0000000000000000000000000000000000000000..71933eaa940d09c8482e6d7b2a2b73cf22afc5b5 --- /dev/null +++ b/api/funkwhale_api/requests/admin.py @@ -0,0 +1,16 @@ +from django.contrib import admin + +from . import models + + +@admin.register(models.ImportRequest) +class ImportRequestAdmin(admin.ModelAdmin): + list_display = ['artist_name', 'user', 'status', 'creation_date'] + list_select_related = [ + 'user', + 'track' + ] + list_filter = [ + 'status', + ] + search_fields = ['artist_name', 'comment', 'albums'] diff --git a/changes/changelog.d/80.feature b/changes/changelog.d/80.feature new file mode 100644 index 0000000000000000000000000000000000000000..16591a9108d022489c1aee138e7ee730aa1016ec --- /dev/null +++ b/changes/changelog.d/80.feature @@ -0,0 +1 @@ +Added admin interface for radios, track files, favorites and import requests (#80)