Commit 04c0a080 authored by Gink's avatar Gink

Adds artist and album view, but no search yet

> /artist/<id>
> /album/<id>
parent d10d7cff
......@@ -57,6 +57,17 @@ def search(request):
}
return render(request, 'search'+type+'.html', context)
def artist_profile(request, identifier):
result = artist.objects.filter(id = identifier)
albums = album.objects.filter(artist = identifier)
return render(request, 'artist.html', {'result': result[0], 'albums': albums})
def album_profile(request, identifier):
result = album.objects.filter(id = identifier)
artist_name = result[0].artist.name
songs = song.objects.filter(album = identifier)
return render(request, 'album.html', {'result':result[0], 'songs': songs, 'artist': artist_name})
# def search(request,term):
# results = album.objects.filter(album_name__contains = term)
# custom()
......
......@@ -104,7 +104,7 @@ body {
margin-top: 2vh;
}
.a {
a, .link{
color: white;
}
......
......@@ -27,6 +27,8 @@ urlpatterns = [
# url(r'^search_by_(?P<type>[A-Za-z0-9-+_.@]+)/?search=(?P<term>[A-Za-z0-9-+_.@]+)/$',core_views.search, name='search'),
url(r'^search/$',core_views.search, name='search'),
url(r'^album/(?P<identifier>[0-9]+)/$', core_views.album_profile, name='album_profile'),
url(r'^artist/(?P<identifier>[0-9]+)/$', core_views.artist_profile, name='artist_profile'),
# url(r'^search/(?P<term>[A-Za-z0-9-+_.@]+)/$',core_views.search, name='search'),
url(r'^profile/(?P<slug>[A-Za-z0-9-+_.@]+)/$', core_views.user_profile_page, name='viewprofile'),
......
{% extends 'base.html' %}
{% block title %}{{result.name}}{% endblock %}
{% block sidebar %}
<h2> Album info </h2>
<p>
Album: {{result.name}} <br>
Artist: {{artist_name}} <br>
Year: {{result.year}} <br>
{% endblock %}
{% block content %}
{% for i in songs %}
<div class = "boxified main">
<h3> {{i.song_name}} </h3>
<p> Genre: {{i.genre}} </p>
</div>
{% endfor %}
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% block title %}{{result.name}}{% endblock %}
{% block sidebar %}
<h2> Artist info </h2>
<p>
Artist: {{result.name}} <br>
Albums: {{albums.count}} <br>
<br>
<h2> Description </h2>
{{result.description}}
{% endblock %}
{% block content %}
{% for i in albums %}
<div class = "boxified main">
<h3> <a class = "link" href= "/album/{{i.id}}"> {{i.album_name}} </a></h3>
<p> Year: {{i.year}} </p>
</div>
{% endfor %}
{% endblock %}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment