]> git.0d.be Git - panikweb.git/commitdiff
grid: use new durations and week numbers to add more info
authorFrédéric Péters <fpeters@0d.be>
Fri, 16 Aug 2013 11:45:28 +0000 (13:45 +0200)
committerFrédéric Péters <fpeters@0d.be>
Fri, 16 Aug 2013 12:20:28 +0000 (14:20 +0200)
panikweb/views.py
panikweb_templates/templates/grid.html

index d0dd230ecc8e1f8789d324d57cc873718953aa19..63be5953ee1a97dbd5599c09532c99763e1c32c8 100644 (file)
@@ -25,18 +25,26 @@ class TimeCell:
     nonstop = None
     w = 1
     h = 1
+    time_label = None
 
     def __init__(self, i, j):
         self.x = i
         self.y = j
-        self.emissions = []
-
-    def add_emission(self, emission):
-        self.emissions.append(emission)
+        self.schedules = []
+
+    def add_schedule(self, schedule):
+        end_time = schedule.datetime + datetime.timedelta(
+                minutes=schedule.emission.duration)
+        self.time_label = '%02d:%02d-%02d:%02d' % (
+                schedule.datetime.hour,
+                schedule.datetime.minute,
+                end_time.hour,
+                end_time.minute)
+        self.schedules.append(schedule)
 
     def __unicode__(self):
-        if self.emissions:
-            return ', '.join([x.title for x in self.emissions])
+        if self.schedules:
+            return ', '.join([x.emission.title for x in self.schedules])
         else:
             return self.nonstop
 
@@ -87,7 +95,7 @@ class Grid(TemplateView):
             for step in range(int(math.ceil(schedule.emission.duration / 30))):
                 if grid[(row_start+step)%nb_lines][day_no] is None:
                     grid[(row_start+step)%nb_lines][day_no] = TimeCell()
-                grid[(row_start+step)%nb_lines][day_no].add_emission(schedule.emission)
+                grid[(row_start+step)%nb_lines][day_no].add_schedule(schedule)
 
         # start grid at 5am
         grid = grid[2*5:] + grid[:2*5]
index 4dc2f273dfc7dbc51d833286eaf15eaf16495272..92d40cd038c45d1de6b015909b7b59e7a2ee7afb 100644 (file)
         font-size:15px;
     }
 
+    #grille h3 {
+       width: 100%;
+    }
+
     #grille .jour {
         margin-top:20px;
         margin-bottom:30px;
   <td class="heure">{{ 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>
+      {% if cell.h > 1 %}rowspan="{{cell.h}}"{% endif %}>
+      {% if cell.time_label %}<h5>{{ cell.time_label }}</h5>{% endif %}
+      {% if cell.schedules %}
+        {% for schedule in cell.schedules %}
+        <h4>{{ schedule.emission.title }}</h4>
+        {% if schedule.weeks_string %}
+          ({{ schedule.weeks_string }})
+        {% endif %}
+        {% endfor %}
+      {% else %}
+        <h3 class="continu">{{ cell }}</h3>
+        {% if cell.w > 1 and cell.h > 1%}<p>la musique en continu</p>{% endif %}
+      {% endif %}
+  </td>
   {% endfor %}
   <td class="heure">{{ time_header }}</td>
 </tr>