TODO-migration-fixed-topic-connection

This commit is contained in:
tonyrewin 2022-07-01 11:39:08 +03:00
parent e60e5691b3
commit d4e456470e
4 changed files with 4 additions and 2 deletions

View File

@ -19,7 +19,7 @@ def load_email_templates():
filename = "templates/%s.tmpl" % name
with open(filename) as f:
email_templates[name] = f.read()
print("all email templates loaded")
print("[email.service] templates loaded")
async def send_confirm_email(user):
text = email_templates["confirm_email"]

View File

@ -29,6 +29,7 @@ def migrate(entry, topics_by_oid):
with local_session() as session:
slug = topics_by_oid.get(topic_dict['oid'], topic_dict)['slug']
if slug:
slug = retopics.get(slug, slug)
try:
topic = session.query(Topic).filter(Topic.slug == slug).first()
if not topic:

View File

@ -263,9 +263,9 @@ def migrate(entry, users_by_oid, topics_by_oid):
shout_dict['topics'] = []
for topic in r['topics']:
try:
ShoutTopic.create(**{ 'shout': s.slug, 'topic': topic['slug'] })
tpc = topics_by_oid[topic['oid']]
slug = retopics.get(tpc['slug'], tpc['slug'])
ShoutTopic.create(**{ 'shout': s.slug, 'topic': slug })
shout_dict['topics'].append(slug)
except sqlalchemy.exc.IntegrityError:
pass

View File

@ -33,6 +33,7 @@ def migrate(entry, topics_by_oid):
retopics = json.loads(open('migration/tables/replacements.json').read())
with local_session() as session:
slug = topics_by_oid.get(topic_dict['oid'], topic_dict)['slug']
slug = retopics.get(slug, slug)
if slug:
topic = session.query(Topic).filter(Topic.slug == slug).first()
if not topic: