Fix bug in users view when person field not present

This commit is contained in:
Lance Edgar 2018-02-22 13:25:20 -06:00
parent f2a60f683c
commit 2c2df9f01e

View file

@ -142,20 +142,21 @@ class UsersView(PrincipalMasterView):
# person # person
f.set_renderer('person', self.render_person) f.set_renderer('person', self.render_person)
if self.creating or self.editing: if self.creating or self.editing:
f.replace('person', 'person_uuid') if 'person' in f.fields:
f.set_node('person_uuid', colander.String(), missing=colander.null) f.replace('person', 'person_uuid')
person_display = "" f.set_node('person_uuid', colander.String(), missing=colander.null)
if self.request.method == 'POST': person_display = ""
if self.request.POST.get('person_uuid'): if self.request.method == 'POST':
person = self.Session.query(model.Person).get(self.request.POST['person_uuid']) if self.request.POST.get('person_uuid'):
if person: person = self.Session.query(model.Person).get(self.request.POST['person_uuid'])
person_display = six.text_type(person) if person:
elif self.editing: person_display = six.text_type(person)
person_display = six.text_type(user.person or '') elif self.editing:
people_url = self.request.route_url('people.autocomplete') person_display = six.text_type(user.person or '')
f.set_widget('person_uuid', forms.widgets.JQueryAutocompleteWidget( people_url = self.request.route_url('people.autocomplete')
field_display=person_display, service_url=people_url)) f.set_widget('person_uuid', forms.widgets.JQueryAutocompleteWidget(
f.set_label('person_uuid', "Person") field_display=person_display, service_url=people_url))
f.set_label('person_uuid', "Person")
# password # password
f.set_widget('password', dfwidget.CheckedPasswordWidget()) f.set_widget('password', dfwidget.CheckedPasswordWidget())