From 9c318c2ed34fbf19d124f9db4a5808c9b890f8ec Mon Sep 17 00:00:00 2001
From: ariannedee
Date: Wed, 26 Aug 2020 12:22:35 -0700
Subject: [PATCH] Show error on Your Children section if other children
questions answered
---
.../question/06_children_your_children.html | 6 ++++--
edivorce/apps/core/utils/step_completeness.py | 16 +++++++++++-----
2 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/edivorce/apps/core/templates/question/06_children_your_children.html b/edivorce/apps/core/templates/question/06_children_your_children.html
index 464701d9..92cc5853 100644
--- a/edivorce/apps/core/templates/question/06_children_your_children.html
+++ b/edivorce/apps/core/templates/question/06_children_your_children.html
@@ -53,8 +53,10 @@
{% endif %}
-
* You have indicated that you have children of the marriage. This includes children under and over the age of 19. Their details
- must be added below.
+ {% if claimant_children_error %}
+
* You have indicated that you have children of the marriage. This includes children under and over the age of 19. Their details
+ must be added below.
+ {% endif %}
diff --git a/edivorce/apps/core/utils/step_completeness.py b/edivorce/apps/core/utils/step_completeness.py
index 602a52a5..921adbfb 100644
--- a/edivorce/apps/core/utils/step_completeness.py
+++ b/edivorce/apps/core/utils/step_completeness.py
@@ -39,7 +39,7 @@ def get_step_completeness(questions_by_step):
"""
status_dict = {}
for step, questions_dict in questions_by_step.items():
- if not_started(questions_dict):
+ if not step_started(questions_dict):
status_dict[step] = "Not started"
else:
complete = is_complete(questions_dict)
@@ -50,11 +50,11 @@ def get_step_completeness(questions_by_step):
return status_dict
-def not_started(question_list):
+def step_started(question_list):
for question_dict in question_list:
if get_cleaned_response_value(question_dict['value']):
- return False
- return True
+ return True
+ return False
def is_complete(question_list):
@@ -92,10 +92,16 @@ def get_error_dict(questions_by_step, step, substep=None):
responses_dict = {}
question_step = page_step_mapping[step]
step_questions = questions_by_step.get(question_step)
+
+ # Since the Your children substep only has one question, show error if future children questions have been answered
+ children_substep_and_step_started = substep == 'your_children' and step_started(step_questions)
+
if substep:
substep_questions = children_substep_question_mapping[substep]
step_questions = list(filter(lambda question_dict: question_dict['question_id'] in substep_questions, step_questions))
- if not not_started(step_questions) and not is_complete(step_questions):
+
+ show_section_errors = not step_started(step_questions) and not is_complete(step_questions)
+ if show_section_errors or children_substep_and_step_started:
for question_dict in step_questions:
if question_dict['error']:
field_error_key = question_dict['question_id'] + '_error'