Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 32 additions & 30 deletions docassemble/AssemblyLine/al_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
DAStaticFile,
alpha,
showifdef,
word,
)
from docassemble.base.pdfa import pdf_to_pdfa
from textwrap import wrap
Expand Down Expand Up @@ -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",
Expand All @@ -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".
Expand All @@ -2056,11 +2057,14 @@ 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 view_label:
view_label = self.view_label or word("View")

if not hasattr(self, "_cached_full_pdf_label"):
self._cached_full_pdf_label = str(self.full_pdf_label)
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
Expand Down Expand Up @@ -2135,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(
Expand All @@ -2154,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(
Expand Down Expand Up @@ -2251,12 +2255,17 @@ 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".
Expand All @@ -2265,14 +2274,12 @@ 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"):
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
Expand Down Expand Up @@ -2310,7 +2317,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",
Expand All @@ -2334,10 +2341,11 @@ 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"):
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

Expand Down Expand Up @@ -2404,12 +2412,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]
Expand Down Expand Up @@ -2443,7 +2445,7 @@ def send_button_html(
# Container of whole email section with header
return_str = f"""
<fieldset class="al_send_bundle al_send_section_alone {html_safe_str(self.instanceName)}" id="al_send_bundle_{name}" name="al_send_bundle_{name}">
<legend class="h4 al_doc_email_header">{self._cached_get_email_copy}</legend>
<legend class="h4 al_doc_email_header">{str(self.get_email_copy)}</legend>
"""
# "Editable" checkbox
if (
Expand All @@ -2456,7 +2458,7 @@ def send_button_html(
<div class="form-check-container">
<div class="form-check">
<input class="form-check-input al_wants_editable" type="checkbox" id="{al_wants_editable_input_id}">
<label class="al_wants_editable form-check-label" for="{al_wants_editable_input_id}">{self._cached_include_editable_documents}
<label class="al_wants_editable form-check-label" for="{al_wants_editable_input_id}">{str(self.include_editable_documents)}
</label>
</div>
</div>
Expand Down
18 changes: 17 additions & 1 deletion docassemble/AssemblyLine/data/questions/ql_baseline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2593,4 +2593,20 @@ data:
- Lt.
- Sgt.
- Fr.
- Sr.
- Sr.
---
generic object: ALDocumentBundle
template: x.view_label
content: "View"
---
generic object: ALDocumentBundle
template: x.download_label
content: "Download"
---
generic object: ALDocumentBundle
template: x.send_label
content: "Send"
---
generic object: ALDocumentBundle
template: x.send_button_to_label
content: "Send"
5 changes: 4 additions & 1 deletion docassemble/AssemblyLine/data/questions/test_aldocument.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
---
include:
- al_package.yml
- assembly_line.yml
---
code: |
al_interview_languages = ["en", "es", "ht", "pt"]
---
metadata:
title: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
include:
- assembly_line.yml
---
code: |
al_interview_languages = ["en", "es", "ht", "pt"]
---
metadata:
title: |
Test Question Library
Expand Down
Loading