]> git.0d.be Git - panikweb.git/commitdiff
add times to grid lines
authorFrédéric Péters <fpeters@0d.be>
Wed, 14 Aug 2013 19:26:03 +0000 (21:26 +0200)
committerFrédéric Péters <fpeters@0d.be>
Wed, 14 Aug 2013 19:26:03 +0000 (21:26 +0200)
panikweb/paniktags/__init__.py [new file with mode: 0644]
panikweb/paniktags/templatetags/__init__.py [new file with mode: 0644]
panikweb/paniktags/templatetags/paniktags.py [new file with mode: 0644]
panikweb/settings.py
panikweb/views.py
panikweb_templates/templates/grid.html

diff --git a/panikweb/paniktags/__init__.py b/panikweb/paniktags/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/panikweb/paniktags/templatetags/__init__.py b/panikweb/paniktags/templatetags/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/panikweb/paniktags/templatetags/paniktags.py b/panikweb/paniktags/templatetags/paniktags.py
new file mode 100644 (file)
index 0000000..b2a9b13
--- /dev/null
@@ -0,0 +1,7 @@
+from django import template
+
+register = template.Library()
+
+@register.filter(name='zip')
+def zip_lists(a, b):
+      return zip(a, b)
index d156f16ed561987967f0127a296f267a72ffa552..9347479ef45717b12cbe37e6bda719ee066999bc 100644 (file)
@@ -125,6 +125,7 @@ INSTALLED_APPS = (
     'django.contrib.admin',
     'django.contrib.admindocs',
     'panikweb_templates',
+    'panikweb.paniktags',
     'jquery',
     'ckeditor',
     'emissions',
index d1321d90835935d8299c10aee9974836efed97a4..c3bc298bf651b4907655ef7db290364040f10baf 100644 (file)
@@ -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
 
index 8de5b573fc354b0b386fbdacfa3e3cd7ad9dee3d..478388d2de99d146ca030bec81de1f5aca0b5161 100644 (file)
@@ -1,18 +1,19 @@
 {% 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>