Skip to content
Snippets Groups Projects
Commit 42d35abc authored by Dan Braghis's avatar Dan Braghis
Browse files

Change migration to OTF-provided export

parent d78c3dad
No related branches found
No related tags found
No related merge requests found
...@@ -9,7 +9,7 @@ class Command(BaseCommand): ...@@ -9,7 +9,7 @@ class Command(BaseCommand):
help = "User migration script. Requires a source JSON file." help = "User migration script. Requires a source JSON file."
def add_arguments(self, parser): def add_arguments(self, parser):
parser.add_argument('source', nargs='?', type=argparse.FileType('r')) parser.add_argument('source', nargs='?', type=argparse.FileType('r'), help='Migration source JSON file')
parser.add_argument( parser.add_argument(
'--dry-run', '--dry-run',
action='store_true', action='store_true',
...@@ -22,8 +22,14 @@ class Command(BaseCommand): ...@@ -22,8 +22,14 @@ class Command(BaseCommand):
User = get_user_model() User = get_user_model()
users = json.load(json_data) users = json.load(json_data)
for user in users: from pprint import pprint
for uid in users:
user = users[uid]
full_name = user.get('field_otf_real_name', None) full_name = user.get('field_otf_real_name', None)
if isinstance(name, dict) and 'und' in name:
full_name = name['und'][0]['safe_value']
if not full_name: if not full_name:
full_name = user.get('name') full_name = user.get('name')
...@@ -33,4 +39,4 @@ class Command(BaseCommand): ...@@ -33,4 +39,4 @@ class Command(BaseCommand):
) )
if created: if created:
print("Imported user %s (%s)" % (user['uid'], full_name)) print("Imported user %s (%s)" % (uid, full_name))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment