Skip to content
Open
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
105 changes: 105 additions & 0 deletions docassemble/AssemblyLine/data/questions/al_document.yml
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,48 @@
---
############## Background document assembly #################
---
# Use these saved completion variables in interview order blocks. Celery's
# task.ready() becomes False again when its result expires (normally one day).
# Error callbacks also save durable state. While waiting, check completed tasks
# for failures from before these callbacks existed. failed() can block, so it
# must only be called after ready(). Neither is needed when a saved result exists.
generic object: ALDocumentBundle
code: |
x.generate_downloads_task
if not defined(x.attr_name("_downloadable_files")):
if defined(x.attr_name("_download_error")) or (
x.generate_downloads_task.ready() and x.generate_downloads_task.failed()
):
x.downloads_error_screen
al_download_waiting_screen
x.downloads_ready = True
---
generic object: ALDocumentBundle
code: |
x.generate_downloads_with_docx_task
if not defined(x.attr_name("_downloadable_files")):
if defined(x.attr_name("_download_error")) or (
x.generate_downloads_with_docx_task.ready() and x.generate_downloads_with_docx_task.failed()
):
x.downloads_error_screen
al_download_waiting_screen
x.downloads_with_docx_ready = True
---
generic object: ALDocumentBundle
code: |
undefine(
x.attr_name("_downloadable_files"),
x.attr_name("_download_error"),
x.attr_name("downloads_ready"),
x.attr_name("downloads_with_docx_ready"),
x.attr_name("generate_downloads_with_docx_task"),
)
x.generate_downloads_task = background_action(x.attr_name("create_downloads"))
---
generic object: ALDocumentBundle
event: x.create_downloads
code: |
background_error_action(x.attr_name("save_download_error"))
download_response = x.get_cacheable_documents(
key="final", pdf=True, include_full_pdf=True
)
Expand All @@ -155,13 +190,21 @@
---
generic object: ALDocumentBundle
code: |
undefine(
x.attr_name("_downloadable_files"),
x.attr_name("_download_error"),
x.attr_name("downloads_ready"),
x.attr_name("downloads_with_docx_ready"),
x.attr_name("generate_downloads_task"),
)
x.generate_downloads_with_docx_task = background_action(
x.attr_name("create_downloads_with_docx")
)
---
generic object: ALDocumentBundle
event: x.create_downloads_with_docx
code: |
background_error_action(x.attr_name("save_download_error"))
download_response = x.get_cacheable_documents(
key="final", pdf=True, docx=True, include_full_pdf=True
)
Expand All @@ -176,13 +219,37 @@

background_response()
---
generic object: ALDocumentBundle
event: x.save_download_error
code: |
x._download_error = True
background_response()
---
generic object: ALDocumentBundle
event: x.downloads_error_screen
id: background downloads error screen
question: |
We could not make your documents
subquestion: |
Your answers have been saved. You can try again.

${ action_button_html(url_action(x.attr_name('retry_downloads')), label='Try again') }
---
generic object: ALDocumentBundle
event: x.retry_downloads
code: |
if defined(x.attr_name("generate_downloads_with_docx_task")):
reconsider(x.attr_name("generate_downloads_with_docx_task"))
else:
reconsider(x.attr_name("generate_downloads_task"))
---
id: waiting screen
question: |
Please wait while we make your documents
subquestion: |
This can take a few minutes.

<div class="spinner-border text-primary d-flex justify-content-center" role="status">

Check warning on line 252 in docassemble/AssemblyLine/data/questions/al_document.yml

View workflow job for this annotation

GitHub Actions / build

WA517

text in subquestion uses inline or semantic color styling; verify contrast and non-color cues: class="spinner-border text-primary
<span class="sr-only visually-hidden">Making documents...</span>
</div>
event: al_download_waiting_screen
Expand All @@ -192,11 +259,28 @@
---
generic object: ALDocumentBundle
code: |
x.generate_preview_task
if not defined(x.attr_name("_preview_file")):
if defined(x.attr_name("_preview_error")) or (
x.generate_preview_task.ready() and x.generate_preview_task.failed()
):
x.preview_error_screen
al_preview_waiting_screen
x.preview_ready = True
---
generic object: ALDocumentBundle
code: |
undefine(
x.attr_name("_preview_file"),
x.attr_name("_preview_error"),
x.attr_name("preview_ready"),
)
x.generate_preview_task = background_action(x.attr_name("generate_preview_event"))
---
generic object: ALDocumentBundle
event: x.generate_preview_event
code: |
background_error_action(x.attr_name("save_preview_error"))
preview_response = x.as_pdf(key="preview")
background_response_action(
x.attr_name("save_preview"), preview_response=preview_response
Expand All @@ -208,13 +292,34 @@
x._preview_file = action_argument("preview_response")
background_response()
---
generic object: ALDocumentBundle
event: x.save_preview_error
code: |
x._preview_error = True
background_response()
---
generic object: ALDocumentBundle
event: x.preview_error_screen
id: background preview error screen
question: |
We could not generate a preview of your document
subquestion: |
Your answers have been saved. You can try again.

${ action_button_html(url_action(x.attr_name('retry_preview')), label='Try again') }
---
generic object: ALDocumentBundle
event: x.retry_preview
code: |
reconsider(x.attr_name("generate_preview_task"))
---
id: preview waiting screen
question: |
Please wait while we generate a preview of your document
subquestion: |
This can take a few minutes.

<div class="spinner-border text-primary d-flex justify-content-center" role="status">

Check warning on line 322 in docassemble/AssemblyLine/data/questions/al_document.yml

View workflow job for this annotation

GitHub Actions / build

WA517

text in subquestion uses inline or semantic color styling; verify contrast and non-color cues: class="spinner-border text-primary
<span class="sr-only visually-hidden">Generating preview...</span>
</div>
event: al_preview_waiting_screen
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@ metadata:
mandatory: True
code: |
intro_screen
if not al_user_bundle.generate_preview_task.ready():
al_preview_waiting_screen
al_user_bundle.preview_ready
preview_screen
# if not al_user_bundle.generate_downloads_task.ready(): # Without DOCX
if not al_user_bundle.generate_downloads_with_docx_task.ready(): # With DOCX
al_download_waiting_screen
# Use al_user_bundle.downloads_ready for PDF-only downloads.
al_user_bundle.downloads_with_docx_ready
download_screen
---
id: intro-screen
Expand All @@ -40,6 +38,15 @@ subquestion: |
Your documents are ready for download.

${ al_user_bundle.download_list_html(use_previously_cached_files=True, include_full_pdf=True) }

${ action_button_html(url_action('regenerate_downloads'), label='Regenerate documents') }
---
# Use this action after collecting any changed attachment inputs. Starting the
# task clears its old saved files and completion gate; the order block waits for
# the replacement files. Do not reconsider the task on every mandatory pass.
event: regenerate_downloads
code: |
reconsider("al_user_bundle.generate_downloads_with_docx_task")
---
objects:
- al_user_bundle: ALDocumentBundle.using(
Expand Down
Loading
Loading