Commit 4853b9ea authored by fred's avatar fred

add times to grid lines

parent a06c092e
from django import template
register = template.Library()
@register.filter(name='zip')
def zip_lists(a, b):
return zip(a, b)
......@@ -125,6 +125,7 @@ INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.admindocs',
'panikweb_templates',
'panikweb.paniktags',
'jquery',
'ckeditor',
'emissions',
......
......@@ -54,6 +54,10 @@ class Grid(TemplateView):
nb_lines = 2 * 24 # the cells are half hours
grid = []
times = ['%02d:%02d' % (x/2, x%2*30) for x in range(nb_lines)]
# grid starts at 5am
times = times[2*5:] + times[:2*5]
nonstops = [[0, 2, 'Biodiversite'],
[2, 5, 'Reveries'],
[5, 7.5, 'La Panique'],
......@@ -90,7 +94,7 @@ class Grid(TemplateView):
# start grid at 5am
grid = grid[2*5:] + grid[:2*5]
# merge adjencent cells
# merge adjacent cells
for i in range(nb_lines):
for j, cell in enumerate(grid[i]):
if grid[i][j] is None:
......@@ -124,6 +128,7 @@ class Grid(TemplateView):
pass
context['grid'] = grid
context['times'] = times
return context
......
{% extends "base.html" %}
{% load paniktags %}
{% block content %}
<h2>Grille</h2>
<table border=1>
{% for time_cells in grid %}
{% for time_header, time_cells in times|zip:grid %}
<tr>
<td>ti:me</td>
<td>{{ time_header }}</td>
{% for cell in time_cells %}
<td {% if cell.w > 1 %}colspan="{{cell.w}}"{% endif %}
{% if cell.h > 1 %}rowspan="{{cell.h}}"{% endif %}>{{ cell }}</td>
{% endfor %}
<td>ti:me</td>
<td>{{ time_header }}</td>
</tr>
{% endfor %}
</table>
......
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