Commit e8ed4c31 authored by fred's avatar fred

add day archive view

parent 657fb216
from django.db import models
from django.utils.translation import ugettext_lazy as _
REMOTE_BASE_PATH = '/srv/soma/nonstop/'
class Artist(models.Model):
name = models.CharField(_('Name'), max_length=255)
......@@ -32,6 +34,10 @@ class NonstopFile(models.Model):
creation_timestamp = models.DateTimeField(auto_now_add=True, null=True)
track = models.ForeignKey(Track, null=True)
@property
def short(self):
return self.filepath[len(REMOTE_BASE_PATH):]
class SomaLogLine(models.Model):
class Meta:
......
{% extends "base.html" %}
{% block appbar %}
<h2>Nonstop - {{ day|date:"d/m/Y" }}</h2>
{% endblock %}
{% block content %}
<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>
<span class="trackartist">({{ somalog.filepath.track.artist.name }})</span>
<span class="filepath">{{ somalog.filepath.short }}</span>
</li>
{% endfor %}
</ul>
<p>
{% if previous_day %}
Previous Day: {{ previous_day }}
{% endif %}
{% if previous_day and next_day %}--{% endif %}
{% if next_day %}
Next Day: {{ next_day }}
{% endif %}
</p>
{% endblock %}
from django.conf.urls import url
from .views import SomaDayArchiveView
urlpatterns = [
# Example: /2012/nov/10/
url(r'^(?P<year>[0-9]{4})/(?P<month>[-\w]+)/(?P<day>[0-9]+)/$',
SomaDayArchiveView.as_view(),
name="archive_day"),
]
from django.views.generic.dates import DayArchiveView
from .models import SomaLogLine
class SomaDayArchiveView(DayArchiveView):
queryset = SomaLogLine.objects.all()
date_field = "play_timestamp"
make_object_list = True
allow_future = False
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