diff --git a/migrate.py b/migrate.py index 5f381715..66cd43e1 100644 --- a/migrate.py +++ b/migrate.py @@ -87,7 +87,7 @@ def topics(export_topics, topics_by_slug, topics_by_oid, cats_data, tags_data): old_id = tag["createdBy"] tag["createdBy"] = user_id_map.get(old_id, 0) topic = migrateTag(tag) - topics_by_title[topic['title']] = topic + #topics_by_title[topic['title']] = topic topics_by_oid[topic['tag_id']] = topic if not topics_by_slug.get(topic['slug']): topics_by_slug[topic['slug']] = topic counter += 1 @@ -98,9 +98,9 @@ def topics(export_topics, topics_by_slug, topics_by_oid, cats_data, tags_data): except Exception as e: raise e topics_by_oid[topic['cat_id']] = topic topics_by_slug[topic['slug']] = topic - topics_by_title[topic['title']] = topic + #topics_by_title[topic['title']] = topic counter += 1 - export_topics = dict(topics_by_title.items()) + #export_topics = dict(topics_by_title.items()) def shouts(content_data, shouts_by_slug, shouts_by_oid): ''' migrating content items one by one ''' diff --git a/migration/tables/content_items.py b/migration/tables/content_items.py index 78d1c3b8..d6de8c96 100644 --- a/migration/tables/content_items.py +++ b/migration/tables/content_items.py @@ -109,7 +109,7 @@ def migrate(entry, users_by_oid, topics_by_oid): if entry.get('type') == 'Literature': media = entry.get('media', '') # print(media[0]['literatureBody']) - if type(media) == list: + if type(media) == list and media: body_orig = media[0].get('literatureBody', '') if body_orig == '': print('EMPTY BODY!') @@ -191,7 +191,7 @@ def migrate(entry, users_by_oid, topics_by_oid): metadata = get_metadata(shout_dict) content = frontmatter.dumps(frontmatter.Post(body, **metadata)) ext = 'mdx' - open('../discoursio-web/content/' + r['layout'] + '/' + r['slug'] + '.' + ext, 'w').write(content) + #open('../discoursio-web/content/' + r['layout'] + '/' + r['slug'] + '.' + ext, 'w').write(content) try: shout_dict['createdAt'] = date_parse(r.get('createdAt')) if entry.get('createdAt') else ts shout_dict['publishedAt'] = date_parse(entry.get('publishedAt')) if entry.get('published') else None diff --git a/migration/tables/users.py b/migration/tables/users.py index 69ee89d1..f40f942e 100644 --- a/migration/tables/users.py +++ b/migration/tables/users.py @@ -34,7 +34,8 @@ def migrate(entry): res['old_id'] = entry['_id'] res['password'] = entry['services']['password'].get('bcrypt', '') del entry['services'] - del entry['subscribedTo'] + if 'subscribedTo' in entry: #TODO: use subscribedTo + del entry['subscribedTo'] res['username'] = entry['emails'][0]['address'] res['email'] = res['username'] res['wasOnlineAt'] = parse(entry.get('loggedInAt', entry['createdAt']))