1
0
mirror of https://github.com/Damillora/Altessimo synced 2024-10-31 21:17:32 +00:00
Altessimo/artists/views.py

21 lines
989 B
Python
Raw Normal View History

2020-12-15 21:32:20 +00:00
from django.shortcuts import render
# Create your views here.
2020-12-16 17:36:29 +00:00
from .models import Artist
from songs.models import OutsideSong
def artist_index(request):
artists = Artist.objects.all()
return render(request,'artists/index.html',{'artists':artists})
def artist_show(request, slug):
artist = Artist.objects.filter(slug=slug)[0]
2020-12-17 07:12:26 +00:00
credit_songs = artist.written_songs.all() | artist.composed_songs.all() | artist.arranged_songs.all()
aliases = artist.aliases.all()
2020-12-16 17:36:29 +00:00
outside_songs = OutsideSong.objects.filter(composer=artist)
2020-12-17 07:12:26 +00:00
for alias in aliases:
credit_songs = credit_songs | alias.written_songs.all() | artist.composed_songs.all() | artist.arranged_songs.all()
outside_songs = outside_songs | OutsideSong.objects.filter(composer=alias)
credit_songs = credit_songs.distinct()
outside_songs = outside_songs.distinct()
2020-12-16 17:36:29 +00:00
return render(request,'artists/show.html',{'artist': artist,'credit_songs':credit_songs,'outside_songs':outside_songs})