]> git.0d.be Git - django-panik-combo.git/blobdiff - panikombo/management/commands/map-item-topik.py
map item to topiks using pages
[django-panik-combo.git] / panikombo / management / commands / map-item-topik.py
index 27994999d5742421219f18edeeacacc3e9a97ecd..61b765cce520588914945adf3c24c3ecc3bd029a 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):