Commit 24b9164e authored by Simon Daron's avatar Simon Daron
Browse files

Fixing week nav in program

parent 64011afe
from datetime import datetime, timedelta
import time
import math
from django.views.generic.base import TemplateView
......@@ -96,14 +97,21 @@ class ProgramView(TemplateView):
context = super(ProgramView, self).get_context_data(**kwargs)
context['sectionName'] = "emissions"
schedules = Schedule.objects.select_related().order_by('datetime')
week = int(week)
year = int(year)
days = []
for day in range(7):
days.append({'schedules': [x for x in schedules if x.is_on_weekday(day+1)],
'datetime': datetime(2007, 1, day+1)})
context['days'] = days
context['weekday'] = datetime.today().weekday()
context['week'] = week if week else datetime.today().isocalendar()[1]-1
context['year'] = year = year if year else datetime.today().year
context['week'] = week if week is not None else datetime.today().isocalendar()[1]-1
context['week'] = week if week is not None else datetime.today().isocalendar()[1]-1
context['year'] = year if year is not None else datetime.today().year
context['week_first_day'] = datetime.strptime(str(year)+' '+str(week)+' 1', '%Y %U %w')
context['week_last_day'] = context['week_first_day'] + timedelta(days=+6)
context['week_previous'] = context['week_first_day'] + timedelta(days=-7)
context['week_next'] = context['week_last_day']
return context
program = ProgramView.as_view()
......
<nav>
<ul class="inline">
<li><a href="{% url 'emissions' %}" class="{% if class != "program" or class != "grid" %}active{% endif %}">
<li><a href="{% url 'emissions' %}" class="{% if class != "program" and class != "grid" %}active{% endif %}">
<span class="icon-microphone" ></span>
<span class="iconLabel">Emissions</span>
</a></li>
......
......@@ -4,27 +4,27 @@
{% block title %}Programme{% endblock %}
{% block nav %}
{% emission_nav with klass="program" %}
{% if week %}
<div class="program">
<nav class="center">
<ul class="custom distributed">
{% if week_previous %}
<li>
<a
href="{% url 'program_week' year=year week=week|add:"-1" %}"
href="{% url 'program_week' year=week_previous|date:"Y" week=week_previous|date:"W" %}"
class="icon-chevron-sign-left"
></a>
</li>
<li>Semaine {{ week }}</li>
{% endif %}
<li>Du {{week_first_day|date:"l j N"}} au {{week_last_day|date:"l j N"}}</li>
<li>
<a
href="{% url 'program_week' year=year week=week|add:"1" %}"
href="{% url 'program_week' year=week_last_day|date:"Y" week=week_last_day|date:"W" %}"
class="icon-chevron-sign-right"
></a>
</li>
</ul>
</nav>
</div>
{% endif %}
{% weekview year=year week=week fragment="nav" %}
{% endblock %}
{% block main %}
......
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