We are no longer offering accounts on this server. Consider https://gitlab.freedesktop.org/ as a place to host projects.

Commit 1f59a25f authored by Daniel Watkins's avatar Daniel Watkins

Add now playing stuff to front page.

parent ecf685c1
......@@ -132,6 +132,10 @@ class NowPlaying(models.Model):
user = models.OneToOneField(GobblerUser, primary_key=True)
track = models.ForeignKey(Track)
@property
def artist(self):
return self.track.album.artist
def __unicode__(self):
return "%s is playing %s" % (self.user, self.track)
......
......@@ -6,6 +6,20 @@
network service that will allow users to share their musical tastes with other
people.</p>
<h3>Now playing</h3>
<ul id="nowplaying" class="listcloud">
{% for np in now_playing %}
<li>
<dl>
<dt><a href="{{ np.artist.get_absolute_url }}">{{ np.artist }}</a></dt>
<dd><a href="{{ np.track.get_absolute_url }}">{{ np.track.name }}</a></dd>
<dd><a href="/profile/{{ np.user }}/">{{ np.user }}</a></dd>
</dl>
</li>
{% endfor %}
</ul>
<h3>What's hot? Recently gobbled.</h3>
<ul id="recenttracks" class="listcloud">
......
......@@ -19,7 +19,7 @@ from django.db.models import Count
from django.shortcuts import get_object_or_404, render_to_response
from django.template import RequestContext
from gobbler.models import Album, Artist, Gobble, GobblerUser
from gobbler.models import Album, Artist, Gobble, GobblerUser, NowPlaying
def album(request, artist_slug, album_slug):
......@@ -47,9 +47,11 @@ def explore_artists(request):
def frontpage(request):
now_playing = NowPlaying.objects.all()
recent_gobbles = Gobble.objects.order_by('-id')[:10]
return render_to_response("frontpage.html",
{'recently_gobbled': recent_gobbles},
{'recently_gobbled': recent_gobbles,
'now_playing': now_playing},
context_instance=RequestContext(request))
......
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