-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create ReturnLocation object to store return params (#1229)
- Loading branch information
1 parent
265c704
commit 965dae0
Showing
30 changed files
with
426 additions
and
351 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from dataclasses import asdict, dataclass | ||
|
||
|
||
@dataclass(kw_only=True, frozen=True) | ||
class ReturnLocation: | ||
""" | ||
Used to store return locations in the questionnaire. | ||
return_to: The name of the type of summary page to return to | ||
return_to_block_id: The block_id of the block to return to | ||
return_to_answer_id: The answer_id of the answer to return to | ||
return_to_list_item_id: The list_item_id to return to if the location is associated with a list | ||
""" | ||
|
||
return_to: str | None = None | ||
return_to_block_id: str | None = None | ||
return_to_answer_id: str | None = None | ||
return_to_list_item_id: str | None = None | ||
|
||
def to_dict(self, answer_id_is_anchor: bool = False) -> dict: | ||
attributes = asdict(self) | ||
if answer_id_is_anchor: | ||
attributes["_anchor"] = attributes["return_to_answer_id"] | ||
del attributes["return_to_answer_id"] | ||
return {k: v for k, v in attributes.items() if v is not None} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.