Commit 9ea1d6eb authored by fred's avatar fred

add artist view

parent 88f62b7e
......@@ -8,6 +8,12 @@ REMOTE_BASE_PATH = '/srv/soma/nonstop/'
class Artist(models.Model):
name = models.CharField(_('Name'), max_length=255)
def get_absolute_url(self):
return reverse('artist-view', kwargs={'pk': self.id})
def recent_diffusions(self):
return SomaLogLine.objects.filter(filepath__track__artist=self).order_by('-play_timestamp')
class Album(models.Model):
name = models.CharField(_('Name'), max_length=255)
......@@ -32,6 +38,9 @@ class Track(models.Model):
def get_absolute_url(self):
return reverse('track-view', kwargs={'pk': self.id})
def recent_diffusions(self):
return SomaLogLine.objects.filter(filepath__track=self).order_by('-play_timestamp')
class NonstopFile(models.Model):
filepath = models.CharField(_('Filepath'), max_length=255)
......
{% extends "base.html" %}
{% block appbar %}
<h2>Nonstop - Artist: {{ object.name }}</h2>
{% endblock %}
{% block content %}
<ul class="soma-list">
{% for somalog in object.recent_diffusions|slice:":10" %}
<li><span class="timestamp">{{ somalog.play_timestamp|date:"d/m/Y H:i" }}</span>:
{% if somalog.filepath.track %}
<a href="{{ somalog.filepath.track.get_absolute_url }}" class="tracktitle">{{ somalog.filepath.track.title }}</a>
<span class="trackartist">(<a href="{{ somalog.filepath.track.artist.get_absolute_url }}" class="trackartist">{{ somalog.filepath.track.artist.name }}</a>)</span>
{% endif %}
<span class="filepath">{{ somalog.filepath.short }}</span>
</li>
{% endfor %}
</ul>
{% endblock %}
......@@ -11,7 +11,7 @@
<li><span class="timestamp">{{ somalog.play_timestamp|date:"H:i" }}</span>:
{% if somalog.filepath.track %}
<a href="{{ somalog.filepath.track.get_absolute_url }}" class="tracktitle">{{ somalog.filepath.track.title }}</a>
<span class="trackartist">({{ somalog.filepath.track.artist.name }})</span>
<span class="trackartist">(<a href="{{ somalog.filepath.track.artist.get_absolute_url }}" class="trackartist">{{ somalog.filepath.track.artist.name }}</a>)</span>
{% endif %}
<span class="filepath">{{ somalog.filepath.short }}</span>
</li>
......@@ -20,11 +20,11 @@
<p>
{% if previous_day %}
Previous Day: {{ previous_day }}
<a href="{% url 'archive_day' year=previous_day.year month=previous_day.month day=previous_day.day %}">Previous Day</a>
{% endif %}
{% if previous_day and next_day %}--{% endif %}
{% if next_day %}
Next Day: {{ next_day }}
<a href="{% url 'archive_day' year=next_day.year month=next_day.month day=next_day.day %}">Next Day</a>
{% endif %}
</p>
......
{% extends "base.html" %}
{% block appbar %}
<h2>Nonstop - Track: {{ object.title }}</h2>
<h2>Nonstop - Track: {{ object.artist.name }} / {{ object.title }}</h2>
{% endblock %}
{% block content %}
<p>
{{ object.artist.name }}
</p>
<ul class="soma-list">
{% for somalog in object.recent_diffusions|slice:":10" %}
<li><span class="timestamp">{{ somalog.play_timestamp|date:"d/m/Y H:i" }}</span>:
{% if somalog.filepath.track %}
<a href="{{ somalog.filepath.track.get_absolute_url }}" class="tracktitle">{{ somalog.filepath.track.title }}</a>
<span class="trackartist">(<a href="{{ somalog.filepath.track.artist.get_absolute_url }}" class="trackartist">{{ somalog.filepath.track.artist.name }}</a>)</span>
{% endif %}
<span class="filepath">{{ somalog.filepath.short }}</span>
</li>
{% endfor %}
</ul>
{% endblock %}
from django.conf.urls import url
from .views import SomaDayArchiveView, RedirectTodayView, TrackDetailView
from .views import SomaDayArchiveView, RedirectTodayView, TrackDetailView, ArtistDetailView
urlpatterns = [
# Example: /2012/nov/10/
url(r'^$', RedirectTodayView.as_view()),
url(r'^tracks/(?P<pk>\d+)/$', TrackDetailView.as_view(), name='track-view'),
url(r'^artists/(?P<pk>\d+)/$', ArtistDetailView.as_view(), name='artist-view'),
url(r'^(?P<year>[0-9]{4})/(?P<month>[-\w]+)/(?P<day>[0-9]+)/$',
SomaDayArchiveView.as_view(),
name="archive_day"),
......
......@@ -5,7 +5,7 @@ from django.views.generic.base import RedirectView
from django.views.generic.dates import DayArchiveView
from django.views.generic.detail import DetailView
from .models import SomaLogLine, Track
from .models import SomaLogLine, Track, Artist
class SomaDayArchiveView(DayArchiveView):
queryset = SomaLogLine.objects.all()
......@@ -26,3 +26,7 @@ class RedirectTodayView(RedirectView):
class TrackDetailView(DetailView):
model = Track
class ArtistDetailView(DetailView):
model = Artist
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