add community for topics
This commit is contained in:
parent
d0fdfd2b31
commit
2a9d0d613f
|
@ -1,7 +1,7 @@
|
||||||
import json
|
import json
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from orm.base import local_session
|
from orm.base import local_session
|
||||||
from orm import Topic
|
from orm import Topic, Community
|
||||||
from dateutil.parser import parse as date_parse
|
from dateutil.parser import parse as date_parse
|
||||||
|
|
||||||
def migrate(entry):
|
def migrate(entry):
|
||||||
|
@ -25,7 +25,8 @@ def migrate(entry):
|
||||||
# 'createdAt': ts,
|
# 'createdAt': ts,
|
||||||
'title': entry['title'].lower(),
|
'title': entry['title'].lower(),
|
||||||
'parents': [],
|
'parents': [],
|
||||||
'children': []
|
'children': [],
|
||||||
|
'community' : Community.default_community.slug
|
||||||
}
|
}
|
||||||
try:
|
try:
|
||||||
with local_session() as session:
|
with local_session() as session:
|
||||||
|
|
|
@ -31,5 +31,5 @@ class Topic(Base):
|
||||||
parents = relationship(lambda: Topic, secondary=Connection, primaryjoin=slug==Connection.c.parent, secondaryjoin=slug==Connection.c.child, viewonly=True)
|
parents = relationship(lambda: Topic, secondary=Connection, primaryjoin=slug==Connection.c.parent, secondaryjoin=slug==Connection.c.child, viewonly=True)
|
||||||
# list of Topics where the current node is the "parent"
|
# list of Topics where the current node is the "parent"
|
||||||
children = relationship(lambda: Topic, secondary=Connection, primaryjoin=slug==Connection.c.child, secondaryjoin=slug==Connection.c.parent)
|
children = relationship(lambda: Topic, secondary=Connection, primaryjoin=slug==Connection.c.child, secondaryjoin=slug==Connection.c.parent)
|
||||||
community = Column(ForeignKey("community.slug"), nullable=True, comment="Community")
|
community = Column(ForeignKey("community.slug"), nullable=False, comment="Community")
|
||||||
|
|
||||||
|
|
|
@ -332,6 +332,7 @@ type Topic {
|
||||||
parents: [String] # NOTE: topic can have parent topics
|
parents: [String] # NOTE: topic can have parent topics
|
||||||
children: [String] # and children
|
children: [String] # and children
|
||||||
cat_id: String
|
cat_id: String
|
||||||
|
community: String
|
||||||
}
|
}
|
||||||
|
|
||||||
# TODO: resolvers to add/remove topics from publication
|
# TODO: resolvers to add/remove topics from publication
|
||||||
|
|
Loading…
Reference in New Issue
Block a user