Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
radiopanik
panikweb
Commits
f66d8e64
Commit
f66d8e64
authored
Aug 27, 2013
by
fred
Browse files
add sample week view
parent
5861e6bb
Changes
3
Hide whitespace changes
Inline
Side-by-side
panikweb/urls.py
View file @
f66d8e64
...
...
@@ -11,6 +11,7 @@ urlpatterns = patterns('',
url
(
r
'^$'
,
'panikweb.views.home'
,
name
=
'home'
),
url
(
r
'^onair.json$'
,
'panikweb.views.onair'
,
name
=
'onair'
),
url
(
r
'^program$'
,
'panikweb.views.program'
,
name
=
'program'
),
url
(
r
'^(?P<year>\d{4})/(?P<week>\d+)/$'
,
'panikweb.views.week'
,
name
=
'program_week'
),
url
(
r
'^grid$'
,
'panikweb.views.grid'
,
name
=
'grid'
),
url
(
r
'^emissions/$'
,
'panikweb.views.emissions'
,
name
=
'emissions'
),
url
(
r
'^emissions/'
,
include
(
'emissions.urls'
)),
...
...
panikweb/views.py
View file @
f66d8e64
...
...
@@ -4,13 +4,14 @@ import math
from
django.views.generic.base
import
TemplateView
from
django.views.generic.detail
import
DetailView
from
django.views.decorators.csrf
import
csrf_exempt
from
django.views.generic.dates
import
_date_from_string
from
jsonresponse
import
to_json
from
emissions.models
import
Category
,
Emission
,
Episode
,
Diffusion
,
SoundFile
,
\
Schedule
,
Nonstop
,
NewsItem
,
NewsCategory
from
emissions.utils
import
whatsonair
from
emissions.utils
import
whatsonair
,
period_program
class
ProgramView
(
TemplateView
):
template_name
=
'program.html'
...
...
@@ -27,6 +28,26 @@ class ProgramView(TemplateView):
program
=
ProgramView
.
as_view
()
class
ProgramWeekView
(
TemplateView
):
template_name
=
'week.html'
def
get_context_data
(
self
,
year
,
week
,
**
kwargs
):
context
=
super
(
ProgramWeekView
,
self
).
get_context_data
(
**
kwargs
)
date
=
_date_from_string
(
year
,
'%Y'
,
'1'
,
'%w'
,
week
,
'%W'
)
date
=
datetime
(
*
date
.
timetuple
()[:
3
])
program
=
period_program
(
date
,
date
+
timedelta
(
days
=
7
))
days
=
[]
for
day
in
range
(
7
):
days
.
append
({
'cells'
:
[
x
for
x
in
program
if
x
.
is_on_weekday
(
day
+
1
)],
'datetime'
:
date
+
timedelta
(
days
=
day
)})
context
[
'days'
]
=
days
return
context
week
=
ProgramWeekView
.
as_view
()
class
TimeCell
:
nonstop
=
None
w
=
1
...
...
panikweb_templates/templates/week.html
0 → 100644
View file @
f66d8e64
{% block main %}
{% for day in days %}
<h2>
{{ day.datetime|date:"D Y-m-d" }}
</h2>
<ul>
{% for cell in day.cells %}
<li>
{{ cell.datetime|date:"H:i" }} -
{% if cell.episode %}
{{ cell.episode.emission.title }} - {{ cell.episode.title }}
{% elif cell.emission %}
{{ cell.emission.title }}
{% endif %}
</li>
{% endfor %}
</ul>
{% endfor %}
{% endblock %}
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