Commit 02207c48 authored by fred's avatar fred

redirect nonstop home to current day

parent e8ed4c31
from django.conf.urls import url
from .views import SomaDayArchiveView
from .views import SomaDayArchiveView, RedirectTodayView
urlpatterns = [
# Example: /2012/nov/10/
url(r'^$', RedirectTodayView.as_view()),
url(r'^(?P<year>[0-9]{4})/(?P<month>[-\w]+)/(?P<day>[0-9]+)/$',
SomaDayArchiveView.as_view(),
name="archive_day"),
......
import datetime
from django.core.urlresolvers import reverse
from django.views.generic.base import RedirectView
from django.views.generic.dates import DayArchiveView
from .models import SomaLogLine
......@@ -7,3 +11,13 @@ class SomaDayArchiveView(DayArchiveView):
date_field = "play_timestamp"
make_object_list = True
allow_future = False
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})
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