def deserialize_user_data(user_data, programs):
"""
Deserializes a dict of mixed User/Profile data and returns the newly-inserted User
"""
username = FAKE_USER_USERNAME_PREFIX + user_data['email'].split('@')[0]
user = deserialize_model_data(User, user_data, username=username)
# Create social username
user.social_auth.create(
provider=EdxOrgOAuth2.name,
uid=user.username,
)
# The user data is generated in this script with mute_signals(post_save)
# so we need to create the profile explicitly.
profile = deserialize_model_data(Profile, user_data, user=user, fake_user=True)
deserialize_profile_detail_data(profile, Employment, user_data['work_history'])
deserialize_profile_detail_data(profile, Education, user_data['education'])
deserialize_dashboard_data(user, user_data, programs)
ensure_cached_data_freshness(user)
return user
评论列表
文章目录