]> git.0d.be Git - panikweb.git/blobdiff - panikweb/views.py
do not crash grid display when there's no nonstop zone
[panikweb.git] / panikweb / views.py
index 520a88255d7bb25d9d2bdcfe299a41981c34f4f8..270ee501e911c1e80e30725e15f4582dc5e0331d 100644 (file)
@@ -404,11 +404,14 @@ class Grid(TemplateView):
             for j in range(7):
                 grid[-1].append(TimeCell(i, j))
 
-            nonstop = [x for x in nonstops if i >= x[0] * 2 and i < x[1] * 2][0]
+            try:
+                nonstop = [x for x in nonstops if i >= x[0] * 2 and i < x[1] * 2][0]
+            except IndexError:
+                nonstop = [0, 24, '', '', None]
             for time_cell in grid[-1]:
                 time_cell.nonstop = nonstop[2]
                 time_cell.nonstop_slug = nonstop[3]
-                time_cell.redirect_path = nonstop[4].redirect_path
+                time_cell.redirect_path = nonstop[4].redirect_path if nonstop[4] else None
                 if nonstop[1] == Schedule.DAY_HOUR_START + Schedule.DAY_MINUTE_START / 60:
                     # the one ending at 4:30am will be cut down, so we inscribe
                     # its duration manually