From e8bd745d82f2f191fe5269209414385ea3ab4700 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Thu, 11 Jun 2020 11:25:15 +0200 Subject: [PATCH] map item to topiks using pages --- panikombo/management/commands/map-item-topik.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/panikombo/management/commands/map-item-topik.py b/panikombo/management/commands/map-item-topik.py index 2799499..61b765c 100644 --- a/panikombo/management/commands/map-item-topik.py +++ b/panikombo/management/commands/map-item-topik.py @@ -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): -- 2.39.2