Commit 88f62b7e authored by fred's avatar fred

add track view

parent 11ac959f
from django.core.urlresolvers import reverse
from django.db import models
from django.utils.translation import ugettext_lazy as _
......@@ -28,6 +29,9 @@ class Track(models.Model):
sabam = models.BooleanField('SABAM', default=True)
cfwb = models.BooleanField('CFWB', default=False)
def get_absolute_url(self):
return reverse('track-view', kwargs={'pk': self.id})
class NonstopFile(models.Model):
filepath = models.CharField(_('Filepath'), max_length=255)
......
......@@ -9,8 +9,10 @@
<ul class="soma-list">
{% for somalog in object_list %}
<li><span class="timestamp">{{ somalog.play_timestamp|date:"H:i" }}</span>:
<span class="tracktitle">{{ somalog.filepath.track.title }}</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>
{% endif %}
<span class="filepath">{{ somalog.filepath.short }}</span>
</li>
{% endfor %}
......
{% extends "base.html" %}
{% block appbar %}
<h2>Nonstop - Track: {{ object.title }}</h2>
{% endblock %}
{% block content %}
<p>
{{ object.artist.name }}
</p>
{% endblock %}
from django.conf.urls import url
from .views import SomaDayArchiveView, RedirectTodayView
from .views import SomaDayArchiveView, RedirectTodayView, TrackDetailView
urlpatterns = [
# Example: /2012/nov/10/
url(r'^$', RedirectTodayView.as_view()),
url(r'^tracks/(?P<pk>\d+)/$', TrackDetailView.as_view(), name='track-view'),
url(r'^(?P<year>[0-9]{4})/(?P<month>[-\w]+)/(?P<day>[0-9]+)/$',
SomaDayArchiveView.as_view(),
name="archive_day"),
......
......@@ -3,8 +3,9 @@ import datetime
from django.core.urlresolvers import reverse
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
from .models import SomaLogLine, Track
class SomaDayArchiveView(DayArchiveView):
queryset = SomaLogLine.objects.all()
......@@ -21,3 +22,7 @@ class RedirectTodayView(RedirectView):
'year': today.year,
'month': today.month,
'day': today.day})
class TrackDetailView(DetailView):
model = Track
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