From 3e796e91642469b1f1735a61dddcd33c732eed23 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Sun, 10 Oct 2021 20:24:26 -0400 Subject: [PATCH] Fix bug when making context for mailing address sometimes those belong to a non-person, e.g. customer --- tailbone/views/people.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tailbone/views/people.py b/tailbone/views/people.py index 3a54559d..8e8374c4 100644 --- a/tailbone/views/people.py +++ b/tailbone/views/people.py @@ -515,8 +515,7 @@ class PersonView(MasterView): return context def get_context_address(self, address): - person = address.person - return { + context = { 'uuid': address.uuid, 'street': address.street, 'street2': address.street2, @@ -524,9 +523,15 @@ class PersonView(MasterView): 'state': address.state, 'zipcode': address.zipcode, 'display': six.text_type(address), - 'invalid': self.handler.address_is_invalid(person, address), } + model = self.model + if isinstance(address, model.PersonMailingAddress): + person = address.person + context['invalid'] = self.handler.address_is_invalid(person, address) + + return context + def get_context_customers(self, person): data = [] for cp in person._customers: