from django.contrib import admin
from django.utils.http import urlencode
from django.shortcuts import redirect
from .models import Track, Artist, Album, Background, Vote, Profile

class TrackAdmin(admin.ModelAdmin):
    pass
class ArtistAdmin(admin.ModelAdmin):
    pass
class AlbumAdmin(admin.ModelAdmin):
    pass
class BackgroundAdmin(admin.ModelAdmin):
    pass
class VoteAdmin(admin.ModelAdmin):
    pass
class ProfileAdmin(admin.ModelAdmin):
    pass
class AllTrackAdmin(admin.ModelAdmin):
    list_display = ["name", "artist", "old", "from_playlist"]
    list_filter = ["old", "from_playlist"]
    def get_queryset(self, request):
        return (Track.all_tracks.all())
    def changelist_view(self, request, extra_context=None):
        if 'old__exact' not in request.GET:
            default_filter = urlencode({'old__exact': '0'})  # 'True' or 'False'
            return redirect(f"{request.path}?{default_filter}")
        return super().changelist_view(request, extra_context=extra_context)


#admin.site.register(Track, TrackAdmin)
admin.site.register(Track, AllTrackAdmin)
admin.site.register(Artist, ArtistAdmin)
admin.site.register(Album, AlbumAdmin)
admin.site.register(Background, BackgroundAdmin)
admin.site.register(Vote, VoteAdmin)
admin.site.register(Profile, ProfileAdmin)
