2015-05-02 15:16:55 +02:00
|
|
|
import markdown
|
|
|
|
|
2015-05-02 14:28:07 +02:00
|
|
|
from django.shortcuts import get_object_or_404, render
|
2015-03-14 22:38:12 +01:00
|
|
|
|
|
|
|
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)
|
|
|
|
|
|
|
|
|
2015-05-02 14:28:07 +02:00
|
|
|
def artist(request, slug):
|
|
|
|
artist = get_object_or_404(Artist, slug = slug)
|
2015-05-02 15:16:55 +02:00
|
|
|
artist.description = markdown.markdown(artist.description)
|
|
|
|
|
2015-03-14 22:38:12 +01:00
|
|
|
releases = artist.release_set.all()
|
2015-05-02 14:43:10 +02:00
|
|
|
for release in releases:
|
|
|
|
release.tag = tools.get_catalog_tag_from_id(release.ident)
|
2015-05-02 15:16:55 +02:00
|
|
|
|
2015-03-14 22:38:12 +01:00
|
|
|
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:
|
2015-05-02 14:34:53 +02:00
|
|
|
release_tag = tools.get_catalog_tag_from_id(release.ident)
|
2015-03-14 22:38:12 +01:00
|
|
|
releases_and_infos.append({
|
|
|
|
"id": release.id,
|
|
|
|
"release_type": release.release_type,
|
2015-05-02 14:34:53 +02:00
|
|
|
"tag": release_tag,
|
2015-03-14 22:38:12 +01:00
|
|
|
"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)
|
|
|
|
|
|
|
|
|
2015-05-02 14:34:53 +02:00
|
|
|
def release(request, tag):
|
|
|
|
ident = tools.get_id_from_catalog_tag(tag)
|
|
|
|
release = get_object_or_404(Release, ident = ident)
|
2015-03-14 22:38:12 +01:00
|
|
|
contribs = tools.get_contribs(release.contributors.all())
|
|
|
|
context = { "release": release, "contribs": contribs }
|
|
|
|
return render(request, "label/release.html", context)
|