diff --git a/migration/tables/content_items.py b/migration/tables/content_items.py index 707b9326..3adfebcd 100644 --- a/migration/tables/content_items.py +++ b/migration/tables/content_items.py @@ -90,7 +90,11 @@ def migrate(entry, users_by_oid, topics_by_oid): # print(entry) raise Exception - topic_oids = set(entry['category']) + category = entry['category'] + mainTopic = topics_by_oid.get(category) + if mainTopic: + r['mainTopic'] = mainTopic["slug"] + topic_oids = set(category) topic_oids.update(entry.get("tags", [])) for oid in topic_oids: if oid in topics_by_oid: diff --git a/orm/shout.py b/orm/shout.py index 223579a1..58d35edf 100644 --- a/orm/shout.py +++ b/orm/shout.py @@ -293,4 +293,5 @@ class Shout(Base): layout: str = Column(String, nullable = True) authors = relationship(lambda: User, secondary=ShoutAuthor.__tablename__) # NOTE: multiple authors topics = relationship(lambda: Topic, secondary=ShoutTopic.__tablename__) + mainTopic = Column(ForeignKey("topic.slug"), nullable=True) visibleFor = relationship(lambda: User, secondary=ShoutViewer.__tablename__)