-
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.
Add initial support for unrelated relationship (#339)
- Loading branch information
1 parent
c7176b6
commit 12a6cfd
Showing
13 changed files
with
733 additions
and
17 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
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
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
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
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
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,4 @@ | ||
from .relationship_collector import RelationshipCollector | ||
from .unrelated_question import UnrelatedQuestion | ||
|
||
__all__ = ["RelationshipCollector", "UnrelatedQuestion"] |
File renamed without changes.
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,45 @@ | ||
from app.questionnaire.location import Location | ||
from app.views.handlers.question import Question | ||
|
||
|
||
class UnrelatedQuestion(Question): | ||
def _get_parent_list_name(self): | ||
parent_block_id = self._schema.parent_id_map[self.block["id"]] | ||
return self._schema.get_block(parent_block_id)["for_list"] | ||
|
||
@property | ||
def parent_location(self): | ||
parent_block_id = self._schema.parent_id_map[self.block["id"]] | ||
return Location( | ||
section_id=self._current_location.section_id, block_id=parent_block_id | ||
) | ||
|
||
def _get_routing_path(self): | ||
return self.router.routing_path(section_id=self.parent_location.section_id) | ||
|
||
def is_location_valid(self): | ||
can_access_parent_location = self.router.can_access_location( | ||
self.parent_location, self._routing_path | ||
) | ||
|
||
if not can_access_parent_location: | ||
return False | ||
|
||
if self.current_location.list_name != self._get_parent_list_name() or ( | ||
self.current_location.list_item_id | ||
and not self.router.is_list_item_in_list_store( | ||
self.current_location.list_item_id, self.current_location.list_name | ||
) | ||
): | ||
return False | ||
|
||
return True | ||
|
||
def get_previous_location_url(self): | ||
pass | ||
|
||
def get_next_location_url(self): | ||
pass # pragma: no cover | ||
|
||
def handle_post(self): | ||
pass # pragma: no cover |
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 @@ | ||
{% include 'question.html' %} |
Oops, something went wrong.