Browse Source

Add missing field label for fact sheets

pull/163/head
ariannedee 5 years ago
parent
commit
c1813d887c
5 changed files with 36 additions and 19 deletions
  1. +3
    -3
      edivorce/apps/core/templates/question/06_children_income_expenses.html
  2. +18
    -7
      edivorce/apps/core/templatetags/summary_format.py
  3. +6
    -5
      edivorce/apps/core/utils/derived.py
  4. +8
    -4
      edivorce/apps/core/utils/step_completeness.py
  5. +1
    -0
      edivorce/apps/core/views/main.py

+ 3
- 3
edivorce/apps/core/templates/question/06_children_income_expenses.html View File

@ -306,10 +306,10 @@
</div>
<div id="fact_sheet_a" class="fact-sheets" hidden>
<div class="question-well {% if derived.special_expenses_missing_error %}error{% endif %}">
<h1>Special or Extraordinary Expenses (Fact Sheet A){% if derived.special_expenses_missing_error %}{% include 'partials/required.html' %}{% endif %}</h1>
<div class="question-well {% if derived.fact_sheet_a_error %}error{% endif %}">
<h1>Special or Extraordinary Expenses (Fact Sheet A){% if derived.fact_sheet_a_error %}{% include 'partials/required.html' %}{% endif %}</h1>
<p>Since you have indicated that there are special or extraordinary expenses, we need you to answer the next set of questions.</p>
{% if derived.special_expenses_missing_error %}<p class="warning">
{% if derived.fact_sheet_a_error %}<p class="warning">
* At least one of these values must be greater than 0
</p>{% endif %}
<table class="table table-bordered">


+ 18
- 7
edivorce/apps/core/templatetags/summary_format.py View File

@ -155,12 +155,13 @@ def format_review_row_heading(title, style="", substep=None):
)
def format_fact_sheet(title, url, style=''):
def format_fact_sheet(title, url, value):
return format_html(
'<tr><td colspan="2" class="table-bordered {0}"><a href="{1}"><b>{2}</b></a></td></tr>',
style,
'<tr><td class="table-bordered"><a href="{}"><b>{}</b></a></td><td>{}</td></tr>',
url,
title)
title,
value
)
@register.simple_tag(takes_context=True)
@ -237,25 +238,35 @@ def format_children(context, source):
for question in questions:
if question in fact_sheet_mapping:
show_fact_sheet = False
fact_sheet_error = False
if question == 'Special or Extraordinary Expenses (Fact Sheet A)' and context['derived']['show_fact_sheet_a']:
show_fact_sheet = True
fact_sheet_error = context['derived']['fact_sheet_a_error']
elif question == 'Shared Living Arrangement (Fact Sheet B)' and context['derived']['show_fact_sheet_b']:
show_fact_sheet = True
fact_sheet_error = context['derived']['fact_sheet_b_error']
elif question == 'Split Living Arrangement (Fact Sheet C)' and context['derived']['show_fact_sheet_c']:
show_fact_sheet = True
fact_sheet_error = context['derived']['fact_sheet_c_error']
elif question == 'Child(ren) 19 Years or Older (Fact Sheet D)' and context['derived']['show_fact_sheet_d']:
show_fact_sheet = True
fact_sheet_error = context['derived']['fact_sheet_d_error']
elif question == 'Undue Hardship (Fact Sheet E)' and context['derived']['show_fact_sheet_e']:
show_fact_sheet = True
elif question == 'Income over $150,000 (Fact Sheet F)' and (
context['derived']['show_fact_sheet_f_you'] or context['derived']['show_fact_sheet_f_spouse']):
fact_sheet_error = context['derived']['fact_sheet_e_error']
elif question == 'Income over $150,000 (Fact Sheet F)' and context['derived']['show_fact_sheet_f']:
show_fact_sheet = True
fact_sheet_error = context['derived']['fact_sheet_f_error']
if show_fact_sheet and len(fact_sheet_mapping[question]):
if fact_sheet_error:
value = MISSING_RESPONSE
else:
value = 'Complete'
tags = format_html(
'{}{}',
tags,
format_fact_sheet(question, fact_sheet_mapping[question]))
format_fact_sheet(question, fact_sheet_mapping[question], value))
else:
item_list = list(filter(lambda x: x['question_id'] == question, working_source))


+ 6
- 5
edivorce/apps/core/utils/derived.py View File

@ -34,6 +34,7 @@ DERIVED_DATA = [
'wants_child_support',
'wants_other_orders',
'show_fact_sheet_a',
'fact_sheet_a_error',
'show_fact_sheet_b',
'fact_sheet_b_error',
'show_fact_sheet_c',
@ -86,7 +87,6 @@ DERIVED_DATA = [
'pursuant_parenting_arrangement',
'pursuant_child_support',
'sole_custody',
'special_expenses_missing_error',
]
@ -160,6 +160,10 @@ def show_fact_sheet_a(responses, derived):
return responses.get('special_extraordinary_expenses', '') == 'YES'
def fact_sheet_a_error(responses, derived):
return determine_missing_extraordinary_expenses(responses)
def show_fact_sheet_b(responses, derived):
"""
If any child lives with both parents, custody is shared, so Fact Sheet B
@ -263,6 +267,7 @@ def fact_sheet_f_error(responses, derived):
if show_fact_sheet_f_spouse(responses, derived):
if _any_question_errors(responses, fields_for_spouse):
return True
return False
def has_fact_sheets(responses, derived):
@ -739,10 +744,6 @@ def sole_custody(responses, derived):
return conditional_logic.determine_sole_custody(responses)
def special_expenses_missing_error(responses, derived):
return determine_missing_extraordinary_expenses(responses)
def _any_question_errors(responses, questions):
for field in questions:
error_field_name = f'{field}_error'


+ 8
- 4
edivorce/apps/core/utils/step_completeness.py View File

@ -84,15 +84,19 @@ def get_formatted_incomplete_list(missed_question_keys):
return missed_questions
def get_error_dict(questions_by_step, step, substep=None):
def get_error_dict(questions_by_step, step=None, substep=None):
"""
Accepts questions dict of {step: [{question_dict}]} and a step (and substep)
Returns a dict of {question_key_error: True} for missing questions that are part of that step (and substep)
"""
responses_dict = {}
question_step = page_step_mapping[step]
step_questions = questions_by_step.get(question_step)
if step:
question_step = page_step_mapping[step]
step_questions = questions_by_step.get(question_step)
else:
step_questions = []
for questions in questions_by_step.values():
step_questions.extend(questions)
# 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)


+ 1
- 0
edivorce/apps/core/views/main.py View File

@ -199,6 +199,7 @@ def question(request, step, sub_step=None):
data_dict = get_data_for_user(request.user)
responses_dict_by_step = get_step_responses(data_dict)
step_status = get_step_completeness(responses_dict_by_step)
data_dict.update(get_error_dict(responses_dict_by_step))
derived = get_derived_data(data_dict)
responses_dict = responses_dict_by_step
else:


Loading…
Cancel
Save