<commit_before>from django.contrib import admin

from vortex.musique.models import Artist, Album, Song


class MusiqueAdmin(admin.ModelAdmin):
    readonly_fields = ['filepath']
    change_form_template = 'admin/musique/change_form.html'

    def get_back_link(self, request):
        return request.path.replace('admin/musique/', '')

    def change_view(self, request, object_id, extra_context=None):
        extra_context = extra_context or {}
        extra_context['back_link'] = self.get_back_link(request)
        return super(MusiqueAdmin, self).change_view(
                            request, object_id, extra_context=extra_context)


#TODO

class ArtistAdmin(MusiqueAdmin):
    search_fields = ['name']


class AlbumAdmin(MusiqueAdmin):
    search_fields = ['title']


class SongAdmin(MusiqueAdmin):
    readonly_fields = ['bitrate', 'filetype', 'filefield', 'original_path']
    search_fields = ['title']


admin.site.register(Artist, ArtistAdmin)
admin.site.register(Album, AlbumAdmin)
admin.site.register(Song, SongAdmin)<commit_msg>Custom ModelAdmin's<commit_after>from django.contrib import admin

from vortex.musique.models import Artist, Album, Song


class SongInline(admin.StackedInline):
    model = Song
    fields = [('track', 'title')]

    has_add_permission = lambda x, y : False


class AlbumInline(admin.StackedInline):
    model = Album
    fields = ('title',)

    has_add_permission = lambda x, y : False


class MusiqueAdmin(admin.ModelAdmin):
    change_form_template = 'admin/musique/change_form.html'

    def get_back_link(self, request):
        return request.path.replace('admin/musique/', '')

    def change_view(self, request, object_id, extra_context=None):
        extra_context = extra_context or {}
        extra_context['back_link'] = self.get_back_link(request)
        return super(MusiqueAdmin, self).change_view(
                            request, object_id, extra_context=extra_context)


class ArtistAdmin(MusiqueAdmin):
    readonly_fields = ['filepath']
    search_fields = ['name']
    inlines = [AlbumInline]


class AlbumAdmin(MusiqueAdmin):
    readonly_fields = ['filepath']
    search_fields = ['title']
    list_display = ('title', 'artist')
    list_filter = ('artist',)
    inlines = [SongInline]


class SongAdmin(MusiqueAdmin):
    readonly_fields = ['bitrate', 'filetype', 'filefield', 'original_path']
    search_fields = ['title']
    list_display = ('title', 'album', 'artist')


admin.site.register(Artist, ArtistAdmin)
admin.site.register(Album, AlbumAdmin)
admin.site.register(Song, SongAdmin)
{'fraction_non_alphanumeric': 0.1191588785046729, 'fraction_numerical': 0.0, 'mean_word_length': 4.158634538152611, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4367438', 'n_tokens_mistral': 794, 'n_tokens_neox': 769, 'n_words': 159}