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

Further simplification

parent 8502d66d
No related branches found
No related tags found
No related merge requests found
...@@ -28,7 +28,7 @@ class Command(BaseCommand): ...@@ -28,7 +28,7 @@ class Command(BaseCommand):
full_name = self.get_full_name(user) full_name = self.get_full_name(user)
user_object, created = User.objects.get_or_create( user_object, created = User.objects.get_or_create(
email=user.get('mail'), email=user['mail'],
defaults={ defaults={
'full_name': full_name, 'full_name': full_name,
'drupal_id': uid, 'drupal_id': uid,
...@@ -49,18 +49,11 @@ class Command(BaseCommand): ...@@ -49,18 +49,11 @@ class Command(BaseCommand):
def get_full_name(self, user): def get_full_name(self, user):
full_name = user.get('field_otf_real_name', None) full_name = user.get('field_otf_real_name', None)
try: try:
""" # The Drupal data structure includes a language reference.
Drupal is i18n-ready out of the box. As such, the data # The default is 'und' (undefined).
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.
"""
full_name = full_name['und'][0]['safe_value'] full_name = full_name['und'][0]['safe_value']
except (KeyError, TypeError): except (KeyError, TypeError):
full_name = user.get('name') full_name = user['name']
return full_name return 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