48 lines
1.4 KiB
Python
48 lines
1.4 KiB
Python
from django.shortcuts import render
|
|
|
|
from label.models import Artist, Release
|
|
import label.tools as tools
|
|
|
|
|
|
def home(request):
|
|
return render(request, "label/home.html")
|
|
|
|
|
|
def artists(request):
|
|
artists = Artist.objects.all()
|
|
context = { "artists": artists }
|
|
return render(request, "label/artists.html", context)
|
|
|
|
|
|
def artist(request, aid):
|
|
artist = Artist.objects.get(id = aid)
|
|
releases = artist.release_set.all()
|
|
context = { "artist": artist, "releases": releases }
|
|
return render(request, "label/artist.html", context)
|
|
|
|
|
|
def releases(request):
|
|
artists = Artist.objects.all()
|
|
releases = Release.objects.all()
|
|
|
|
releases_and_infos = []
|
|
for release in releases:
|
|
releases_and_infos.append({
|
|
"id": release.id,
|
|
"release_type": release.release_type,
|
|
"ident": tools.get_catalog_tag(release.ident),
|
|
"title": release.title,
|
|
"contribs": tools.get_contribs(release.contributors.all()),
|
|
"year": release.year
|
|
})
|
|
|
|
context = { "releases": releases_and_infos }
|
|
return render(request, "label/releases.html", context)
|
|
|
|
|
|
def release(request, rid):
|
|
release = Release.objects.get(id = rid)
|
|
contribs = tools.get_contribs(release.contributors.all())
|
|
context = { "release": release, "contribs": contribs }
|
|
return render(request, "label/release.html", context)
|