39 lines
1.4 KiB
Python
39 lines
1.4 KiB
Python
from django import views as django_views
|
|
from django.shortcuts import render
|
|
from django.http.request import HttpRequest
|
|
from django.shortcuts import get_object_or_404
|
|
|
|
from music.models import Track
|
|
from music.models import Artist
|
|
from music.models import Album
|
|
|
|
|
|
class TrackListView(django_views.View):
|
|
def get(self, request: HttpRequest, *args, **kwargs):
|
|
tracks = Track.objects.all()
|
|
return render(request, "music/track_list.html", {"tracks": tracks})
|
|
|
|
|
|
class ArtistListView(django_views.View):
|
|
def get(self, request: HttpRequest, *args, **kwargs):
|
|
artists = Artist.objects.all()
|
|
return render(request, "music/artist_list.html", {"artists": artists})
|
|
|
|
|
|
class ArtistDetailView(django_views.View):
|
|
def get(self, request: HttpRequest, pk: int, *args, **kwargs):
|
|
artist = get_object_or_404(Artist, id=pk)
|
|
return render(request, "music/artist_detail.html", {"artist": artist})
|
|
|
|
|
|
class AlbumListView(django_views.View):
|
|
def get(self, request: HttpRequest, *args, **kwargs):
|
|
albums = Album.objects.all()
|
|
return render(request, "music/album_list.html", {"albums": albums})
|
|
|
|
|
|
class AlbumDetailView(django_views.View):
|
|
def get(self, request: HttpRequest, pk: int, *args, **kwargs):
|
|
album = get_object_or_404(Album, id=pk)
|
|
return render(request, "music/album_detail.html", {"album": album})
|