From 30d80f522e734ab916609745a27e2f6e413e58b2 Mon Sep 17 00:00:00 2001 From: Dan Braghis <dan.braghis@torchbox.com> Date: Thu, 1 Mar 2018 10:41:43 +0000 Subject: [PATCH] Further simplification --- .../users/management/commands/migrate_users.py | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/opentech/apply/users/management/commands/migrate_users.py b/opentech/apply/users/management/commands/migrate_users.py index 3beff4ed2..f77444311 100644 --- a/opentech/apply/users/management/commands/migrate_users.py +++ b/opentech/apply/users/management/commands/migrate_users.py @@ -28,7 +28,7 @@ class Command(BaseCommand): full_name = self.get_full_name(user) user_object, created = User.objects.get_or_create( - email=user.get('mail'), + email=user['mail'], defaults={ 'full_name': full_name, 'drupal_id': uid, @@ -49,18 +49,11 @@ class Command(BaseCommand): def get_full_name(self, user): full_name = user.get('field_otf_real_name', None) try: - """ - Drupal is i18n-ready out of the box. As such, the data - structure includes a language reference, defaulting to 'und' (undefined) - In addition to that, most fields are arrays indexed by language, and - the value delta. Different field types will have a different value. - Native entity fields are loaded directly (as string or int). They are - things like entity id, owner, created/updated timestamp. - And name/mail on users. - """ + # The Drupal data structure includes a language reference. + # The default is 'und' (undefined). full_name = full_name['und'][0]['safe_value'] except (KeyError, TypeError): - full_name = user.get('name') + full_name = user['name'] return full_name -- GitLab