Commit 9d62fedb authored by fred's avatar fred

add view listing artists

parent f37d410f
......@@ -8,6 +8,9 @@ REMOTE_BASE_PATH = '/srv/soma/nonstop/'
class Artist(models.Model):
name = models.CharField(_('Name'), max_length=255)
class Meta:
ordering = ['name']
def get_absolute_url(self):
return reverse('artist-view', kwargs={'pk': self.id})
......
{% extends "base.html" %}
{% load i18n %}
{% block appbar %}
<h2>Nonstop - Artists</h2>
{% endblock %}
{% block content %}
<ul class="artists-list">
{% for artist in object_list %}
<li><a href="{% url 'artist-view' pk=artist.id %}">{{ artist.name }}</a></li>
{% endfor %}
</ul>
{% endblock %}
from django.conf.urls import url
from .views import SomaDayArchiveView, SomaDayArchiveCsvView, RedirectTodayView, TrackDetailView, ArtistDetailView
from .views import SomaDayArchiveView, SomaDayArchiveCsvView, RedirectTodayView, TrackDetailView, ArtistDetailView, ArtistListView
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/$', ArtistListView.as_view(), name='artist-list'),
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(),
......
......@@ -7,6 +7,7 @@ from django.http import HttpResponse
from django.views.generic.base import RedirectView
from django.views.generic.dates import DayArchiveView
from django.views.generic.detail import DetailView
from django.views.generic.list import ListView
from .models import SomaLogLine, Track, Artist
......@@ -52,3 +53,7 @@ class TrackDetailView(DetailView):
class ArtistDetailView(DetailView):
model = Artist
class ArtistListView(ListView):
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