Browse Source

Merge pull request #90 from bcgov/DIV-1016

DIV-1016: Update Step 12 - Review your answers
pull/170/head
Arianne 5 years ago
committed by GitHub
parent
commit
a71692f4c1
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 583 additions and 662 deletions
  1. +1
    -1
      edivorce/apps/core/static/css/main.css
  2. +39
    -3
      edivorce/apps/core/static/css/main.scss
  3. +1
    -0
      edivorce/apps/core/templates/partials/incomplete.html
  4. +34
    -44
      edivorce/apps/core/templates/partials/review_user_responses.html
  5. +3
    -3
      edivorce/apps/core/templates/question/06_children_income_expenses.html
  6. +52
    -33
      edivorce/apps/core/templates/question/12_review.html
  7. +244
    -380
      edivorce/apps/core/templatetags/summary_format.py
  8. +12
    -3
      edivorce/apps/core/utils/derived.py
  9. +8
    -8
      edivorce/apps/core/utils/question_step_mapping.py
  10. +9
    -5
      edivorce/apps/core/utils/step_completeness.py
  11. +1
    -1
      edivorce/apps/core/utils/user_response.py
  12. +2
    -9
      edivorce/apps/core/views/main.py
  13. +177
    -172
      edivorce/fixtures/Question.json

+ 1
- 1
edivorce/apps/core/static/css/main.css
File diff suppressed because it is too large
View File


+ 39
- 3
edivorce/apps/core/static/css/main.scss View File

