map item to topiks using pages
authorFrédéric Péters <fpeters@0d.be>
Thu, 11 Jun 2020 09:25:15 +0000 (11:25 +0200)
committerFrédéric Péters <fpeters@0d.be>
Thu, 11 Jun 2020 09:25:15 +0000 (11:25 +0200)
panikombo/management/commands/map-item-topik.py

index 2799499..61b765c 100644 (file)
@@ -2,19 +2,20 @@ from django.core.management.base import BaseCommand, CommandError
 
 from emissions.models import NewsItem, Episode
 
-from combo.data.models import CellBase
-from panikombo.models import Topik, ItemTopik
+from combo.data.models import Page, CellBase
+from panikombo.models import ItemTopik
+
 
 class Command(BaseCommand):
     def handle(self, *args, **kwargs):
         remaining_item_topik = set(ItemTopik.objects.all())
-        for topik in Topik.objects.all():
-            cells = CellBase.get_cells(page=topik.page)
+        for topik_page in Page.objects.exclude(picture__isnull=True):
+            cells = CellBase.get_cells(page=topik_page)
             for cell in cells:
                 if not hasattr(cell, 'get_included_items'):
                     continue
                 for item in cell.get_included_items():
-                    kwargs = {'topik': topik}
+                    kwargs = {'page': topik_page}
                     if isinstance(item, NewsItem):
                         kwargs['newsitem'] = item
                     elif isinstance(item, Episode):