Skip to content

Commit

Permalink
Allow the hub to be enabled with repeating sections (#1309)
Browse files Browse the repository at this point in the history
  • Loading branch information
berroar authored Jan 31, 2024
1 parent 74647bb commit 693f9e9
Show file tree
Hide file tree
Showing 6 changed files with 1,157 additions and 5 deletions.
29 changes: 24 additions & 5 deletions app/questionnaire/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from flask import url_for

from app.data_models.data_stores import DataStores
from app.data_models.list_store import ListModel
from app.questionnaire import QuestionnaireSchema
from app.questionnaire.location import Location, SectionKey
from app.questionnaire.path_finder import PathFinder
Expand Down Expand Up @@ -82,11 +83,29 @@ def can_access_location(
return location.block_id in self._get_allowable_path(routing_path)

def can_access_hub(self) -> bool:
return self._schema.is_flow_hub and all(
self._data_stores.progress_store.is_section_complete(SectionKey(section_id))
for section_id in self._schema.get_section_ids_required_for_hub()
if section_id in self.enabled_section_ids
)
if not self._schema.is_flow_hub:
return False

for section_id in self._schema.get_section_ids_required_for_hub():
if section_id in self.enabled_section_ids:
repeating_list_for_section = (
self._schema.get_repeating_list_for_section(section_id)
)

items: ListModel | list[None] = (
self._data_stores.list_store.get(repeating_list_for_section)
if repeating_list_for_section
else [None]
)

for list_item_id in items:
section_key = SectionKey(section_id, list_item_id)
if not self._data_stores.progress_store.is_section_complete(
section_key
):
return False

return True

def can_display_section_summary(self, section_key: SectionKey) -> bool:
return bool(
Expand Down
Loading

0 comments on commit 693f9e9

Please sign in to comment.