Skip to content
Merged
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
13 changes: 13 additions & 0 deletions docassemble/EFSPIntegration/efm_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
Person,
Individual,
DAStore,
DAEmpty,
DADateTime,
as_datetime,
reconsider,
Expand Down Expand Up @@ -93,6 +94,16 @@ def _give_data_url(bundle: ALDocumentBundle, key: str = "final") -> None:
doc.page_count = doc_pdf.num_pages()


def _remove_all_da_emptys(json_val):
if isinstance(json_val, DAEmpty):
return None
if isinstance(json_val, list):
return [_remove_all_da_emptys(v) for v in json_val]
if isinstance(json_val, dict):
return {k: _remove_all_da_emptys(v) for k, v in json_val.items()}
return json_val


def _get_all_vars(bundle: ALDocumentBundle, key: str = "final") -> Dict:
"""Strips out some extra big variables that we don't need to serialize and send across the network"""
_give_data_url(bundle, key=key)
Expand Down Expand Up @@ -132,6 +143,8 @@ def _get_all_vars(bundle: ALDocumentBundle, key: str = "final") -> Dict:
for var in vars_to_pop:
all_vars_dict.pop(var, None)

all_vars_dict = _remove_all_da_emptys(all_vars_dict)

for doc in all_vars_dict.get("al_court_bundle", {}).get("elements", []):
doc.pop("optional_service_options", None)
doc.pop("document_type_options", None)
Expand Down
Loading