diff --git a/edivorce/apps/core/templatetags/step_order.py b/edivorce/apps/core/templatetags/step_order.py
index 6eda0ce9..1310a40d 100644
--- a/edivorce/apps/core/templatetags/step_order.py
+++ b/edivorce/apps/core/templatetags/step_order.py
@@ -72,23 +72,20 @@ def _adjust_for_orders(next_item, want_which_orders, children_of_marriage=None,
@register.simple_tag(takes_context=True)
def step_order(context, step):
- want_which_orders = __parse_json_which_orders_selected(context)
base_order = template_step_order[step]
order = base_order
+ derived_data = context.get('derived', dict())
- if base_order > 5 and (
- context.get('children_of_marriage', None) != 'YES' and
- context.get('derived', dict()).get('has_children_of_marriage', None) is False
- ):
+ if base_order > 5 and not derived_data.get('has_children_of_marriage'):
order -= 1
- if base_order > 6 and 'Spousal support' not in want_which_orders:
+ if base_order > 6 and not derived_data.get('wants_spousal_support'):
order -= 1
- if base_order > 7 and 'Division of property and debts' not in want_which_orders:
+ if base_order > 7 and not derived_data.get('wants_property_division'):
order -= 1
- if base_order > 8 and 'Other orders' not in want_which_orders:
+ if base_order > 8 and not derived_data.get('wants_other_orders'):
order -= 1
return order
diff --git a/edivorce/apps/core/tests/test_logic.py b/edivorce/apps/core/tests/test_logic.py
index f1319fad..1d7a3365 100644
--- a/edivorce/apps/core/tests/test_logic.py
+++ b/edivorce/apps/core/tests/test_logic.py
@@ -57,6 +57,7 @@ class ConditionalLogicTestCase(TestCase):
# Has children, and marked YES to children of marriage in prequal
self.create_response('children_of_marriage', 'YES')
+ self.create_response('has_children_under_19', 'YES')
self.assertEqual(logic.get_num_children_living_with(self.questions_dict, 'Lives with you'), '1')
self.assertEqual(logic.get_num_children_living_with(self.questions_dict, 'Lives with spouse'), '2')
self.assertEqual(logic.get_num_children_living_with(self.questions_dict, 'Lives with both'), '3')
@@ -70,12 +71,34 @@ class ConditionalLogicTestCase(TestCase):
self.assertFalse(logic.determine_shared_custody(self.questions_dict))
self.create_response('children_of_marriage', 'YES')
+ self.create_response('has_children_under_19', 'YES')
self.assertTrue(logic.determine_shared_custody(self.questions_dict))
children = [self.child_live_with_spouse, self.child_live_with_you]
self.create_response('claimant_children', json.dumps(children))
self.assertFalse(logic.determine_shared_custody(self.questions_dict))
+ def test_has_children_of_marriage(self):
+ self.assertFalse(logic.determine_has_children_of_marriage(self.questions_dict))
+
+ self.create_response('children_of_marriage', 'NO')
+ self.assertFalse(logic.determine_has_children_of_marriage(self.questions_dict))
+
+ self.create_response('children_of_marriage', 'YES')
+ self.create_response('has_children_under_19', 'YES')
+ self.assertTrue(logic.determine_has_children_of_marriage(self.questions_dict))
+
+ self.create_response('has_children_under_19', 'NO')
+ self.create_response('has_children_over_19', 'NO')
+ self.assertFalse(logic.determine_has_children_of_marriage(self.questions_dict))
+
+ self.create_response('has_children_over_19', 'YES')
+ self.create_response('children_financial_support', '["NO"]')
+ self.assertFalse(logic.determine_has_children_of_marriage(self.questions_dict))
+
+ self.create_response('children_financial_support', '["Yes, attending post secondary institution"]')
+ self.assertTrue(logic.determine_has_children_of_marriage(self.questions_dict))
+
class ViewLogic(TestCase):
def test_content_type_from_filename(self):
diff --git a/edivorce/apps/core/tests/test_step_completeness.py b/edivorce/apps/core/tests/test_step_completeness.py
index 2046269d..b1e46d5f 100644
--- a/edivorce/apps/core/tests/test_step_completeness.py
+++ b/edivorce/apps/core/tests/test_step_completeness.py
@@ -466,6 +466,7 @@ class ChildrenStepCompletenessTestCase(TestCase):
self.child_live_with_spouse = {"child_name": "Child with spouse", "child_birth_date": "Jan 4, 2009", "child_live_with": "Lives with spouse", "child_relationship_to_you": "Adopted child", "child_relationship_to_spouse": "Adopted child", "child_live_with_other_details": ""}
self.child_live_with_both = {"child_name": "Child with both", "child_birth_date": "Jan 4, 2009", "child_live_with": "Lives with both", "child_relationship_to_you": "Adopted child", "child_relationship_to_spouse": "Adopted child", "child_live_with_other_details": ""}
self.create_response('children_of_marriage', 'YES')
+ self.create_response('has_children_under_19', 'YES')
def get_children_step_status(self, substep=None):
responses_dict = get_data_for_user(self.user)
@@ -499,12 +500,36 @@ class ChildrenStepCompletenessTestCase(TestCase):
def test_no_children(self):
self.create_response('children_of_marriage', 'NO')
- self.assertEqual(self.get_children_step_status(), 'Hidden')
- self.assertEqual(self.get_children_step_status('your_children'), 'Hidden')
- self.assertEqual(self.get_children_step_status('income_expenses'), 'Hidden')
- self.assertEqual(self.get_children_step_status('facts'), 'Hidden')
- self.assertEqual(self.get_children_step_status('payor_medical'), 'Hidden')
- self.assertEqual(self.get_children_step_status('what_for'), 'Hidden')
+ self.assertEqual(self.get_children_step_status(), Status.HIDDEN)
+ self.assertEqual(self.get_children_step_status('your_children'), Status.HIDDEN)
+ self.assertEqual(self.get_children_step_status('income_expenses'), Status.HIDDEN)
+ self.assertEqual(self.get_children_step_status('facts'), Status.HIDDEN)
+ self.assertEqual(self.get_children_step_status('payor_medical'), Status.HIDDEN)
+ self.assertEqual(self.get_children_step_status('what_for'), Status.HIDDEN)
+
+ def test_only_grown_children(self):
+ self.create_response('children_of_marriage', 'YES')
+ self.create_response('has_children_under_19', 'NO')
+ self.create_response('has_children_over_19', 'YES')
+ self.create_response('children_financial_support', '["NO"]')
+ self.assertEqual(self.get_children_step_status(), Status.HIDDEN)
+ self.assertEqual(self.get_children_step_status('your_children'), Status.HIDDEN)
+ self.assertEqual(self.get_children_step_status('income_expenses'), Status.HIDDEN)
+ self.assertEqual(self.get_children_step_status('facts'), Status.HIDDEN)
+ self.assertEqual(self.get_children_step_status('payor_medical'), Status.HIDDEN)
+ self.assertEqual(self.get_children_step_status('what_for'), Status.HIDDEN)
+
+ def test_has_children(self):
+ self.create_response('children_of_marriage', 'YES')
+ self.create_response('has_children_under_19', 'NO')
+ self.create_response('has_children_over_19', 'YES')
+ self.create_response('children_financial_support', '["Yes, other reason"]')
+ self.assertEqual(self.get_children_step_status(), Status.NOT_STARTED)
+ self.assertEqual(self.get_children_step_status('your_children'), Status.NOT_STARTED)
+ self.assertEqual(self.get_children_step_status('income_expenses'), Status.NOT_STARTED)
+ self.assertEqual(self.get_children_step_status('facts'), Status.NOT_STARTED)
+ self.assertEqual(self.get_children_step_status('payor_medical'), Status.NOT_STARTED)
+ self.assertEqual(self.get_children_step_status('what_for'), Status.NOT_STARTED)
def test_children_details(self):
substep = 'your_children'
diff --git a/edivorce/apps/core/utils/conditional_logic.py b/edivorce/apps/core/utils/conditional_logic.py
index 0c2fa0ac..8a57b5a3 100644
--- a/edivorce/apps/core/utils/conditional_logic.py
+++ b/edivorce/apps/core/utils/conditional_logic.py
@@ -3,21 +3,23 @@ import json
import re
+def determine_has_children_of_marriage(questions_dict):
+ has_children = questions_dict.get('children_of_marriage', '') == 'YES'
+ has_under_19 = questions_dict.get('has_children_under_19', '') == 'YES'
+ return has_children and (has_under_19 or _children_over_19_supported(questions_dict))
+
+
def if_no_children(return_val):
def decorator_no_children(func):
@functools.wraps(func)
def inner(questions_dict, *args, **kwargs):
- if questions_dict.get('children_of_marriage', '') != 'YES':
+ if not determine_has_children_of_marriage(questions_dict):
return return_val
return func(questions_dict, *args, **kwargs)
return inner
return decorator_no_children
-def determine_has_children_of_marriage(questions_dict):
- return questions_dict.get('children_of_marriage', '') == 'YES'
-
-
@if_no_children(return_val=[])
def get_children(questions_dict):
children_json = questions_dict.get('claimant_children', '[]')
@@ -69,6 +71,10 @@ def determine_split_custody(questions_dict):
@if_no_children(return_val=False)
def determine_child_over_19_supported(questions_dict):
+ return _children_over_19_supported(questions_dict)
+
+
+def _children_over_19_supported(questions_dict):
has_children_over_19 = questions_dict.get('has_children_over_19', '') == 'YES'
support = json.loads(questions_dict.get('children_financial_support', '[]'))
supporting_children = len(support) > 0 and 'NO' not in support
diff --git a/edivorce/apps/core/utils/derived.py b/edivorce/apps/core/utils/derived.py
index d1ebe9d3..f7e3afd0 100644
--- a/edivorce/apps/core/utils/derived.py
+++ b/edivorce/apps/core/utils/derived.py
@@ -117,9 +117,7 @@ def children(responses, derived):
def has_children_of_marriage(responses, derived):
- """ Returns whether or not the their are children of marriage for claim"""
-
- return responses.get('children_of_marriage', '') == 'YES'
+ return conditional_logic.determine_has_children_of_marriage(responses)
def wants_divorce_order(responses, derived):