diff --git a/tailbone/views/users.py b/tailbone/views/users.py index 310967eb..127d3491 100644 --- a/tailbone/views/users.py +++ b/tailbone/views/users.py @@ -274,15 +274,20 @@ class UsersView(PrincipalMasterView): names['last'] = data['last_name_'] if 'display_name_' in form: names['display'] = data['display_name_'] + # we will not have a person reference yet, when creating new user. if + # that is the case, go ahead and load it, if specified. + if self.creating and user.person_uuid: + self.Session.add(user) + self.Session.flush() # note, do *not* create new person unless name(s) provided if not user.person and any([n for n in names.values()]): user.person = model.Person() if user.person: - if 'first' in names: + if names.get('first'): user.person.first_name = names['first'] - if 'last' in names: + if names.get('last'): user.person.last_name = names['last'] - if 'display' in names: + if names.get('display'): user.person.display_name = names['display'] # force "local only" flag unless global access granted