don't get anything for unconfigured auto cells
authorFrédéric Péters <fpeters@0d.be>
Wed, 27 Apr 2016 14:56:37 +0000 (16:56 +0200)
committerFrédéric Péters <fpeters@0d.be>
Wed, 27 Apr 2016 14:56:37 +0000 (16:56 +0200)
panikombo/models.py

index 3a74383..5588962 100644 (file)
@@ -132,9 +132,12 @@ class EpisodeAutoSelectionCell(CellBase):
         tmpl = template.loader.get_template('panikombo/episode_auto_selection.html')
         context['title'] = self.title
 
-        episodes_queryset = self.get_included_items()
-        episodes_queryset = episodes_queryset.order_by('-first_diffusion').distinct()
-        context['episodes'] = episodes_queryset
+        if (self.category or self.period or self.tags.count()):
+            episodes_queryset = self.get_included_items()
+            episodes_queryset = episodes_queryset.order_by('-first_diffusion').distinct()
+            context['episodes'] = episodes_queryset
+        else:
+            context['episodes'] = []
         return tmpl.render(context)
 
     def get_default_form_class(self):
@@ -171,7 +174,10 @@ class NewsItemAutoSelectionCell(CellBase):
     def render(self, context):
         tmpl = template.loader.get_template('panikombo/newsitem_auto_selection.html')
         context['title'] = self.title
-        context['newsitems'] = self.get_included_items()
+        if self.tags.count() or self.future or self.category:
+            context['newsitems'] = self.get_included_items()
+        else:
+            context['newsitems'] = []
         return tmpl.render(context)
 
     def get_default_form_class(self):