Merge pull request #2999 from bison/user-location
Add user location metadata filed
This commit is contained in:
commit
62971b7f20
11 changed files with 79 additions and 15 deletions
|
@ -135,6 +135,7 @@ def user_view(user, previous_username=None):
|
|||
'company': user.company,
|
||||
'family_name': user.family_name,
|
||||
'given_name': user.given_name,
|
||||
'location': user.location,
|
||||
})
|
||||
|
||||
analytics_metadata = user_analytics.get_user_analytics_metadata(user)
|
||||
|
@ -246,6 +247,10 @@ class User(ApiResource):
|
|||
'type': 'string',
|
||||
'description': 'The optional entered company for the user',
|
||||
},
|
||||
'location': {
|
||||
'type': 'string',
|
||||
'description': 'The optional entered location for the user',
|
||||
},
|
||||
},
|
||||
},
|
||||
'UserView': {
|
||||
|
@ -362,14 +367,21 @@ class User(ApiResource):
|
|||
model.user.update_email(user, new_email, auto_verify=not features.MAILING)
|
||||
|
||||
if features.USER_METADATA:
|
||||
if 'given_name' in user_data or 'family_name' in user_data or 'company' in user_data:
|
||||
model.user.update_user_metadata(user, user_data.get('given_name'),
|
||||
user_data.get('family_name'), user_data.get('company'))
|
||||
metadata_fields = ('given_name', 'family_name', 'company', 'location')
|
||||
if any(field in user_data for field in metadata_fields):
|
||||
model.user.update_user_metadata(user, {
|
||||
'given_name': user_data.get('given_name'),
|
||||
'family_name': user_data.get('family_name'),
|
||||
'company': user_data.get('company'),
|
||||
'location': user_data.get('location'),
|
||||
})
|
||||
|
||||
ua_mdata_future = user_analytics.change_metadata(
|
||||
user.email,
|
||||
user_data.get('given_name'),
|
||||
user_data.get('family_name'),
|
||||
user_data.get('company'),
|
||||
user_data.get('location'),
|
||||
)
|
||||
ua_mdata_future.add_done_callback(build_error_callback('Change metadata failed'))
|
||||
|
||||
|
|
|
@ -51,6 +51,7 @@ def common_login(user_uuid, permanent_session=True):
|
|||
user.given_name,
|
||||
user.family_name,
|
||||
user.company,
|
||||
user.location,
|
||||
)
|
||||
create_lead_future.add_done_callback(build_error_callback('Create lead failed'))
|
||||
return True
|
||||
|
|
|
@ -4,7 +4,11 @@ from collections import namedtuple
|
|||
from six import add_metaclass
|
||||
|
||||
|
||||
class User(namedtuple('User', ['uuid', 'username', 'email', 'given_name', 'family_name', 'company'])):
|
||||
USER_FIELDS = ['uuid', 'username', 'email', 'given_name',
|
||||
'family_name', 'company', 'location']
|
||||
|
||||
|
||||
class User(namedtuple('User', USER_FIELDS)):
|
||||
"""
|
||||
User represents a user.
|
||||
"""
|
||||
|
|
|
@ -9,7 +9,8 @@ class EndpointsCommonDataPreOCIModel(EndpointsCommonDataInterface):
|
|||
return None
|
||||
|
||||
return User(uuid=user.uuid, username=user.username, email=user.email,
|
||||
given_name=user.given_name, family_name=user.family_name, company=user.company)
|
||||
given_name=user.given_name, family_name=user.family_name,
|
||||
company=user.company, location=user.location)
|
||||
|
||||
def get_namespace_uuid(self, namespace_name):
|
||||
user = model.user.get_namespace_user(namespace_name)
|
||||
|
|
Reference in a new issue