fix selection of past/future episodes
authorFrédéric Péters <fpeters@0d.be>
Mon, 23 Nov 2015 18:27:37 +0000 (19:27 +0100)
committerFrédéric Péters <fpeters@0d.be>
Mon, 23 Nov 2015 18:27:37 +0000 (19:27 +0100)
panikombo/models.py

index 38da84b..3a74383 100644 (file)
@@ -114,16 +114,16 @@ class EpisodeAutoSelectionCell(CellBase):
                     select={ 'first_diffusion': 'emissions_diffusion.datetime', },
                     select_params=(False, True),
                     where=['''datetime = (SELECT MIN(datetime) FROM emissions_diffusion
-                                           WHERE episode_id = emissions_episode.id AND
-                                                 emissions_diffusion.datetime >= CURRENT_TIMESTAMP)'''],
+                                           WHERE episode_id = emissions_episode.id) AND
+                                                 datetime >= CURRENT_TIMESTAMP'''],
                     tables=['emissions_diffusion'])
         elif self.period == 2:
             episodes_queryset = episodes_queryset.extra(
                     select={ 'first_diffusion': 'emissions_diffusion.datetime', },
                     select_params=(False, True),
                     where=['''datetime = (SELECT MIN(datetime) FROM emissions_diffusion
-                                           WHERE episode_id = emissions_episode.id AND
-                                                 emissions_diffusion.datetime < CURRENT_TIMESTAMP)'''],
+                                           WHERE episode_id = emissions_episode.id) AND
+                                                 datetime < CURRENT_TIMESTAMP'''],
                     tables=['emissions_diffusion'])
 
         return episodes_queryset