SuffolkLITLab / docassemble-AssemblyLine

Quickly go from a paper court form to a runnable, guided, step-by-step web application powered by Docassemble. Swap out branding and pre-built questions to meet your needs.
https://suffolklitlab.org/docassemble-AssemblyLine-documentation/
MIT License
44 stars 5 forks source link

We don't respect the .gathered attribute of an ALDocumentBundle #805

Open nonprofittechy opened 11 months ago

nonprofittechy commented 11 months ago

Currently, when we show al_document_bundle, we loop over .enabled_documents() which in turn loops over .elements, thereby not triggering the normal Docassemble process to gather elements of the list.

See offending code: https://github.com/SuffolkLITLab/docassemble-AssemblyLine/blob/7726cbe92a184e12b2bb1f9cff219bf4717bee19/docassemble/AssemblyLine/al_document.py#L1645

I'm not quite sure if changing this could break any existing interviews though.

Here's a simple test interview that doesn't work:

---
include:
  - docassemble.AssemblyLine:assembly_line.yml
---
objects:
  - letter: ALDocument.using(title="Letter to Social Security", filename="ssa_letter", enabled=True, has_addendum=False)
---
attachment:
    variable name: letter[i]
    content: |
      Hello, World
---
objects:
  - al_user_bundle: ALDocumentBundle.using(title="Forms to download", filename="ssa_documents", gathered=False)
---
code: |
  al_user_bundle.append(letter)
  al_user_bundle.gathered = True
---
mandatory: True
question: |
  Download
subquestion: |
  ${ al_user_bundle.download_list_html() }
nonprofittechy commented 10 months ago

To explain a little more what this does: it stops us from using a separate code block to define the items in a bundle. This would be really useful for dynamic interviews, where the number of possible generated documents depends on the answers in the interview. E.g., generating a document for a client and the spouse, or one for each child.