diff --git a/auth/__init__.py b/auth/__init__.py new file mode 100644 index 00000000..7d4fb480 --- /dev/null +++ b/auth/__init__.py @@ -0,0 +1,3 @@ +from auth.email import load_email_templates + +load_email_templates() diff --git a/migrate.py b/migrate.py index 1bec3a73..3e386c9a 100644 --- a/migrate.py +++ b/migrate.py @@ -90,7 +90,7 @@ def topics(export_topics, topics_by_slug, topics_by_oid, cats_data, tags_data): topic = migrateTag(tag) 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 + # if not topics_by_slug.get(topic['slug']): topics_by_slug[topic['slug']] = topic counter += 1 for cat in cats_data: old_id = cat["createdBy"] @@ -98,10 +98,11 @@ def topics(export_topics, topics_by_slug, topics_by_oid, cats_data, tags_data): try: topic = migrateCategory(cat) 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 counter += 1 - export_topics = dict(topics_by_title.items()) + for t in topics_by_title.values(): + topics_by_slug[t['slug']] = t + export_topics = dict(topics_by_slug.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 759f8549..8059470b 100644 --- a/migration/tables/content_items.py +++ b/migration/tables/content_items.py @@ -110,7 +110,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!') diff --git a/migration/tables/users.py b/migration/tables/users.py index 287d7814..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'] - if entry.get('subscribedTo', '') != '': 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']))