Commit 824ac781 authored by fred's avatar fred
Browse files

add a program view

parent e298d2b4
......@@ -7,6 +7,7 @@ admin.autodiscover()
urlpatterns = patterns('',
url(r'^$', 'panikweb.views.home', name='home'),
url(r'^program$', 'panikweb.views.program', name='program'),
url(r'^emissions/', include('emissions.urls')),
url(r'^ckeditor/', include('ckeditor.urls')),
......
import datetime
from django.views.generic.base import TemplateView
from emissions.models import Emission
from emissions.models import Emission, Schedule
class ProgramView(TemplateView):
template_name = 'program.html'
def get_context_data(self, **kwargs):
context = super(ProgramView, self).get_context_data(**kwargs)
schedules = Schedule.objects.all().order_by('datetime')
days = []
for day in range(7):
days.append({'schedules': [x for x in schedules if x.is_on_weekday(day+1)],
'datetime': datetime.datetime(2007, 1, day+1)})
context['days'] = days
return context
program = ProgramView.as_view()
class Home(TemplateView):
template_name = 'home.html'
......
......@@ -14,9 +14,9 @@
<body>
<div id="top-links">
<a href="#">Home</a>
<a href="{% url 'home' %}">Home</a>
<a href="#">About Us</a>
<a href="#">Programme</a>
<a href="{% url 'program' %}">Programme</a>
<a href="#">Media</a>
<a href="#">Newsletter</a>
<span>Recherche <input/></span>
......
{% extends "base.html" %}
{% block content %}
<h2>Programme</h2>
<div id="tabs">
<ul>
{% for day in days %}
<li><a href="#tabs-{{ day.datetime|date:"w" }}">{{ day.datetime|date:"D" }}</a></li>
{% endfor %}
</ul>
{% for day in days %}
<div id="tabs-{{ day.datetime|date:"w" }}">
<ul class="emission-list">
{% for schedule in day.schedules %}
<li>{{ schedule.datetime|date:"H:i" }} <a href="{% url 'emission-view' slug=schedule.emission.slug %}">{{ schedule.emission.title }}</a></li>
{% endfor %}
</ul>
</div>
{% endfor %}
</div>
{% endblock %}
{% block pageend %}
<script>
$(function() {
$("#tabs").tabs();
});
</script>
{% endblock %}
Supports Markdown
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