Skip to content

Commit

Permalink
Fix #933 by warning user if DOCX has no fields even in auto drafting …
Browse files Browse the repository at this point in the history
…mode. Also clarified the proper API keys to use with the Weaver for SPOT vs tools.suffolklitlab.org
  • Loading branch information
nonprofittechy committed Jun 5, 2024
1 parent a34b422 commit 4944745
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
4 changes: 4 additions & 0 deletions docassemble/ALWeaver/data/questions/assembly_line.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2048,6 +2048,10 @@ code: |
interview.auto_assign_attributes()
interview_label_draft = varname(interview.title).lower()
# Check for an empty file
if not len(interview.all_fields):
force_ask('empty_pdf')
# TODO: refactor this at some point, this is a shim to create objects block but we
# shouldn't need it forever.
# person_candidates = interview.all_fields.get_person_candidates()
Expand Down
11 changes: 9 additions & 2 deletions docassemble/ALWeaver/data/questions/template_validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -230,12 +230,18 @@ code: |
]
---
event: empty_pdf
question: You uploaded an empty PDF
question: |
% if interview.get_file_types() == "pdf":
You uploaded a PDF without any fields
% elif interview.get_file_types() == "docx":
You uploaded a DOCX file without any Jinja2 syntax
% endif
subquestion: |
The PDF you uploaded (${ interview.uploaded_templates[0].filename }) does not have any
The document you uploaded (${ interview.uploaded_templates[0].filename }) does not have any
fillable fields. To make a new interview with the Weaver, we need to have a
document that has fillable fields.
% if interview.get_file_types() == "pdf":
If you saved a DOCX file as a PDF, you will need to add fillable fields in a
tool like [Adobe Acrobat](https://acrobat.adobe.com).
For more info, see the [documentation](https://suffolklitlab.org/docassemble-AssemblyLine-documentation/docs/pdfs).
Expand All @@ -244,6 +250,7 @@ subquestion: |
or XFA form), you may need to flatten it first. You can flatten an XFA form
using [iText PDF's free
tool](https://itextpdf.com/en/demos/flatten-dynamic-xfa-pdf-free-online).
% endif
buttons:
- Restart: restart
---
Expand Down
2 changes: 1 addition & 1 deletion docassemble/ALWeaver/interview_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -1801,7 +1801,7 @@ def _guess_categories(self, title) -> List[str]:
categories = formfyxer.spot(
title + ": " + full_text,
token=get_config("assembly line", {}).get(
"tools.suffolklitlab.org api key", None
"spot api key", None
),
)
if categories and not "401" in categories:
Expand Down

0 comments on commit 4944745

Please sign in to comment.