From 4c67d1df4ad66c071c04693ee54b90f4a98f2ecf Mon Sep 17 00:00:00 2001 From: Quinten Steenhuis Date: Tue, 18 Nov 2025 13:48:55 -0500 Subject: [PATCH 1/5] Fix #989 - use translatable blocks for download_list_html, not hardcoded strings --- docassemble/AssemblyLine/al_document.py | 34 ++++++++++++++----- .../data/questions/ql_baseline.yml | 18 +++++++++- 2 files changed, 43 insertions(+), 9 deletions(-) diff --git a/docassemble/AssemblyLine/al_document.py b/docassemble/AssemblyLine/al_document.py index 8f8d1c9e..9f5498c7 100644 --- a/docassemble/AssemblyLine/al_document.py +++ b/docassemble/AssemblyLine/al_document.py @@ -29,6 +29,7 @@ DAStaticFile, alpha, showifdef, + word, ) from docassemble.base.pdfa import pdf_to_pdfa from textwrap import wrap @@ -2008,11 +2009,11 @@ def download_list_html( refresh: bool = True, pdfa: bool = False, include_zip: bool = True, - view_label="View", + view_label: Optional[str] = None, view_icon: str = "eye", - download_label: str = "Download", + download_label: Optional[str] = None, download_icon: str = "download", - send_label: str = "Send", + send_label: Optional[str] = None, send_icon: str = "envelope", zip_label: Optional[str] = None, zip_icon: str = "file-archive", @@ -2035,11 +2036,11 @@ def download_list_html( refresh (bool): Flag to reconsider the 'enabled' attribute, default is True. pdfa (bool): Flag to return documents in PDF/A format, default is False. include_zip (bool): Flag to include a zip option, default is True. - view_label (str): Label for the 'view' button, default is "View". + view_label (str): Label for the 'view' button, default is self.view_label or "View". view_icon (str): Icon for the 'view' button, default is "eye". - download_label (str): Label for the 'download' button, default is "Download". + download_label (str): Label for the 'download' button, default is self.download_label or "Download". download_icon (str): Icon for the 'download' button, default is "download". - send_label (str): Label for the 'send' button. Default is "Send". + send_label (str): Label for the 'send' button. Default is self.send_label or "Send". send_icon (str): Fontawesome icon for the 'send' button. Default is "envelope". zip_label (Optional[str]): Label for the zip option. If not provided, uses the generic template for `self.zip_label` ("Download all"). zip_icon (str): Icon for the zip option, default is "file-archive". @@ -2062,6 +2063,15 @@ def download_list_html( if not hasattr(self, "_cached_full_pdf_label"): self._cached_full_pdf_label = str(self.full_pdf_label) + if not view_label: + view_label = self.view_label or word("View") + + if not download_label: + download_label = self.download_label or word("Download") + + if not send_label: + send_label = self.send_label or word("Send") + if zip_format is None: zip_format = format @@ -2251,12 +2261,14 @@ def download_html( return html def send_email_table_row( - self, key: str = "final", send_label: str = "Send", send_icon: str = "envelope" + self, key: str = "final", send_label: Optional[str] = None, send_icon: str = "envelope" ) -> str: """ Generate HTML doc table row for an input box and button that allows someone to send the bundle to the specified email address. + This should normally only be called by download_list_html. + Args: key (str): A key used to identify which version of the ALDocument to send. Defaults to "final". send_label (str): Label for the 'send' button. Default is "Send". @@ -2265,6 +2277,9 @@ def send_email_table_row( Returns: str: The generated HTML string for the table row. """ + if not send_label: + send_label = self.send_label or word("Send") + if not self.has_enabled_documents(): return "" # Don't let people email an empty set of documents if not hasattr(self, "_cached_get_email_copy"): @@ -2310,7 +2325,7 @@ def send_button_to_html( email: str, editable: Optional[bool] = None, template_name: str = "", - label: str = "Send", + label: Optional[str] = None, icon: str = "envelope", color: str = "primary", key: str = "final", @@ -2334,6 +2349,9 @@ def send_button_to_html( Returns: str: The generated HTML string for the button. """ + if label is None: + label = self.send_label or word("Send") + if not self.has_enabled_documents(): return "" # Don't let people email an empty set of documents if not hasattr(self, "_cached_get_email_copy"): diff --git a/docassemble/AssemblyLine/data/questions/ql_baseline.yml b/docassemble/AssemblyLine/data/questions/ql_baseline.yml index 93967871..1d9cde34 100644 --- a/docassemble/AssemblyLine/data/questions/ql_baseline.yml +++ b/docassemble/AssemblyLine/data/questions/ql_baseline.yml @@ -2593,4 +2593,20 @@ data: - Lt. - Sgt. - Fr. - - Sr. \ No newline at end of file + - Sr. +--- +generic object: ALDocumentBundle +variable name: x.view_label +data: "View" +--- +generic object: ALDocumentBundle +variable name: x.download_label +data: "Download" +--- +generic object: ALDocumentBundle +variable name: x.send_label +data: "Send" +--- +generic object: ALDocumentBundle +variable name: x.send_button_to_label +data: "Send" From ccaea7b16aea730ace144693892cdabfd82e3412 Mon Sep 17 00:00:00 2001 From: Quinten Steenhuis Date: Thu, 20 Nov 2025 10:01:57 -0500 Subject: [PATCH 2/5] WIP --- .../AssemblyLine/data/questions/ql_baseline.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/docassemble/AssemblyLine/data/questions/ql_baseline.yml b/docassemble/AssemblyLine/data/questions/ql_baseline.yml index 1d9cde34..2d486d4f 100644 --- a/docassemble/AssemblyLine/data/questions/ql_baseline.yml +++ b/docassemble/AssemblyLine/data/questions/ql_baseline.yml @@ -2596,17 +2596,17 @@ data: - Sr. --- generic object: ALDocumentBundle -variable name: x.view_label -data: "View" +template: x.view_label +content: "View" --- generic object: ALDocumentBundle -variable name: x.download_label -data: "Download" +template: x.download_label +content: "Download" --- generic object: ALDocumentBundle -variable name: x.send_label -data: "Send" +template: x.send_label +content: "Send" --- generic object: ALDocumentBundle -variable name: x.send_button_to_label -data: "Send" +template: x.send_button_to_label +content: "Send" \ No newline at end of file From 58ef5321703081657d2cc70e2a9775bf17bf5a95 Mon Sep 17 00:00:00 2001 From: Quinten Steenhuis Date: Thu, 20 Nov 2025 13:15:30 -0500 Subject: [PATCH 3/5] Finish fix #989, remove cached strings for some parts of ALDocumentBundle --- docassemble/AssemblyLine/al_document.py | 29 +++++-------------------- 1 file changed, 5 insertions(+), 24 deletions(-) diff --git a/docassemble/AssemblyLine/al_document.py b/docassemble/AssemblyLine/al_document.py index 9f5498c7..f20edfd1 100644 --- a/docassemble/AssemblyLine/al_document.py +++ b/docassemble/AssemblyLine/al_document.py @@ -2057,12 +2057,6 @@ def download_list_html( Returns: str: HTML representation of a table with documents and their associated actions. """ - if not hasattr(self, "_cached_zip_label"): - self._cached_zip_label = str(self.zip_label) - - if not hasattr(self, "_cached_full_pdf_label"): - self._cached_full_pdf_label = str(self.full_pdf_label) - if not view_label: view_label = self.view_label or word("View") @@ -2145,7 +2139,7 @@ def download_list_html( # Add a zip file row if included if include_zip and bundled_zip: if not zip_label: - zip_label = self._cached_zip_label + zip_label = str(self.zip_label) filename_root = os.path.splitext(str(self.filename))[0] zip_button = action_button_html( bundled_zip.url_for( @@ -2164,7 +2158,7 @@ def download_list_html( if include_full_pdf and bundled_pdf: if not full_pdf_label: - full_pdf_label = self._cached_full_pdf_label + full_pdf_label = str(self.full_pdf_label) filename_root = os.path.splitext(str(self.filename))[0] full_pdf_button = action_button_html( bundled_pdf.url_for( @@ -2282,12 +2276,7 @@ def send_email_table_row( if not self.has_enabled_documents(): return "" # Don't let people email an empty set of documents - if not hasattr(self, "_cached_get_email_copy"): - self._cached_get_email_copy = str(self.get_email_copy) - if not hasattr(self, "_cached_include_editable_documents"): - self._cached_include_editable_documents = str( - self.include_editable_documents - ) + name = html_safe_str(self.instanceName) + random_suffix() al_wants_editable_input_id = "_ignore_al_wants_editable_" + name al_email_input_id = "_ignore_al_doc_email_" + name @@ -2354,8 +2343,6 @@ def send_button_to_html( if not self.has_enabled_documents(): return "" # Don't let people email an empty set of documents - if not hasattr(self, "_cached_get_email_copy"): - self._cached_get_email_copy = str(self.get_email_copy) name = html_safe_str(self.instanceName) + random_suffix() al_send_button_id = "al_send_email_to_button_" + name @@ -2422,12 +2409,6 @@ def send_button_html( """ if not self.has_enabled_documents(): return "" # Don't let people email an empty set of documents - if not hasattr(self, "_cached_get_email_copy"): - self._cached_get_email_copy = str(self.get_email_copy) - if not hasattr(self, "_cached_include_editable_documents"): - self._cached_include_editable_documents = str( - self.include_editable_documents - ) if isinstance(preferred_formats, str): preferred_formats = [preferred_formats] @@ -2461,7 +2442,7 @@ def send_button_html( # Container of whole email section with header return_str = f"""
- {self._cached_get_email_copy} + {str(self.get_email_copy)} """ # "Editable" checkbox if ( @@ -2474,7 +2455,7 @@ def send_button_html(
-
From 349a6e2f089df49b78ca1487a4e2f3356360d381 Mon Sep 17 00:00:00 2001 From: Quinten Steenhuis Date: Thu, 20 Nov 2025 16:16:51 -0500 Subject: [PATCH 4/5] Add test to two files to allow interactive validation of the new translated strings --- docassemble/AssemblyLine/data/questions/test_aldocument.yml | 5 ++++- .../AssemblyLine/data/questions/test_question_library.yml | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/docassemble/AssemblyLine/data/questions/test_aldocument.yml b/docassemble/AssemblyLine/data/questions/test_aldocument.yml index f0b22384..263623a0 100644 --- a/docassemble/AssemblyLine/data/questions/test_aldocument.yml +++ b/docassemble/AssemblyLine/data/questions/test_aldocument.yml @@ -1,6 +1,9 @@ --- include: - - al_package.yml + - assembly_line.yml +--- +code: | + al_interview_languages = ["en", "es", "ht", "pt"] --- metadata: title: | diff --git a/docassemble/AssemblyLine/data/questions/test_question_library.yml b/docassemble/AssemblyLine/data/questions/test_question_library.yml index 6addbc5c..0a027b46 100644 --- a/docassemble/AssemblyLine/data/questions/test_question_library.yml +++ b/docassemble/AssemblyLine/data/questions/test_question_library.yml @@ -2,6 +2,9 @@ include: - assembly_line.yml --- +code: | + al_interview_languages = ["en", "es", "ht", "pt"] +--- metadata: title: | Test Question Library From 38ee0fedf79b41a5034542344f737fb7e4f20aff Mon Sep 17 00:00:00 2001 From: Quinten Steenhuis Date: Thu, 20 Nov 2025 16:30:09 -0500 Subject: [PATCH 5/5] Format with black --- docassemble/AssemblyLine/al_document.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/docassemble/AssemblyLine/al_document.py b/docassemble/AssemblyLine/al_document.py index f20edfd1..f707118e 100644 --- a/docassemble/AssemblyLine/al_document.py +++ b/docassemble/AssemblyLine/al_document.py @@ -2059,10 +2059,10 @@ def download_list_html( """ if not view_label: view_label = self.view_label or word("View") - + if not download_label: download_label = self.download_label or word("Download") - + if not send_label: send_label = self.send_label or word("Send") @@ -2255,7 +2255,10 @@ def download_html( return html def send_email_table_row( - self, key: str = "final", send_label: Optional[str] = None, send_icon: str = "envelope" + self, + key: str = "final", + send_label: Optional[str] = None, + send_icon: str = "envelope", ) -> str: """ Generate HTML doc table row for an input box and button that allows @@ -2340,7 +2343,7 @@ def send_button_to_html( """ if label is None: label = self.send_label or word("Send") - + if not self.has_enabled_documents(): return "" # Don't let people email an empty set of documents name = html_safe_str(self.instanceName) + random_suffix()