Don't create new person for new user, if one was selected

This commit is contained in:
Lance Edgar 2021-01-14 12:10:35 -06:00
parent 758d5e6f4c
commit 5e9264bbef

View file

@ -274,15 +274,20 @@ class UsersView(PrincipalMasterView):
names['last'] = data['last_name_'] names['last'] = data['last_name_']
if 'display_name_' in form: if 'display_name_' in form:
names['display'] = data['display_name_'] 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 # note, do *not* create new person unless name(s) provided
if not user.person and any([n for n in names.values()]): if not user.person and any([n for n in names.values()]):
user.person = model.Person() user.person = model.Person()
if user.person: if user.person:
if 'first' in names: if names.get('first'):
user.person.first_name = names['first'] user.person.first_name = names['first']
if 'last' in names: if names.get('last'):
user.person.last_name = names['last'] user.person.last_name = names['last']
if 'display' in names: if names.get('display'):
user.person.display_name = names['display'] user.person.display_name = names['display']
# force "local only" flag unless global access granted # force "local only" flag unless global access granted