From 6463c08c83fea3c744ca5bfdd31699bffd118e4f Mon Sep 17 00:00:00 2001
From: Christian Pointner <equinox@spreadspace.org>
Date: Wed, 15 Feb 2012 23:06:22 +0100
Subject: only show active program_slots at show_detail


diff --git a/program/models.py b/program/models.py
index 0b78347..9197837 100644
--- a/program/models.py
+++ b/program/models.py
@@ -239,6 +239,12 @@ class ProgramSlot(models.Model):
         return self.timeslots.count()
     timeslot_count.description = _("Time slot count")
 
+    def has_active_timeslot(self):
+        start = self.timeslots.all().order_by("start")[0].start
+        end = self.timeslots.all().order_by("-end")[0].end
+        now = datetime.now()
+        return (start < now and end > now)
+
 class TimeSlotManager(models.Manager):
     def get_or_create_current(self):
         try:
diff --git a/templates/program/show_detail.html b/templates/program/show_detail.html
index b5c5f91..8337155 100644
--- a/templates/program/show_detail.html
+++ b/templates/program/show_detail.html
@@ -14,7 +14,9 @@
     {% if show.id != 1 %}
       <p id="programslots">
       {% for slot in show.programslots.all %}
-        <span class="programslot">{{ slot }}</span><br />
+        {% if slot.has_active_timeslot %}
+          <span class="programslot">{{ slot }}</span><br />
+        {% endif %}
       {% endfor %}
       </p>
     {% endif %}
-- 
cgit v0.10.2