Skip to content

Commit

Permalink
[SF2035] Change processing user data for the current project (#20)
Browse files Browse the repository at this point in the history
**Description:**
- Change processing user data for the current project

**YouTrack:**
[SF2035-5](https://youtrack.raccoongang.com/issue/SF2035-5)
  • Loading branch information
arsentur authored and Igor Degtiarov committed Nov 11, 2019
1 parent 54395fe commit 14f7107
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions edx_oauth_client/pipeline.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
import datetime
from logging import getLogger

from student.forms import AccountCreationForm
Expand Down Expand Up @@ -38,11 +39,22 @@ def ensure_user_information(

# Received fields could be pretty different from the expected, mandatory are only 'username' and 'email'
data['username'] = user_data.get('username', user_data.get('name'))
data['first_name'] = user_data.get('firstName', user_data.get('first_name'))
data['last_name'] = user_data.get('lastName', user_data.get('last_name'))
data['first_name'] = user_data.get('firstname', user_data.get('first_name'))
data['last_name'] = user_data.get('lastname', user_data.get('last_name'))
data['email'] = user_data.get('email')
data['country'] = country
data['access_token'] = access_token

date_of_birth = user_data.get('date_of_birth')

if date_of_birth is not None:
data['year_of_birth'] = datetime.datetime.strptime(date_of_birth, '%d.%m.%Y').year

# User API provide two possible variants "male" or "female", with are strings.
# We need extract only first letter and save it to the user profile model.
if user_data.get('gender'):
data['gender'] = user_data.get('gender')[0]

if any((data['first_name'], data['last_name'])):
data['name'] = u'{} {}'.format(data['first_name'], data['last_name']).strip()
else:
Expand Down

0 comments on commit 14f7107

Please sign in to comment.