diff --git a/edivorce/apps/core/utils/user_response.py b/edivorce/apps/core/utils/user_response.py index d14af105..da90a1c3 100644 --- a/edivorce/apps/core/utils/user_response.py +++ b/edivorce/apps/core/utils/user_response.py @@ -1,10 +1,10 @@ from edivorce.apps.core.models import UserResponse, Question -from edivorce.apps.core.utils.question_step_mapping import question_step_mapping +from edivorce.apps.core.utils.question_step_mapping import pre_qual_step_question_mapping, question_step_mapping from edivorce.apps.core.utils.step_completeness import evaluate_numeric_condition from collections import OrderedDict -def get_responses_from_db(bceid_user, step_errors=None): +def get_responses_from_db(bceid_user, show_errors=False, step=None, substep=None): """ Get UserResponses from the database for a user.""" married, married_questions, responses = __get_data(bceid_user) responses_dict = {} @@ -13,8 +13,11 @@ def get_responses_from_db(bceid_user, step_errors=None): responses_dict[answer.question.key] = '' elif answer.value.strip('[').strip(']'): responses_dict[answer.question.key] = answer.value - if step_errors: - step_questions = question_step_mapping.get(step_errors, []) + if show_errors: + if step == 'prequalification' and substep: + step_questions = pre_qual_step_question_mapping.get(substep) + else: + step_questions = question_step_mapping.get(step, []) questions = Question.objects.filter(key__in=step_questions) for question in questions: if responses_dict.get(question.key): diff --git a/edivorce/apps/core/views/main.py b/edivorce/apps/core/views/main.py index 4a3cfcfc..cee46b9b 100644 --- a/edivorce/apps/core/views/main.py +++ b/edivorce/apps/core/views/main.py @@ -40,7 +40,7 @@ def prequalification(request, step): if not request.user.is_authenticated: responses_dict = get_responses_from_session(request) else: - responses_dict = get_responses_from_db(request.user, 'prequalification') + responses_dict = get_responses_from_db(request.user, show_errors=True, step='prequalification', substep=step) responses_dict['active_page'] = 'prequalification' responses_by_step = get_responses_from_db_grouped_by_steps(request.user) responses_dict['step_status'] = get_step_status(responses_by_step) @@ -188,16 +188,17 @@ def question(request, step, sub_step=None): template = 'question/%02d_%s%s.html' % (template_step_order[step], step, sub_page_template) responses_dict_by_step = get_responses_from_db_grouped_by_steps(request.user, True) - + step_status = get_step_status(responses_dict_by_step) if step == "review": responses_dict = responses_dict_by_step derived = get_derived_data(get_responses_from_db(request.user)) else: - responses_dict = get_responses_from_db(request.user, step) + show_errors = step_status.get(step) == 'Started' + responses_dict = get_responses_from_db(request.user, show_errors=show_errors, step=step, substep=sub_step) derived = get_derived_data(responses_dict) # Add step status dictionary - responses_dict['step_status'] = get_step_status(responses_dict_by_step) + responses_dict['step_status'] = step_status responses_dict['active_page'] = step # If page is filing location page, add registries dictionary for list of court registries