Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
django-panik-nonstop
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
radiopanik
django-panik-nonstop
Commits
02207c48
Commit
02207c48
authored
Nov 01, 2014
by
fred
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
redirect nonstop home to current day
parent
e8ed4c31
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
1 deletion
+16
-1
nonstop/urls.py
nonstop/urls.py
+2
-1
nonstop/views.py
nonstop/views.py
+14
-0
No files found.
nonstop/urls.py
View file @
02207c48
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"
),
...
...
nonstop/views.py
View file @
02207c48
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
})
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment