From 6b7631013d53c67769cacab89ae0a6a1e08eded2 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Wed, 21 Nov 2018 19:56:01 -0600 Subject: [PATCH] Remove some relationship fields when creating new Person --- tailbone/views/people.py | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/tailbone/views/people.py b/tailbone/views/people.py index bab450d4..e5b96ef1 100644 --- a/tailbone/views/people.py +++ b/tailbone/views/people.py @@ -153,14 +153,26 @@ class PeopleView(MasterView): f.set_readonly('address') f.set_label('address', "Mailing Address") - f.set_readonly('employee') - f.set_renderer('employee', self.render_employee) + # employee + if self.creating: + f.remove_field('employee') + else: + f.set_readonly('employee') + f.set_renderer('employee', self.render_employee) - f.set_readonly('customers') - f.set_renderer('customers', self.render_customers) + # customers + if self.creating: + f.remove_field('customers') + else: + f.set_readonly('customers') + f.set_renderer('customers', self.render_customers) - f.set_readonly('users') - f.set_renderer('users', self.render_users) + # users + if self.creating: + f.remove_field('users') + else: + f.set_readonly('users') + f.set_renderer('users', self.render_users) def render_employee(self, person, field): employee = person.employee