views.py 885 Bytes
Newer Older
fred's avatar
fred committed
1 2 3 4
import datetime

from django.core.urlresolvers import reverse
from django.views.generic.base import RedirectView
fred's avatar
fred committed
5
from django.views.generic.dates import DayArchiveView
fred's avatar
fred committed
6
from django.views.generic.detail import DetailView
fred's avatar
fred committed
7

fred's avatar
fred committed
8
from .models import SomaLogLine, Track, Artist
fred's avatar
fred committed
9 10 11 12 13 14

class SomaDayArchiveView(DayArchiveView):
    queryset = SomaLogLine.objects.all()
    date_field = "play_timestamp"
    make_object_list = True
    allow_future = False
fred's avatar
fred committed
15 16 17 18 19 20 21 22 23 24
    month_format = '%m'


class RedirectTodayView(RedirectView):
    def get_redirect_url(self, *args, **kwargs):
        today = datetime.datetime.today()
        return reverse('archive_day', kwargs={
                        'year': today.year,
                        'month': today.month,
                        'day': today.day})
fred's avatar
fred committed
25 26 27 28


class TrackDetailView(DetailView):
    model = Track
fred's avatar
fred committed
29 30 31 32


class ArtistDetailView(DetailView):
    model = Artist