-
Notifications
You must be signed in to change notification settings - Fork 9
Hardened feature for importing answers from a JSON file #1027
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
e3eac36
1935e34
208645c
e5e72c1
e710691
4c5b904
242dd22
947eda3
fedc432
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -3,6 +3,7 @@ code: | | |||||||||||||||||||
| # HACK | ||||||||||||||||||||
| # Create a placeholder value to avoid playground errors | ||||||||||||||||||||
| al_sessions_snapshot_results = DAEmpty() | ||||||||||||||||||||
| al_sessions_last_import_report = {"accepted": [], "rejected": [], "warnings": []} | ||||||||||||||||||||
| --- | ||||||||||||||||||||
| initial: True | ||||||||||||||||||||
| code: | | ||||||||||||||||||||
|
|
@@ -217,18 +218,39 @@ back button: False | |||||||||||||||||||
| --- | ||||||||||||||||||||
| id: al sessions load status | ||||||||||||||||||||
| continue button field: al_sessions_load_status | ||||||||||||||||||||
| comment: | | ||||||||||||||||||||
| #TODO There's no error handling yet so this might be a lie | ||||||||||||||||||||
| question: | | ||||||||||||||||||||
| % if al_sessions_snapshot_results: | ||||||||||||||||||||
| Your answer set was loaded | ||||||||||||||||||||
| % else: | ||||||||||||||||||||
| Your answer set was not loaded. You can try again. | ||||||||||||||||||||
| % endif | ||||||||||||||||||||
| subquestion: | | ||||||||||||||||||||
| % if defined('al_sessions_last_import_report'): | ||||||||||||||||||||
| % if al_sessions_last_import_report.get('warnings'): | ||||||||||||||||||||
| ${ collapse_template(al_sessions_import_warnings_template) } | ||||||||||||||||||||
| % endif | ||||||||||||||||||||
| % if al_sessions_last_import_report.get('rejected'): | ||||||||||||||||||||
| ${ collapse_template(al_sessions_import_rejected_template) } | ||||||||||||||||||||
| % endif | ||||||||||||||||||||
| % endif | ||||||||||||||||||||
|
|
||||||||||||||||||||
| Tap "next" to keep answering any unanswered questions and finish the interview. | ||||||||||||||||||||
| back button: False | ||||||||||||||||||||
| --- | ||||||||||||||||||||
| template: al_sessions_import_warnings_template | ||||||||||||||||||||
| subject: Import warnings | ||||||||||||||||||||
| content: | | ||||||||||||||||||||
| % for warning in al_sessions_last_import_report.get('warnings', []): | ||||||||||||||||||||
| * ${ warning } | ||||||||||||||||||||
| % endfor | ||||||||||||||||||||
| --- | ||||||||||||||||||||
| template: al_sessions_import_rejected_template | ||||||||||||||||||||
| subject: Variables skipped during import | ||||||||||||||||||||
| content: | | ||||||||||||||||||||
| % for item in al_sessions_last_import_report.get('rejected', []): | ||||||||||||||||||||
| * `${ item.get('path', '?') }`: ${ item.get('reason', 'unknown reason') } | ||||||||||||||||||||
| % endfor | ||||||||||||||||||||
|
Comment on lines
+250
to
+252
|
||||||||||||||||||||
| % for item in al_sessions_last_import_report.get('rejected', []): | |
| * `${ item.get('path', '?') }`: ${ item.get('reason', 'unknown reason') } | |
| % endfor | |
| % for item in al_sessions_last_import_report.get('rejected', [])[:50]: | |
| * `${ item.get('path', '?') }`: ${ item.get('reason', 'unknown reason') } | |
| % endfor | |
| % if len(al_sessions_last_import_report.get('rejected', [])) > 50: | |
| * ${ len(al_sessions_last_import_report.get('rejected', [])) - 50 } more variables were skipped and are not shown here. | |
| % endif |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| { | ||
| "users_name": "Alex", | ||
| "city": "Boston", | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| { | ||
| "users_name": "Alex", | ||
| "__class__": "builtins.object", | ||
| "city": "Boston" | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| { | ||
| "users_name": "Alex", | ||
| "_internal": { | ||
| "steps": 99 | ||
| }, | ||
| "city": "Boston" | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| { | ||
| "users": { | ||
| "_class": "docassemble.playground1.al_general.ALPeopleList", | ||
| "instanceName": "users", | ||
| "object_type": { | ||
| "_class": "type", | ||
| "name": "docassemble.playground1.al_general.ALIndividual" | ||
| }, | ||
| "elements": [ | ||
| { | ||
| "_class": "docassemble.playground1.al_general.ALIndividual", | ||
| "instanceName": "users[0]", | ||
| "name": { | ||
| "_class": "docassemble.playground1.al_general.IndividualName", | ||
| "instanceName": "users[0].name", | ||
| "first": "Client", | ||
| "last": "Example" | ||
| } | ||
| } | ||
| ] | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| { | ||
| "users": { | ||
| "_class": "docassemble.bad.Actor", | ||
| "instanceName": "users" | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| { | ||
| "users": { | ||
| "_class": "docassemble.AssemblyLine.al_general.ALPeopleList", | ||
| "instanceName": "users", | ||
| "object_type": { | ||
| "_class": "type", | ||
| "name": "docassemble.AssemblyLine.al_general.ALIndividual" | ||
| }, | ||
| "elements": [ | ||
| { | ||
| "_class": "docassemble.AssemblyLine.al_general.ALIndividual", | ||
| "instanceName": "users[0]", | ||
| "name": { | ||
| "_class": "docassemble.base.util.IndividualName", | ||
| "instanceName": "users[0].name", | ||
| "first": "Client", | ||
| "last": "Example" | ||
| }, | ||
| "agent": { | ||
| "_class": "docassemble.AssemblyLine.al_general.ALIndividual", | ||
| "instanceName": "spouse" | ||
| }, | ||
| "custom_text": "notes", | ||
| "custom_float": 1.25, | ||
| "custom_dict": { | ||
| "_class": "docassemble.base.util.DADict", | ||
| "instanceName": "users[0].custom_dict", | ||
| "elements": { | ||
| "case": "A123" | ||
| } | ||
| } | ||
| }, | ||
| { | ||
| "_class": "docassemble.AssemblyLine.al_general.ALIndividual", | ||
| "instanceName": "spouse", | ||
| "name": { | ||
| "_class": "docassemble.base.util.IndividualName", | ||
| "instanceName": "spouse.name", | ||
| "first": "Spouse", | ||
| "last": "Example" | ||
| } | ||
| } | ||
| ] | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
README says that when
answer set import allowed variablesis unset, imports use a denylist-only policy for backwards compatibility. However, the implementation also restricts imports to variables detected in the target interview (via_get_target_interview_variables) when available, which is stricter than denylist-only. Please update this section to match the actual default behavior (or adjust the code to match the documented policy).