Skip to content

Commit

Permalink
put in some null checks for an optional address
Browse files Browse the repository at this point in the history
  • Loading branch information
taraepp committed Nov 14, 2024
1 parent 7670a16 commit d0d8628
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ class ProjectSummary(SoftDeleteMixin, AuditMixin, Base):
def __get_address_type_code(cls, address_data):
if isinstance(address_data, list):
return address_data[0].get('address_type_code')
return address_data.get('address_type_code')
return address_data.get('address_type_code', None) if address_data else None

def __repr__(self):
return f'{self.__class__.__name__} {self.project_summary_id}'
Expand Down Expand Up @@ -297,7 +297,7 @@ def create_or_update_party(cls, party_data, job_title_code, existing_party):
address_type_code=addr.get('address_type_code'),
)
new_party.address.append(new_address)
else:
elif address_data is not None:
new_address = Address.create(
suite_no=address_data.get('suite_no'),
address_line_1=address_data.get('address_line_1'),
Expand Down

0 comments on commit d0d8628

Please sign in to comment.