Browse Source

Make no_children decorator more clear

pull/172/head
ariannedee 5 years ago
parent
commit
e2e5cb03b2
1 changed files with 14 additions and 14 deletions
  1. +14
    -14
      edivorce/apps/core/utils/conditional_logic.py

+ 14
- 14
edivorce/apps/core/utils/conditional_logic.py View File

@ -3,7 +3,7 @@ import json
import re
def no_children(return_val):
def if_no_children(return_val):
def decorator_no_children(func):
@functools.wraps(func)
def inner(questions_dict, *args, **kwargs):
@ -18,7 +18,7 @@ def determine_has_children_of_marriage(questions_dict):
return questions_dict.get('children_of_marriage', '') == 'YES'
@no_children([])
@if_no_children(return_val=[])
def get_children(questions_dict):
children_json = questions_dict.get('claimant_children', '[]')
if isinstance(children_json, dict):
@ -26,14 +26,14 @@ def get_children(questions_dict):
return json.loads(children_json)
@no_children('0')
@if_no_children(return_val='0')
def get_num_children_living_with(questions_dict, living_arrangement):
assert living_arrangement in ['Lives with you', 'Lives with spouse', 'Lives with both']
children = get_children(questions_dict)
return str(len([child for child in children if child['child_live_with'] == living_arrangement]))
@no_children(False)
@if_no_children(return_val=False)
def determine_sole_custody(questions_dict):
""" Return True if all children live with one parent """
child_list = get_children(questions_dict)
@ -41,7 +41,7 @@ def determine_sole_custody(questions_dict):
all([child['child_live_with'] == 'Lives with spouse' for child in child_list]))
@no_children(False)
@if_no_children(return_val=False)
def determine_shared_custody(questions_dict):
""" Return True if any children live with both parents """
child_list = get_children(questions_dict)
@ -49,7 +49,7 @@ def determine_shared_custody(questions_dict):
for child in child_list])
@no_children(False)
@if_no_children(return_val=False)
def determine_split_custody(questions_dict):
""" Return True if at least one child lives with one parent and at least one lives with the other (or both) """
child_list = get_children(questions_dict)
@ -67,7 +67,7 @@ def determine_split_custody(questions_dict):
with_spouse > 0 and (with_you + with_both > 0))
@no_children(False)
@if_no_children(return_val=False)
def determine_child_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', '[]'))
@ -75,7 +75,7 @@ def determine_child_over_19_supported(questions_dict):
return has_children_over_19 and supporting_children
@no_children(False)
@if_no_children(return_val=False)
def determine_missing_undue_hardship_reasons(questions_dict):
claiming_undue_hardship = questions_dict.get('claiming_undue_hardship', '') == 'YES'
if claiming_undue_hardship:
@ -98,7 +98,7 @@ def determine_missing_undue_hardship_reasons(questions_dict):
return False
@no_children('')
@if_no_children(return_val='')
def determine_child_support_payor(questions_dict):
payor = questions_dict.get('child_support_payor', '')
if payor == 'Myself (Claimant 1)':
@ -110,7 +110,7 @@ def determine_child_support_payor(questions_dict):
return ''
@no_children(False)
@if_no_children(return_val=False)
def determine_show_fact_sheet_f_you(questions_dict):
"""
If claimant 1 (you) is a payor and makes over $150,000/year, show fact sheet F for claimant 1
@ -123,7 +123,7 @@ def determine_show_fact_sheet_f_you(questions_dict):
return (payor == 'Claimant 1' or payor == 'both Claimant 1 and Claimant 2') and annual > 150000
@no_children(False)
@if_no_children(return_val=False)
def determine_show_fact_sheet_f_spouse(questions_dict):
"""
If claimant 2 (spouse) is a payor and makes over $150,000/year, show fact sheet F for claimant 2
@ -138,13 +138,13 @@ def determine_show_fact_sheet_f_spouse(questions_dict):
return (payor == 'Claimant 2' or payor == 'both Claimant 1 and Claimant 2') and annual > 150000
@no_children(False)
@if_no_children(return_val=False)
def determine_child_support_act_requirement(questions_dict):
orders_wanted = json.loads(questions_dict.get('want_which_orders', '[]'))
return 'Child support' in orders_wanted
@no_children(False)
@if_no_children(return_val=False)
def determine_missing_extraordinary_expenses(questions_dict):
special_expenses_keys = ["child_care_expenses",
"children_healthcare_premiums",
@ -167,7 +167,7 @@ def determine_missing_extraordinary_expenses(questions_dict):
return False
@no_children(False)
@if_no_children(return_val=False)
def determine_show_children_live_with_others(questions_dict):
has_children_under_19 = questions_dict.get('has_children_under_19', '') == 'YES'
child_over_19_supported = determine_child_over_19_supported(questions_dict)


Loading…
Cancel
Save