Browse Source

DIV-519: Adding questions to find out the number of children and displaying appropriate warning messages

pull/160/head
Benard Ebinu 8 years ago
parent
commit
e7d5c9a19b
8 changed files with 161 additions and 36 deletions
  1. +1
    -0
      .gitignore
  2. +53
    -16
      edivorce/apps/core/static/js/functions.js
  3. +1
    -1
      edivorce/apps/core/static/js/main.js
  4. +45
    -2
      edivorce/apps/core/templates/prequalification/step_04.html
  5. +2
    -0
      edivorce/apps/core/templatetags/input_field.py
  6. +3
    -1
      edivorce/apps/core/utils/question_step_mapping.py
  7. +30
    -2
      edivorce/apps/core/utils/step_completeness.py
  8. +26
    -14
      edivorce/fixtures/Question.json

+ 1
- 0
.gitignore View File

@ -69,3 +69,4 @@ target/
# Noise
.DS_Store
.sass-cache/
edivorce/apps/core/static/css/main.css.map

+ 53
- 16
edivorce/apps/core/static/js/functions.js View File

@ -7,15 +7,59 @@ var reveal = function(el) {
var id = '#' + el.data("target_id");
var css_class = el.data("target_class");
var related_id = el.data("related_id");
// hide or show based on target id
var reveal_condition = el.data("reveal_condition");
var should_reveal = true;
if (reveal_condition !== undefined) {
should_reveal = false;
if (reveal_condition.startsWith(">=")) {
should_reveal = el.val() >= parseInt(reveal_condition.slice(2), 10);
} else if (reveal_condition.startsWith("<=")) {
should_reveal = el.val() <= parseInt(reveal_condition.slice(2), 10);
} else if (reveal_condition.startsWith("==")) {
should_reveal = el.val() === parseInt(reveal_condition.slice(2), 10);
} else if (reveal_condition.startsWith("<")) {
should_reveal = el.val() < parseInt(reveal_condition.slice(1), 10);
} else if (reveal_condition.startsWith(">")) {
should_reveal = el.val() > parseInt(reveal_condition.slice(1), 10) ;
}
if (!should_reveal) {
if (related_id !== undefined){
$('#' + related_id).hide();
}
if (css_class !== undefined){
$('.' + css_class).hide();
}
}
}
if (should_reveal) {
showHideTargetId(el, id, related_id);
showHideRevealClass(el, css_class);
if (el.prop('name') === "provide_certificate_later" || el.prop('name') === "original_marriage_certificate") {
if ($('input[name=provide_certificate_later]:checked').val() !== 'YES' && $('input[name=original_marriage_certificate]:checked').val() === 'NO') {
$('#is_certificate_in_english').hide();
}
else {
$('#is_certificate_in_english').show();
}
}
}
};
// hide or show based on target id
var showHideTargetId = function(el, id, related_id) {
if (el.data("reveal_target") === true && el.prop('checked')) {
$(id).show();
if (related_id !== undefined){
$('#' + related_id).hide();
}
if (id === "#has_children"){
reveal($("input[name=any_under_19]:checked"));
reveal($("input[name=number_children_over_19]"));
}
// reveal nested question as well
if (id ==="#marriage_certificate"){
reveal($("input[name=provide_certificate_later]:checked"));
@ -26,24 +70,17 @@ var reveal = function(el) {
$('#' + related_id).show();
}
}
};
// hide or show based on target css class
// Controls show or hiding a target css class
var showHideRevealClass = function(el, target_css_class) {
if (el.data("reveal_class") === false) {
if (css_class !== undefined){
$('.' + css_class).hide();
if (target_css_class !== undefined){
$('.' + target_css_class).hide();
}
} else {
if (css_class !== undefined){
$('.' + css_class).show();
}
}
if (el.prop('name') === "provide_certificate_later" || el.prop('name') === "original_marriage_certificate"){
if ($('input[name=provide_certificate_later]:checked').val() !== 'YES' && $('input[name=original_marriage_certificate]:checked').val() === 'NO') {
$('#is_certificate_in_english').hide();
}
else {
$('#is_certificate_in_english').show();
if (target_css_class !== undefined){
$('.' + target_css_class).show();
}
}
};


+ 1
- 1
edivorce/apps/core/static/js/main.js View File

@ -50,7 +50,7 @@ $(function () {
$(this).parent().find('.radio-with-other').prop('checked', true);
});
$("input[type=radio], input[type=checkbox], input[type=text], .response-textarea, .response-dropdown").on("change", ajaxOnChange);
$("input[type=number], input[type=radio], input[type=checkbox], input[type=text], .response-textarea, .response-dropdown").on("change", ajaxOnChange);
// If relationship is common law and they want spousal support, update spouse_support_act with hidden input field, spouse_support_act_common_law
if ($("#spouse_support_act_common_law").length) {


+ 45
- 2
edivorce/apps/core/templates/prequalification/step_04.html View File

@ -193,13 +193,13 @@
<div class="reveal question-well">
<h3>How many children are under the age of 19?</h3>
{# {% input_field type="text" name="number_children_under_19" data_target_id="number_children_under_19" %}#}
{% input_field type="number" name="number_children_under_19" value="0" min="0" data_target_id="number_children_under_19" %}
</div>
<div class="reveal question-well">
<h3>How many children are 19 years or older?</h3>
{# {% input_field type="text" name="number_children_over_19" data_target_id="number_children_over_19" data_reveal_target="true" data_related_id="financial_support" data_target_class="not-disqualified-age" data_reveal_class="false"%}#}
{% input_field type="number" name="number_children_over_19" value="0" min="0" data_target_id="number_children_over_19" data_related_id="financial_support" data_target_class="not-disqualified-age" data_reveal_class="true" data_reveal_condition=">0" %}
</div>
<div class="reveal question-well" id="financial_support" hidden>
@ -213,6 +213,49 @@
<div class="checkbox"><label>{% input_field type="checkbox" name="children_financial_support" value="Yes, due to illness" data_target_id="need_support" data_reveal_target="true" data_target_class="not-disqualified-other" data_reveal_class="false" %}Yes, due to illness</label></div>
<div class="checkbox"><label>{% input_field type="checkbox" name="children_financial_support" value="Yes, other reason" data_target_id="need_support" data_reveal_target="true" data_target_class="not-disqualified-other" data_reveal_class="false" %}Yes, other reason(s)</label></div>
</div>
<div class="collapse-trigger collapsed" data-toggle="collapse"
aria-expanded="false" data-target="#collapse_circumstances_change_child_support"
aria-controls="collapse_circumstances_change_child_support">
<div>
What if circumstances change and child support is either required, or not required, for any
children over 19 years of age?
</div>
</div>
<div class="collapse" id="collapse_circumstances_change_child_support">
<div>
<p>
If you have a child support agreement, you can change it at any time if both of you agree.
</p>
<p>
If the other party doesn’t agree with a change you want to make, you can apply to court
to set aside all or part of the agreement. The court would then replace it with a court
order. The court may set aside your agreement if it’s different from what the court would
have ordered under the law.
</p>
<p>
If you have a court order, either party can apply to lower or raise child support payments
if there’s a change in circumstances, such as:
</p>
<ul>
<li>a long-term income change for the payor,</li>
<li>a change to the child’s special or extraordinary expenses, or</li>
<li>a change in parenting arrangements or contact.</li>
</ul>
<p>
The court can also change the order if:
</p>
<ul>
<li>circumstances have changed so much that a court would make a different order now,</li>
<li>one party didn’t provide all the required financial information when the order was made, or</li>
<li>there’s important new information that wasn’t available when the first order was made.</li>
</ul>
<p>
If you have taken over responsibility for the daily care of a child from the other parent
or guardian, you can apply to change the child support order or agreement so the other parent
or guardian pays you child support.
</p>
</div>
</div>
<div class="information-message bg-danger hard-stop" id="need_support" hidden>
<p>Sorry, but at this point in time you will not be able to
complete your application for divorce using this online tool.


+ 2
- 0
edivorce/apps/core/templatetags/input_field.py View File

@ -23,6 +23,8 @@ def input_field(context, type, name='', value='', multiple='', **kwargs):
# set initial value for textbox
if type == "text" and value == '' and multiple != 'true':
value = context.get(name, '')
elif type == "number":
value = context.get(name, '')
tag = ['<input type="%s" name="%s" value="%s"' % (type, name, value)]
tag = additional_attributes(tag, **kwargs)


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

@ -5,7 +5,9 @@
question_step_mapping = {
'prequalification': ['married_marriage_like', 'lived_in_bc',
'lived_in_bc_at_least_year', 'separation_date',
'children_of_marriage', 'any_under_19',
'children_of_marriage',
'number_children_under_19',
'number_children_over_19',
'children_financial_support',
'original_marriage_certificate',
'provide_certificate_later',


+ 30
- 2
edivorce/apps/core/utils/step_completeness.py View File

@ -51,8 +51,12 @@ def is_complete(step, lst):
def __condition_met(reveal_response, target, lst):
# return false if the condition was not met
if target["value"] != reveal_response:
# check whether using a numeric condition
numeric_condition_met = __evaluate_numeric_condition(target, reveal_response)
if numeric_condition_met is None:
if target["value"] != reveal_response:
return False
elif numeric_condition_met is False:
return False
# return true if the target is not Conditional
@ -79,3 +83,27 @@ def __has_value(key, lst):
if answer != "" and answer != "[]" and answer != '[["",""]]':
return True
return False
def __evaluate_numeric_condition(target, reveal_response):
"""
Tests whether the reveal_response contains a numeric condition. If so, it will
evaluate the numeric condition and return the results of that comparison.
:param target: the questions value being tested against
:param reveal_response: the numeric condition that will be evaluated against
:return: boolean result of numeric condition evaluation or None if there is no
numeric condition to evaluate.
"""
if reveal_response.startswith('>='):
return int(target["value"]) >= int(reveal_response[2:])
elif reveal_response.startswith('<='):
return int(target["value"]) <= int(reveal_response[2:])
elif reveal_response.startswith('=='):
return int(target["value"]) == int(reveal_response[2:])
elif reveal_response.startswith('<'):
return int(target["value"]) < int(reveal_response[1:])
elif reveal_response.startswith('>'):
return int(target["value"]) > int(reveal_response[1:])
else:
return None

+ 26
- 14
edivorce/fixtures/Question.json View File

@ -71,26 +71,14 @@
"model": "core.question",
"pk": "children_of_marriage"
},
{
"fields": {
"name": "Are any of the children under 19 years old?",
"description": "For pre-qualification step 4",
"summary_order": 8,
"required": "Conditional",
"conditional_target": "children_of_marriage",
"reveal_response": "YES"
},
"model": "core.question",
"pk": "any_under_19"
},
{
"fields": {
"name": "Are you financially supporting any of the children that are 19 years or older?",
"description": "For pre-qualification step 4, Form 1 3. Info concerning children",
"summary_order": 9,
"required": "Conditional",
"conditional_target": "any_under_19",
"reveal_response": "NO"
"conditional_target": "number_children_over_19",
"reveal_response": ">0"
},
"model": "core.question",
"pk": "children_financial_support"
@ -784,5 +772,29 @@
},
"model": "core.question",
"pk": "name_change_spouse_fullname"
},
{
"fields": {
"name": "How many children are under the age of 19?",
"description": "For pre-qualification step 4, Form 1 3. Info concerning children",
"summary_order": 0,
"required": "Conditional",
"conditional_target": "children_of_marriage",
"reveal_response": "YES"
},
"pk": "number_children_under_19",
"model": "core.question"
},
{
"fields": {
"name": "How many children are 19 years or older?",
"description": "For pre-qualification step 4, Form 1 3. Info concerning children",
"summary_order": 0,
"required": "Conditional",
"conditional_target": "children_of_marriage",
"reveal_response": "YES"
},
"pk": "number_children_over_19",
"model": "core.question"
}
]

Loading…
Cancel
Save