From 5e9264bbefcc704c7f317a010b5f35b2d411001e Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Thu, 14 Jan 2021 12:10:35 -0600 Subject: [PATCH] Don't create new person for new user, if one was selected --- tailbone/views/users.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) 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