From 2814e4d71a69a4e98e59d23284fc23fedf9bf9f0 Mon Sep 17 00:00:00 2001 From: Quinten Steenhuis Date: Fri, 19 Jan 2024 10:40:07 -0500 Subject: [PATCH 1/3] Fix #816 - don't pass 'bare' parameter unless it's an ALAddress --- docassemble/AssemblyLine/al_general.py | 55 +++++++++++++++++--------- 1 file changed, 37 insertions(+), 18 deletions(-) diff --git a/docassemble/AssemblyLine/al_general.py b/docassemble/AssemblyLine/al_general.py index ba7bf6d7..20591064 100644 --- a/docassemble/AssemblyLine/al_general.py +++ b/docassemble/AssemblyLine/al_general.py @@ -712,7 +712,7 @@ def names_and_addresses_on_one_line( """ return comma_and_list( [ - str(person) + ", " + person.address.on_one_line(bare=bare) + str(person) + ", " + (person.address.on_one_line(bare=bare) if isinstance(person.address, ALAddress) else str(person.address.on_one_line())) for person in self ], comma_string=comma_string, @@ -1436,29 +1436,48 @@ def address_block( str: The formatted address block. """ if this_thread.evaluation_context == "docx": - return ( - self.name.full() - + '' - + self.address.block( + if isinstance(self.address, ALAddress): + return self.address.block( language=language, international=international, show_country=show_country, bare=bare, show_impounded=show_impounded, ) - ) - return ( - "[FLUSHLEFT] " - + self.name.full() - + " [NEWLINE] " - + self.address.block( - language=language, - international=international, - show_country=show_country, - bare=bare, - show_impounded=show_impounded, - ) - ) + else: + # bare parameter is ignored for plain Address objects + return self.address.block( + language=language, + international=international, + show_country=show_country, + show_impounded=show_impounded, + ) + else: + if isinstance(self.address, ALAddress): + return ( + "[FLUSHLEFT] " + + self.name.full() + + " [NEWLINE] " + + self.address.block( + language=language, + international=international, + show_country=show_country, + bare=bare, + show_impounded=show_impounded, + ) + ) + else: + return ( + "[FLUSHLEFT] " + + self.name.full() + + " [NEWLINE] " + + self.address.block( + language=language, + international=international, + show_country=show_country, + show_impounded=show_impounded, + ) + ) def pronoun(self, **kwargs) -> str: """Returns an objective pronoun as appropriate, based on attributes. From 38fb410a55d0c03baeb7c7765451ab70c94a8829 Mon Sep 17 00:00:00 2001 From: Quinten Steenhuis Date: Fri, 19 Jan 2024 10:49:20 -0500 Subject: [PATCH 2/3] Fix formatting with Black --- docassemble/AssemblyLine/al_general.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/docassemble/AssemblyLine/al_general.py b/docassemble/AssemblyLine/al_general.py index 20591064..fa2fc493 100644 --- a/docassemble/AssemblyLine/al_general.py +++ b/docassemble/AssemblyLine/al_general.py @@ -712,7 +712,13 @@ def names_and_addresses_on_one_line( """ return comma_and_list( [ - str(person) + ", " + (person.address.on_one_line(bare=bare) if isinstance(person.address, ALAddress) else str(person.address.on_one_line())) + str(person) + + ", " + + ( + person.address.on_one_line(bare=bare) + if isinstance(person.address, ALAddress) + else str(person.address.on_one_line()) + ) for person in self ], comma_string=comma_string, From 0c3f3c9824f515f5706b13d7e5c1572ba5247c9c Mon Sep 17 00:00:00 2001 From: Quinten Steenhuis Date: Fri, 19 Jan 2024 13:11:11 -0500 Subject: [PATCH 3/3] Also don't use show_impounded on plain Address --- docassemble/AssemblyLine/al_general.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/docassemble/AssemblyLine/al_general.py b/docassemble/AssemblyLine/al_general.py index fa2fc493..78c7d45b 100644 --- a/docassemble/AssemblyLine/al_general.py +++ b/docassemble/AssemblyLine/al_general.py @@ -1456,7 +1456,6 @@ def address_block( language=language, international=international, show_country=show_country, - show_impounded=show_impounded, ) else: if isinstance(self.address, ALAddress): @@ -1481,7 +1480,6 @@ def address_block( language=language, international=international, show_country=show_country, - show_impounded=show_impounded, ) )