@ -19,6 +19,8 @@ $color-green: #57b26a;
$color-green-light: #d9f6df;
$color-gold-light: #e6ca85;
$color-red: #D8292F;
$color-red-light: #F7D4D5;
$color-red-dark: #AC2025;
$font-custom: Myriad-Pro, Calibri, Arial, Sans Serif;
$font-custom-bold: Myriad-Pro-Bold, Calibri, Arial, Sans Serif;
@ -676,9 +678,33 @@ i.fa.fa-question-circle {
transition: all 0.1s ease-in-out;
}
}
&[disabled] {
pointer-events: none;
cursor: default;
}
}
}
.review-warning {
background-color: $color-red-light;
padding: 20px;
margin: 30px 0;
border-radius: 8px;
display: flex;
.exclamation i {
font-size: 25px;
color: $color-red-dark;
}
div {
margin: 10px;
}
.warning, .progress-status i {
color: $color-red-dark;
font-weight: bolder;
margin: 0 3px;
}
}
.error {
border: 2px solid $color-red !important;
-webkit-transition: 0.1s ease-in-out all;
@ -695,8 +721,16 @@ i.fa.fa-question-circle {
border: 2px solid $color-red !important;
-webkit-transition: 0.1s ease-in-out all;
transition: 0.1s ease-in-out all;
margin: -5px -10px;
margin: -12px -16px;
padding: 12px 16px;
.warning {
color: $color-red;
font-size: 14px;
font-weight: bolder;
display: inline-block;
width: 100%;
text-align: center;
}
}
.btn-radio {
@ -1323,6 +1357,10 @@ textarea {
background-color: $brand-blue;
color: #fff;
}
.value-column {
width: 30%;
min-width: 192px;
}
}
.collapse > div,
@ -1332,8 +1370,6 @@ textarea {
.review-buttons {
float: right;
padding: 0 15px 10px;
margin: 0;
}
}
/* Column Grid in flexbox */


+ 1
- 0
edivorce/apps/core/templates/partials/incomplete.html View File

@ -0,0 +1 @@
<span class="required">Incomplete</span>

+ 34
- 44
edivorce/apps/core/templates/partials/review_user_responses.html View File

@ -1,49 +1,39 @@
{% load summary_format %}
{% if questions %}
{% if step == 'your_children' %}
<table class="table table-striped">
<thead>
<tr>
<th class="table-bordered">Question</th>
<th class="table-bordered">Response</th>
</tr>
</thead>
{% format_children source=questions %}
</table>
{% else %}
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>Question</th>
<th>Response</th>
</tr>
</thead>
<tbody>
{% if step == 'prequalification' %}
{% prequal_tag source=questions %}
{% elif step == 'your_information' or step == 'your_spouse' %}
{% personal_info_tag source=questions %}
{% elif step == 'property_and_debt' %}
{% property_tag source=questions %}
{% elif step == 'your_marriage' %}
{% marriage_tag source=questions %}
{% elif step == 'other_questions' %}
{% combine_address source=questions %}
{% else %}
{% for question in questions %}
<tr>
<td width="75%" style="padding-right: 5%">{{question.question__name}}</td>
<td width="25%">{% reformat_value source=question.value question_key=question.question_id %}</td>
</tr>
{% endfor %}
{% endif %}
</tbody>
</table>
{% endif %}
{% if step == 'your_children' %}
<table class="table table-striped">
<thead>
<tr>
<th class="table-bordered">Question</th>
<th class="table-bordered">Response</th>
</tr>
</thead>
{% format_children source=questions %}
</table>
{% else %}
<table class="table table-bordered">
<table class="table table-bordered table-striped">
<thead>
<tr>
<td>No answered questions</td>
<th>Question</th>
<th>Response</th>
</tr>
</table>
</thead>
<tbody>
{% if step == 'prequalification' %}
{% prequal_tag source=questions %}
{% elif step == 'your_information' or step == 'your_spouse' %}
{% personal_info_tag source=questions %}
{% elif step == 'your_marriage' %}
{% marriage_tag source=questions %}
{% elif step == 'other_questions' %}
{% combine_address source=questions %}
{% else %}
{% for question in questions %}
<tr>
<td style="padding-right: 5%">{{question.question__name}}</td>
<td class="value-column">{% reformat_value source=question %}</td>
</tr>
{% endfor %}
{% endif %}
</tbody>
</table>
{% endif %}

+ 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">


+ 52
- 33
edivorce/apps/core/templates/question/12_review.html View File

@ -31,14 +31,14 @@
</div>
</div>
</div>
<div class="question-well step-review">
<div class="question-well step-review {% if step_status.which_orders != 'Complete' %}error{% endif %}">
<div class="collapse-trigger" data-toggle="collapse" aria-expanded="true" data-target="#review_step_1" aria-controls="collapse_changed_name">
<div>
Step 1: What are you asking for
</div>
</div>
<p class="review-buttons"><a class="btn btn-success" href="{% url 'question_steps' 'orders' %}">Edit</a> </p>
</div>
</div>
{% if step_status.which_orders != 'Complete' %}{% include 'partials/incomplete.html' %}{% endif %}
<p class="review-buttons"><a class="btn btn-success" href="{% url 'question_steps' 'orders' %}">Edit</a> </p>
<div class="clearfix"> </div>
<div class="collapse in" id="review_step_1">
<div>
@ -47,12 +47,13 @@
</div>
</div>
<div class="question-well step-review">
<div class="question-well step-review {% if step_status.your_information != 'Complete' %}error{% endif %}">
<div class="collapse-trigger" data-toggle="collapse" aria-expanded="true" data-target="#review_step_2" aria-controls="collapse_changed_name">
<div>
Step 2: Your information
</div>
</div>
</div>
{% if step_status.your_information != 'Complete' %}{% include 'partials/incomplete.html' %}{% endif %}
<p class="review-buttons"><a class="btn btn-success" href="{% url 'question_steps' 'claimant' %}">Edit</a> </p>
<div class="clearfix"> </div>
<div class="collapse in" id="review_step_2">
@ -62,13 +63,14 @@
</div>
</div>
<div class="question-well step-review">
<div class="question-well step-review {% if step_status.your_spouse != 'Complete' %}error{% endif %}">
<div class="collapse-trigger" data-toggle="collapse" aria-expanded="true" data-target="#review_step_3" aria-controls="collapse_changed_name">
<div>
Step 3: Your spouse
</div>
</div>
<p class="review-buttons"><a class="btn btn-success" href="{% url 'question_steps' 'respondent' %}">Edit</a> </p>
{% if step_status.your_spouse != 'Complete' %}{% include 'partials/incomplete.html' %}{% endif %}
<p class="review-buttons"><a class="btn btn-success" href="{% url 'question_steps' 'respondent' %}">Edit</a> </p>
<div class="clearfix"> </div>
<div class="collapse in" id="review_step_3">
<div>
@ -77,13 +79,14 @@
</div>
</div>
<div class="question-well step-review">
<div class="question-well step-review {% if step_status.your_marriage != 'Complete' %}error{% endif %}">
<div class="collapse-trigger" data-toggle="collapse" aria-expanded="true" data-target="#review_step_4" aria-controls="collapse_changed_name">
<div>
Step 4: Your marriage
</div>
</div>
<p class="review-buttons"><a class="btn btn-success" href="{% url 'question_steps' 'marriage' %}">Edit</a> </p>
{% if step_status.your_marriage != 'Complete' %}{% include 'partials/incomplete.html' %}{% endif %}
<p class="review-buttons"><a class="btn btn-success" href="{% url 'question_steps' 'marriage' %}">Edit</a> </p>
<div class="clearfix"> </div>
<div class="collapse in" id="review_step_4">
<div>
@ -92,13 +95,14 @@
</div>
</div>
<div class="question-well step-review">
<div class="question-well step-review {% if step_status.your_separation != 'Complete' %}error{% endif %}">
<div class="collapse-trigger" data-toggle="collapse" aria-expanded="true" data-target="#review_step_5" aria-controls="collapse_changed_name">
<div>
Step 5: Your separation
</div>
</div>
<p class="review-buttons"><a class="btn btn-success" href="{% url 'question_steps' 'separation' %}">Edit</a> </p>
{% if step_status.your_separation != 'Complete' %}{% include 'partials/incomplete.html' %}{% endif %}
<p class="review-buttons"><a class="btn btn-success" href="{% url 'question_steps' 'separation' %}">Edit</a> </p>
<div class="clearfix"> </div>
<div class="collapse in" id="review_step_5">
<div>
@ -108,13 +112,14 @@
</div>
{% if derived.has_children_of_marriage %}
<div class="question-well step-review">
<div class="question-well step-review {% if step_status.your_children != 'Complete' %}error{% endif %}">
<div class="collapse-trigger" data-toggle="collapse" aria-expanded="true" data-target="#review_step_6" aria-controls="collapse_changed_name">
<div>
Step {% step_order step="children" %}: Your children
</div>
</div>
<p class="review-buttons"><a class="btn btn-success" href="{% url 'question_steps' 'children' 'your_children' %}">Edit</a> </p>
{% if step_status.your_children != 'Complete' %}{% include 'partials/incomplete.html' %}{% endif %}
<p class="review-buttons"><a class="btn btn-success" href="{% url 'question_steps' 'children' 'your_children' %}">Edit</a> </p>
<div class="clearfix"> </div>
<div class="collapse in" id="review_step_6">
<div>
@ -125,13 +130,14 @@
{% endif %}
{% if 'Spousal support' in which_orders.0.value|load_json %}
<div class="question-well step-review">
<div class="question-well step-review {% if step_status.spousal_support != 'Complete' %}error{% endif %}">
<div class="collapse-trigger" data-toggle="collapse" aria-expanded="true" data-target="#review_step_7" aria-controls="collapse_changed_name">
<div>
Step {% step_order step="support" %}: Spousal support
</div>
</div>
<p class="review-buttons"><a class="btn btn-success" href="{% url 'question_steps' 'support' %}">Edit</a> </p>
{% if step_status.spousal_support != 'Complete' %}{% include 'partials/incomplete.html' %}{% endif %}
<p class="review-buttons"><a class="btn btn-success" href="{% url 'question_steps' 'support' %}">Edit</a> </p>
<div class="clearfix"> </div>
<div class="collapse in" id="review_step_7">
<div>
@ -142,13 +148,14 @@
{% endif %}
{% if 'Division of property and debts' in which_orders.0.value|load_json %}
<div class="question-well step-review">
<div class="question-well step-review {% if step_status.property_and_debt != 'Complete' %}error{% endif %}">
<div class="collapse-trigger" data-toggle="collapse" aria-expanded="true" data-target="#review_step_8" aria-controls="collapse_changed_name">
<div>
Step {% step_order step="property" %}: Property and debt
</div>
</div>
<p class="review-buttons"><a class="btn btn-success" href="{% url 'question_steps' 'property' %}">Edit</a> </p>
{% if step_status.property_and_debt != 'Complete' %}{% include 'partials/incomplete.html' %}{% endif %}
<p class="review-buttons"><a class="btn btn-success" href="{% url 'question_steps' 'property' %}">Edit</a> </p>
<div class="clearfix"> </div>
<div class="collapse in" id="review_step_8">
<div>
@ -159,13 +166,14 @@
{% endif %}
{% if 'Other orders' in which_orders.0.value|load_json %}
<div class="question-well step-review">
<div class="question-well step-review {% if step_status.other_orders != 'Complete' %}error{% endif %}">
<div class="collapse-trigger" data-toggle="collapse" aria-expanded="true" data-target="#review_step_9" aria-controls="collapse_changed_name">
<div>
Step {% step_order step="other_orders" %}: Other orders
</div>
</div>
<p class="review-buttons"><a class="btn btn-success" href="{% url 'question_steps' 'other_orders' %}">Edit</a> </p>
{% if step_status.other_orders != 'Complete' %}{% include 'partials/incomplete.html' %}{% endif %}
<p class="review-buttons"><a class="btn btn-success" href="{% url 'question_steps' 'other_orders' %}">Edit</a> </p>
<div class="clearfix"> </div>
<div class="collapse in" id="review_step_9">
<div>
@ -175,13 +183,14 @@
</div>
{% endif %}
<div class="question-well step-review">
<div class="question-well step-review {% if step_status.other_questions != 'Complete' %}error{% endif %}">
<div class="collapse-trigger" data-toggle="collapse" aria-expanded="true" data-target="#review_step_10" aria-controls="collapse_changed_name">
<div>
Step {% step_order step="other_questions" %}: Other questions
</div>
</div>
<p class="review-buttons"><a class="btn btn-success" href="{% url 'question_steps' 'other_questions' %}">Edit</a> </p>
{% if step_status.other_questions != 'Complete' %}{% include 'partials/incomplete.html' %}{% endif %}
<p class="review-buttons"><a class="btn btn-success" href="{% url 'question_steps' 'other_questions' %}">Edit</a> </p>
<div class="clearfix"> </div>
<div class="collapse in" id="review_step_10">
<div>
@ -190,13 +199,14 @@
</div>
</div>
<div class="question-well step-review">
<div class="question-well step-review {% if step_status.filing_locations != 'Complete' %}error{% endif %}">
<div class="collapse-trigger" data-toggle="collapse" aria-expanded="true" data-target="#review_step_11" aria-controls="collapse_changed_name">
<div>
Step {% step_order step="location" %}: Filing location
</div>
</div>
<p class="review-buttons"><a class="btn btn-success" href="{% url 'question_steps' 'location' %}">Edit</a> </p>
{% if step_status.filing_locations != 'Complete' %}{% include 'partials/incomplete.html' %}{% endif %}
<p class="review-buttons"><a class="btn btn-success" href="{% url 'question_steps' 'location' %}">Edit</a> </p>
<div class="clearfix"> </div>
<div class="collapse in" id="review_step_11">
<div>
@ -204,7 +214,20 @@
</div>
</div>
</div>
{% if derived.any_errors %}
<div class="review-warning">
<div><span class="exclamation"><i class="fa fa-fw fa-exclamation-circle"></i></span></div>
<div>
You have not completed at least one field that is required to create your forms.
Missing required fields are noted on this screen in the
following way: <span class="warning">MISSING REQUIRED FIELD</span>
Forms which are missing fields will be identified with the following symbol:
<span class="progress-status"><i class="fa fa-adjust" aria-hidden="true"></i></span>
Please ensure that all required fields are
completed and then return to this page.
</div>
</div>
{% endif %}
<div id="questions_modal" class="modal in" tabindex="-1" role="dialog" style="display: block">
<div class="modal-dialog" role="document">
@ -226,13 +249,9 @@
{% endblock %}
{% block formbuttons %}
<div class="form-buttons clearfix">
<a class="btn btn-success pull-right" href="{% url 'dashboard_nav' 'print_form' %}">Next&nbsp;&nbsp;&nbsp;<i class="fa fa-arrow-circle-o-right"></i></a>
</div>
{% endblock %}
{% block formBack %}{% prev_step step='review' %}{% endblock %}
{% block formNext %}{% url 'dashboard_nav' 'print_form' %}{% endblock %}
{% block nextButtonAttribute %}{% if derived.any_errors %}disabled{% endif %}{% endblock %}
{% block sidebarNav %}
<!-- no sidebar -->


+ 244
- 380
edivorce/apps/core/templatetags/summary_format.py View File

@ -5,40 +5,66 @@ import json
from django.urls import reverse
from django.utils.html import format_html, format_html_join
from django.utils.safestring import mark_safe
NO_ANSWER = 'No answer'
MISSING_RESPONSE = mark_safe('<div class="table-error"><span class="warning">MISSING REQUIRED FIELD</span></div>')
register = template.Library()
@register.simple_tag
def reformat_value(source, question_key):
def reformat_value(source):
"""
Reformat user response on summary page
ie) Remove [], make it a bullet point form
Cases:
- If there is a missing field, return error html
- If value is a json list:
Either return the only item
Or make it into bullet point form
- If it's a text area:
For certain fields, make it into bullet points
For others, convert \n to <br>
- Otherwise, return the original value
"""
if source['error']:
return MISSING_RESPONSE
elif not source['value']:
return NO_ANSWER
question_key = source['question_id']
try:
lst = json.loads(source)
if len(lst) == 1:
return lst[0]
else:
return process_list(lst, question_key)
json_list = json.loads(source['value'])
return process_json_list(question_key, json_list)
except:
if question_key == 'spouse_support_details' or question_key == 'other_orders_detail'\
or question_key == 'provide_certificate_later_reason' or question_key == 'not_provide_certificate_reason':
return reformat_list(source)
return source
if question_key in ['spouse_support_details', 'other_orders_detail']:
return reformat_textarea(source)
elif '\n' in source['value']:
return reformat_textarea(source, as_ul=False)
return source['value']
def process_list(lst, question_key):
def process_json_list(question_key, json_list):
"""
Convert a json list to html list, handling special question formats
"""
assert isinstance(json_list, list)
if question_key.startswith('other_name_'):
list_items = format_html_join(
'\n',
'<li>{} {}</li>',
((alias_type, value) for alias_type, value in lst if value))
list_items = get_other_name_tags(json_list)
elif question_key == 'reconciliation_period':
list_items = get_reconciliation_period_tags(json_list)
elif question_key == 'claimant_children':
return get_claimant_children_tags(json_list)
elif 'address' in question_key:
tag = format_html_join(
'\n',
'{0}<br/>',
((value, '') for value in json_list))
return tag
else:
list_items = format_html_join(
'\n',
'<li>{0}</li>',
((value, '') for value in lst if value and not value.isspace()))
((value, '') for value in json_list if value and not value.isspace()))
tag = format_html(
'<ul>{}</ul>',
list_items)
@ -46,55 +72,112 @@ def process_list(lst, question_key):
return tag
def reformat_list(source):
text_list = source.split('\n')
def get_other_name_tags(json_list):
list_items = format_html_join(
'\n',
'<li>{} {}</li>',
((alias_type, value) for alias_type, value in json_list if value))
return list_items
def get_reconciliation_period_tags(json_list):
list_items = format_html_join(
'\n',
'<li>From {} to {}</li>',
(date_range for date_range in json_list))
return list_items
def get_claimant_children_tags(json_list):
child_counter = 1
tags = ''
for child in json_list:
tags = format_html(
'{}{}{}{}{}{}{}',
tags,
format_review_row_heading('Child {}'.format(child_counter), 'review-child-heading'),
format_row('Child\'s name', child['child_name']),
format_row('Birth date', child['child_birth_date']),
format_row('Child now living with', child['child_live_with']),
format_row('Relationship to yourself (claimant 1)', child['child_relationship_to_you']),
format_row('Relationship to your spouse (claimant 2)', child['child_relationship_to_spouse']))
child_counter = child_counter + 1
return tags
def reformat_textarea(source, as_ul=True):
"""
Takes a textarea value (string with \n) and converts either into html with <br> tags or a list
"""
response = source['value']
if not response:
return NO_ANSWER
text_list = response.split('\n')
if len(text_list) > 1:
list_items = format_html_join(
'\n',
'<li>{0}</li>',
((value, '') for value in text_list if value))
tag = format_html(
'<ul>{}</ul>',
list_items)
if as_ul:
list_items = format_html_join(
'\n',
'<li>{0}</li>',
((value, '') for value in text_list if value))
tag = format_html(
'<ul>{}</ul>',
list_items)
else:
tag = format_html_join(
'\n',
'{0}<br/>',
((value, '') for value in text_list))
return tag
else:
return text_list.pop()
def format_row(question, response):
""" Used for children sub-section tables """
return format_html(
'<tr><td width="75%" class="table-bordered" style="padding-right: 5%">{0}</td><td class="table-bordered" width="25%">{1}</td></tr>',
'<tr><td class="table-bordered" style="padding-right: 5%">{0}</td><td class="table-bordered value-column">{1}</td></tr>',
question,
response)
def format_review_row_heading(title, style=""):
def format_review_row_heading(title, style="", substep=None):
""" Used for children sub-section tables """
if substep:
url = reverse('question_steps', args=['children', substep])
extra_html = mark_safe(f'<span class="review-buttons"><a href="{url}">Edit</a></span>')
else:
extra_html = ''
return format_html(
'<tr><td colspan="2" class="table-bordered {1}"><b>{0}</b></td></tr>',
'<tr><td colspan="2" class="table-bordered {1}"><b>{0}</b>{2}</td></tr>',
title,
style)
style,
extra_html,
)
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)
def format_children(context, source):
"""
:param source:
:return:
"""
substep_to_heading = {
'your_children': 'Children details',
'income_expenses': 'Income & expenses',
'facts': 'Payor & Fact Sheets',
'payor_medical': 'Medical & other expenses',
'what_for': 'What are you asking for?',
}
question_to_heading = OrderedDict()
question_to_heading['Children details'] = [
question_to_heading['your_children'] = [
'claimant_children'
]
question_to_heading['Income & expenses'] = [
question_to_heading['income_expenses'] = [
'how_will_calculate_income',
'annual_gross_income',
'spouse_annual_gross_income',
@ -103,7 +186,7 @@ def format_children(context, source):
'Special or Extraordinary Expenses (Fact Sheet A)',
'describe_order_special_extra_expenses'
]
question_to_heading['Payor & Fact Sheets'] = [
question_to_heading['facts'] = [
'Shared Living Arrangement (Fact Sheet B)',
'Split Living Arrangement (Fact Sheet C)',
'child_support_payor',
@ -112,13 +195,13 @@ def format_children(context, source):
'claiming_undue_hardship',
'Undue Hardship (Fact Sheet E)'
]
question_to_heading['Medical & other expenses'] = [
question_to_heading['payor_medical'] = [
'medical_coverage_available',
'whose_plan_is_coverage_under',
'child_support_payments_in_arrears',
'child_support_arrears_amount'
]
question_to_heading['What are you asking for?'] = [
question_to_heading['what_for'] = [
'child_support_in_order',
# 'order_monthly_child_support_amount',
'child_support_in_order_reason',
@ -142,106 +225,84 @@ def format_children(context, source):
fact_sheet_mapping['Undue Hardship (Fact Sheet E)'] = reverse('question_steps', args=['children', 'facts'])
fact_sheet_mapping['Income over $150,000 (Fact Sheet F)'] = reverse('question_steps', args=['children', 'facts'])
child_support_orders = {'want_parenting_arrangements', 'order_respecting_arrangement', 'order_for_child_support'}
tags = format_html('<tbody>')
# process mapped questions first
working_source = source.copy()
for title, questions in question_to_heading.items():
for substep, questions in question_to_heading.items():
title = substep_to_heading[substep]
tags = format_html(
'{}{}',
tags,
format_review_row_heading(title))
format_review_row_heading(title, substep=substep))
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(filter(lambda x: x['question_id'] == question, working_source))
item_list = list(filter(lambda x: x['question_id'] == question, working_source))
# skip child support order related questions if user did not select that option
if question in child_support_orders and len(item):
item = item.pop()
if question == 'order_for_child_support' and len(item_list):
item = item_list.pop()
if context['derived']['wants_child_support'] is True and item['value']:
# make sure free form text is reformted to be bullet list.
tags = format_html(
'{}{}',
tags,
format_row(item['question__name'], reformat_list(item['value'])))
format_row(item['question__name'], reformat_textarea(item)))
continue
if len(item):
item = item.pop()
if len(item_list):
item = item_list.pop()
q_id = item['question_id']
if q_id in questions:
if q_id == 'claimant_children':
child_counter = 1
for child in json.loads(item['value']):
tags = format_html(
'{}{}{}{}{}{}{}',
tags,
format_review_row_heading('Child {}'.format(child_counter), 'review-child-heading'),
format_row('Child\'s name', child['child_name']),
format_row('Birth date', child['child_birth_date']),
format_row('Child now living with', child['child_live_with']),
format_row('Relationship to yourself (claimant 1)', child['child_relationship_to_you']),
format_row('Relationship to your spouse (claimant 2)', child['child_relationship_to_spouse']))
child_counter = child_counter + 1
else:
value = item['value']
if q_id == 'describe_order_special_extra_expenses':
pass
if q_id == 'payor_monthly_child_support_amount':
# Only display this field if it is sole custody
sole_custody = (all([child['child_live_with'] == 'Lives with you' for child in context['derived']['children']]) or
all([child['child_live_with'] == 'Lives with spouse' for child in context['derived']['children']]))
if not sole_custody:
continue
try:
value = json.loads(item['value'])
except:
pass
question_name = item['question__name']
if question == 'child_support_in_order':
question_name = '{} {}'.format(question_name, context['derived']['child_support_payor_by_name'])
if value == 'MATCH':
value = '{:.2f}'.format(float(context['derived']['guideline_amounts_difference_total']))
elif value == 'DIFF':
amount = list(filter(lambda x: x['question_id'] == 'order_monthly_child_support_amount', working_source))
amount = amount.pop()
value = '{:.2f}'.format(float(amount['value']))
if question == 'describe_order_special_extra_expenses':
value = reformat_list(value)
if isinstance(value, list):
tags = format_html('{}{}', tags, format_row(question_name, process_list(value, q_id)))
elif isinstance(value, str):
if len(value):
tags = format_html('{}{}', tags, format_row(question_name, value))
else:
tags = format_html('{}{}', tags, format_row(question_name, value))
if q_id == 'describe_order_special_extra_expenses':
pass
if q_id == 'payor_monthly_child_support_amount':
# Only display this field if it is sole custody
if not context['derived']['sole_custody']:
continue
question_name = item['question__name']
if question == 'child_support_in_order':
question_name = '{} {}'.format(question_name, context['derived']['child_support_payor_by_name'])
if item['value'] == 'MATCH':
item['value'] = '{:.2f}'.format(float(context['derived']['guideline_amounts_difference_total']))
elif item['value'] == 'DIFF':
amount = list(filter(lambda x: x['question_id'] == 'order_monthly_child_support_amount', working_source))
amount = amount.pop()
item['value'] = '{:.2f}'.format(float(amount['value']))
tags = format_html('{}{}', tags, format_row(question_name, reformat_value(item)))
tags = format_html('{}</tbody> <tbody class="review-table-spacer">', tags)
tags = format_html('{}</tbody>', tags)
return tags
@ -249,321 +310,124 @@ def format_children(context, source):
@register.simple_tag
def combine_address(source):
"""
Reformat address to combine them into one cell with multiple line
Also show/hide optional questions
"""
tags = ''
address_you = ""
fax_you = ""
email_you = ""
address_spouse = ""
fax_spouse = ""
email_spouse = ""
is_specific_date = False
effective_date = ""
address_you = []
address_you_name = "What is the best address to send you official court documents?"
address_you_error = False
address_spouse = []
address_spouse_name = "What is the best address to send your spouse official court documents?"
address_spouse_error = False
take_effect_on_item = None
for item in source:
q_id = item['question_id']
if "you" in q_id:
if "email" not in q_id and "fax" not in q_id:
if q_id == "address_to_send_official_document_country_you":
if 'address' in q_id and 'email' not in q_id and 'fax' not in q_id:
if 'you' in q_id:
if address_you_error:
continue
address_you = format_html('{}{}<br />', address_you, item["value"])
elif "fax" in q_id:
fax_you = item["value"]
elif "email" in q_id:
email_you = item["value"]
elif "spouse" in q_id:
if "email" not in q_id and "fax" not in q_id:
if q_id == "address_to_send_official_document_country_spouse":
elif item['error']:
address_you_error = True
tags = format_table_data(tags, address_you_name, MISSING_RESPONSE)
continue
address_spouse = format_html('{}{}<br />', address_spouse, item["value"])
elif "fax" in q_id:
fax_spouse = item["value"]
elif "email" in q_id:
email_spouse = item["value"]
elif q_id == "divorce_take_effect_on":
if item['value'] == "specific date":
is_specific_date = True
elif item['value']:
address_you.append(item['value'])
if 'postal_code' in q_id:
tags = format_table_data(tags, address_you_name, process_json_list(q_id, address_you))
continue
else:
effective_date = item['value']
elif q_id == "divorce_take_effect_on_specific_date" and is_specific_date:
effective_date = item['value']
if address_you != "":
tags = format_table_data(tags, "What is the best address to send you official court documents?", address_you)
if fax_you != "":
tags = format_table_data(tags, "Fax", fax_you)
if email_you != "":
tags = format_table_data(tags, "Email", email_you)
if address_spouse != "":
tags = format_table_data(tags, "What is the best address to send your spouse official court documents?", address_spouse)
if fax_spouse != "":
tags = format_table_data(tags, "Fax", fax_spouse)
if email_spouse != "":
tags = format_table_data(tags, "Email", email_spouse)
if effective_date != "":
tags = format_table_data(tags, "Divorce is to take effect on", effective_date)
if address_spouse_error:
continue
elif item['error']:
address_spouse_error = True
tags = format_table_data(tags, address_spouse_name, MISSING_RESPONSE)
continue
elif item['value']:
address_spouse.append(item['value'])
if 'postal_code' in q_id:
tags = format_table_data(tags, address_spouse_name, process_json_list(q_id, address_spouse))
continue
elif q_id == 'divorce_take_effect_on':
take_effect_on_item = item
if item['value'] == 'specific date':
continue
elif q_id == 'divorce_take_effect_on_specific_date':
item['question__name'] = take_effect_on_item['question__name']
tags = format_question_for_table(tags, item)
return tags
@register.simple_tag(takes_context=True)
def marriage_tag(context, source):
"""
Reformat your_marriage step
Also show/hide optional questions
"""
show_all = False
tags = ''
marriage_location = ""
married_date = ""
married_date_q = ""
common_law_date = ""
common_law_date_q = ""
marital_status_you = ""
marital_status_you_q = ""
marital_status_spouse = ""
marital_status_spouse_q = ""
# get married_marriage_like value to check if legally married or not
for question in context.get('prequalification', ''):
if question['question_id'] == 'married_marriage_like' and question['value'] == 'Legally married':
show_all = True
break
elif question['question_id'] == 'married_marriage_like':
break
marriage_location = []
marriage_country_is_other = False
skip_location = False
for item in source:
q_id = item['question_id']
value = item['value']
q_name = item['question__name']
if q_id == 'when_were_you_married':
married_date_q = q_name
married_date = value
elif q_id == 'when_were_you_live_married_like':
common_law_date_q = q_name
common_law_date = value
elif q_id.startswith('where_were_you_married'):
if value == 'Other':
if q_id.startswith('where_were_you_married') and not skip_location:
if item['error']:
skip_location = True
tags = format_table_data(tags, "Where were you married?", MISSING_RESPONSE)
continue
marriage_location = format_html('{}{}<br />', marriage_location, value)
elif q_id == 'marital_status_before_you':
marital_status_you_q = q_name
marital_status_you = value
elif q_id == 'marital_status_before_spouse':
marital_status_spouse_q = q_name
marital_status_spouse = value
if show_all and married_date != "":
tags = format_table_data(tags, married_date_q, married_date)
if common_law_date != "":
tags = format_table_data(tags, common_law_date_q, common_law_date)
if show_all and marriage_location != "":
tags = format_table_data(tags, "Where were you married", marriage_location)
if marital_status_you != "":
tags = format_table_data(tags, marital_status_you_q, marital_status_you)
if marital_status_spouse != "":
tags = format_table_data(tags, marital_status_spouse_q, marital_status_spouse)
return tags
@register.simple_tag
def property_tag(source):
"""
Reformat your_property and debt step
Also show/hide optional questions
"""
tags = ''
division = division_detail = other_detail = None
for item in source:
q_id = item['question_id']
if q_id == 'deal_with_property_debt':
division = item
elif q_id == 'how_to_divide_property_debt':
division_detail = item
elif q_id == 'other_property_claims':
other_detail = item
if division:
tags = format_table_data(tags, division['question__name'], division['value'])
if division and division['value'] == "Unequal division" and division_detail:
tags = format_table_data(tags, division_detail['question__name'], process_list(division_detail['value'].split('\n'), division_detail['question_id']))
if other_detail and other_detail['value'].strip():
tags = format_table_data(tags, other_detail['question__name'], process_list(other_detail['value'].split('\n'), other_detail['question_id']))
elif q_id == 'where_were_you_married_country' and item['value'] == 'Other':
marriage_country_is_other = True
continue
elif item['value']:
marriage_location.append(item['value'])
# Insert in the right spot in table. Either country is the last item (if US or Canada) or other country is last
us_or_canada = not marriage_country_is_other and q_id == 'where_were_you_married_country'
other_country = marriage_country_is_other and q_id == 'where_were_you_married_other_country'
if us_or_canada or other_country:
tags = format_table_data(tags, "Where were you married?", process_json_list('married_address', marriage_location))
else:
tags = format_question_for_table(tags, item)
return tags
@register.simple_tag
def prequal_tag(source):
"""
Reformat prequalification step
Also show/hide optional questions
"""
tags = ''
marriage_status = lived_in_bc = live_at_least_year = separation_date = try_reconcile = reconciliation_period = None
children_of_marriage = number_children_under_19 = number_children_over_19 = financial_support = certificate = provide_later = None
provide_later_reason = not_provide_later_reason = in_english = divorce_reason = children_live_with_others = None
for item in source:
q_id = item['question_id']
if q_id == 'married_marriage_like':
marriage_status = item
elif q_id == 'lived_in_bc':
lived_in_bc = item
elif q_id == 'lived_in_bc_at_least_year':
live_at_least_year = item
elif q_id == 'separation_date':
separation_date = item
elif q_id == 'try_reconcile_after_separated':
try_reconcile = item
elif q_id == 'reconciliation_period':
reconciliation_period = item
elif q_id == 'children_of_marriage':
children_of_marriage = item
elif q_id == 'number_children_under_19':
number_children_under_19 = item
elif q_id == 'number_children_over_19':
number_children_over_19 = item
elif q_id == 'children_financial_support':
financial_support = item
elif q_id == 'children_live_with_others':
children_live_with_others = item
elif q_id == 'original_marriage_certificate':
certificate = item
elif q_id == 'provide_certificate_later':
provide_later = item
elif q_id == 'provide_certificate_later_reason':
provide_later_reason = item
elif q_id == 'not_provide_certificate_reason':
not_provide_later_reason = item
elif q_id == 'marriage_certificate_in_english':
in_english = item
elif q_id == 'divorce_reason':
divorce_reason = item
if divorce_reason['value'] == 'live separate':
divorce_reason['value'] = 'Lived apart for one year'
if marriage_status:
tags = format_table_data(tags, marriage_status['question__name'], marriage_status['value'])
if lived_in_bc:
tags = format_table_data(tags, lived_in_bc['question__name'], lived_in_bc['value'])
if live_at_least_year:
tags = format_table_data(tags, live_at_least_year['question__name'], live_at_least_year['value'])
if separation_date:
tags = format_table_data(tags, separation_date['question__name'], separation_date['value'])
if try_reconcile:
tags = format_table_data(tags, try_reconcile['question__name'], try_reconcile['value'])
if try_reconcile and try_reconcile['value'] == 'YES' and reconciliation_period:
tags = format_table_data(tags, reconciliation_period['question__name'], reconciliation_period_reformat(reconciliation_period['value']))
if children_of_marriage:
tags = format_table_data(tags, children_of_marriage['question__name'], children_of_marriage['value'])
if children_of_marriage and children_of_marriage['value'] == 'YES' and number_children_under_19:
tags = format_table_data(tags, number_children_under_19['question__name'], number_children_under_19['value'])
if children_of_marriage and children_of_marriage['value'] == 'YES' and number_children_over_19:
tags = format_table_data(tags, number_children_over_19['question__name'], number_children_over_19['value'])
if children_of_marriage and children_of_marriage['value'] == 'YES' and number_children_over_19 and financial_support and financial_support['value']:
tags = format_table_data(tags, financial_support['question__name'], '<br>'.join(json.loads(financial_support['value'])))
if children_of_marriage and children_of_marriage['value'] == 'YES' and number_children_over_19 and financial_support:
tags = format_table_data(tags, children_live_with_others['question__name'], children_live_with_others['value'])
if certificate:
tags = format_table_data(tags, certificate['question__name'], certificate['value'])
if certificate and certificate['value'] == 'NO' and provide_later:
tags = format_table_data(tags, provide_later['question__name'], provide_later['value'])
if certificate and provide_later and certificate['value'] == 'NO' and provide_later['value'] == 'YES' and provide_later_reason:
tags = format_table_data(tags, provide_later_reason['question__name'], process_list(provide_later_reason['value'].split('\n'), provide_later_reason['question_id']))
if certificate and provide_later and certificate['value'] == 'NO' and provide_later['value'] == 'NO' and not_provide_later_reason:
tags = format_table_data(tags, not_provide_later_reason['question__name'], process_list(not_provide_later_reason['value'].split('\n'), not_provide_later_reason['question_id']))
if marriage_status and marriage_status['value'] == 'Living together in a marriage like relationship' and in_english:
tags = format_table_data(tags, in_english['question__name'], in_english['value'])
if divorce_reason:
tags = format_table_data(tags, divorce_reason['question__name'], divorce_reason['value'])
if item['question_id'] == 'divorce_reason':
if item['value'] == 'live separate':
item['value'] = 'Lived apart for one year'
elif item['value'] == 'other':
item['value'] = 'Other reasons (grounds)'
tags = format_question_for_table(tags, item)
return tags
@register.simple_tag
def personal_info_tag(source):
"""
Reformat your information and your spouse step
Also show/hide optional questions
"""
tags = ''
name = other_name = other_name_list = last_name_born = last_name_before = None
birthday = occupation = lived_bc = moved_bc = None
lived_in_bc_item = None
for item in source:
q_id = item['question_id']
if q_id.startswith('name_'):
name = item
elif q_id.startswith('any_other_name_'):
other_name = item
elif q_id.startswith('other_name_'):
other_name_list = item
elif q_id.startswith('last_name_born_'):
last_name_born = item
elif q_id.startswith('last_name_before_married_'):
last_name_before = item
elif q_id.startswith('birthday_'):
birthday = item
elif q_id.startswith('occupation_'):
occupation = item
elif q_id.startswith('lived_in_bc_'):
lived_bc = item
moved_to_bc_value = "Moved to B.C. on"
if q_id.startswith('lived_in_bc_') and item['value'] == moved_to_bc_value:
lived_in_bc_item = item
continue
elif q_id.startswith('moved_to_bc_date_'):
moved_bc = item
if name:
tags = format_table_data(tags, name['question__name'], name['value'])
if other_name:
tags = format_table_data(tags, other_name['question__name'], other_name['value'])
if other_name and other_name['value'] == 'YES' and other_name_list:
tags = format_table_data(tags, other_name_list['question__name'], process_list(json.loads(other_name_list['value']), other_name_list['question_id']))
if last_name_born:
tags = format_table_data(tags, last_name_born['question__name'], last_name_born['value'])
if last_name_before:
tags = format_table_data(tags, last_name_before['question__name'], last_name_before['value'])
if birthday:
tags = format_table_data(tags, birthday['question__name'], birthday['value'])
if occupation:
tags = format_table_data(tags, occupation['question__name'], occupation['value'])
if lived_bc and moved_bc and lived_bc['value'] == "Moved to B.C. on":
tags = format_table_data(tags, lived_bc['question__name'], lived_bc['value'] + ' ' + moved_bc['value'])
if lived_bc and lived_bc['value'] != "Moved to B.C. on" and lived_bc:
tags = format_table_data(tags, lived_bc['question__name'], lived_bc['value'])
item['question__name'] = lived_in_bc_item['question__name']
item['value'] = f"{moved_to_bc_value} {item['value']}"
tags = format_question_for_table(tags, item)
return tags
def format_question_for_table(tags, question):
name = question['question__name']
response = reformat_value(question)
return format_table_data(tags, name, response)
def format_table_data(tags, question, response):
return format_html(
'{}<tr><td width="75%" style="padding-right: 5%">{}</td><td width="25%">{}</td></tr>',
'{}<tr><td style="padding-right: 5%">{}</td><td class="value-column">{}</td></tr>',
tags,
question,
response)
def reconciliation_period_reformat(lst):
"""
Reformat reconciliation period into From [dd/mm/yyyy] to [dd/mm/yyyy] format
"""
try:
lst = json.loads(lst)
except:
lst = []
period = ""
for f_date, t_date in lst:
period = format_html('{}From {} to {}<br />', period, f_date, t_date)
return period

+ 12
- 3
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,7 @@ DERIVED_DATA = [
'pursuant_parenting_arrangement',
'pursuant_child_support',
'sole_custody',
'special_expenses_missing_error',
'any_errors',
]
@ -160,6 +161,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 +268,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,8 +745,11 @@ 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_errors(responses, derived):
for question_key in responses:
if question_key.endswith('_error'):
return True
return False
def _any_question_errors(responses, questions):


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

@ -133,6 +133,8 @@ question_step_mapping = {
'lived_in_bc',
'lived_in_bc_at_least_year',
'separation_date',
'try_reconcile_after_separated',
'reconciliation_period',
'children_of_marriage',
'number_children_under_19',
'number_children_over_19',
@ -142,10 +144,8 @@ question_step_mapping = {
'provide_certificate_later',
'provide_certificate_later_reason',
'not_provide_certificate_reason',
'divorce_reason',
'marriage_certificate_in_english',
'try_reconcile_after_separated',
'reconciliation_period'],
'divorce_reason'],
'which_orders': ['want_which_orders'],
'your_information': ['name_you',
'any_other_name_you',
@ -153,18 +153,18 @@ question_step_mapping = {
'last_name_born_you',
'last_name_before_married_you',
'birthday_you',
'occupation_you',
'lived_in_bc_you',
'moved_to_bc_date_you',
'occupation_you'],
'moved_to_bc_date_you',],
'your_spouse': ['name_spouse',
'any_other_name_spouse',
'other_name_spouse',
'last_name_born_spouse',
'last_name_before_married_spouse',
'birthday_spouse',
'occupation_spouse',
'lived_in_bc_spouse',
'moved_to_bc_date_spouse',
'occupation_spouse'],
'moved_to_bc_date_spouse',],
'your_marriage': ['when_were_you_married',
'where_were_you_married_city',
'where_were_you_married_prov',
@ -295,7 +295,7 @@ page_step_mapping = {
'property': 'property_and_debt',
'other_orders': 'other_orders',
'other_questions': 'other_questions',
'filing_locations': 'filing_locations',
'location': 'filing_locations',
}
""" List of court registries """


+ 9
- 5
edivorce/apps/core/utils/step_completeness.py View File

@ -34,7 +34,7 @@ def evaluate_numeric_condition(target, reveal_response):
def get_step_completeness(questions_by_step):
"""
Accepts a dictionary of {step: {question_id: {question__name, question_id, value, error}}} <-- from get_step_responses
Accepts a dictionary of {step: [{question__name, question_id, value, error}]} <-- from get_step_responses
Returns {step: status}, {step: [missing_question_key]}
"""
status_dict = {}
@ -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
- 1
edivorce/apps/core/utils/user_response.py View File

@ -27,7 +27,7 @@ def get_data_for_user(bceid_user):
def get_step_responses(responses_by_key):
"""
Accepts a dictionary of {question_key: user_response_value} <-- from get_data_for_user
Returns a dictionary of {step: {question_id: {question__name, question_id, value, error}}}
Returns a dictionary of {step: [{question__name, question_id, value, error}]}
"""
responses_by_step = {}
for step in page_step_mapping.values():


+ 2
- 9
edivorce/apps/core/views/main.py View File

@ -199,16 +199,9 @@ 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 = {}
# Just for now (until showing missing questions in review is implemented) remove unanswered questions
for step, question_list in responses_dict_by_step.items():
copy = deepcopy(question_list)
for question_dict in question_list:
if question_dict['value'] is None:
copy.remove(question_dict)
responses_dict[step] = copy
responses_dict = responses_dict_by_step
else:
responses_dict = get_data_for_user(request.user)
responses_dict_by_step = get_step_responses(responses_dict)


+ 177
- 172
edivorce/fixtures/Question.json
File diff suppressed because it is too large
View File


Loading…
Cancel
Save