From 58ead2d340b41f056a4be0c3f3185aaae129b531 Mon Sep 17 00:00:00 2001 From: Benard Ebinu Date: Mon, 5 Feb 2018 15:02:20 -0800 Subject: [PATCH] DIV-758: Hiding children related information/menus if there are no children of the marriage --- edivorce/apps/core/templates/overview.html | 7 ++--- .../core/templates/partials/progress.html | 6 +++-- .../core/templates/question/13_review.html | 7 ++--- edivorce/apps/core/templatetags/step_order.py | 26 +++++++++++++++---- edivorce/apps/core/utils/derived.py | 9 ++++++- edivorce/apps/core/views/main.py | 1 + 6 files changed, 42 insertions(+), 14 deletions(-) diff --git a/edivorce/apps/core/templates/overview.html b/edivorce/apps/core/templates/overview.html index c72ec885..bb4b6efe 100644 --- a/edivorce/apps/core/templates/overview.html +++ b/edivorce/apps/core/templates/overview.html @@ -47,18 +47,19 @@ {% if step_status.your_separation == 'Started' %} Started {% elif step_status.your_separation == 'Complete' %} Completed {% endif %} - + {% if children_of_marriage == 'YES' or derived.has_children_of_marriage %} - Step 6
Your children
+ Step {% step_order step="children" %}
Your children
{% if step_status.your_children == 'Started' %} Started {% elif step_status.your_children == 'Complete' %} Completed {% endif %}
+ {% endif %} {% if 'Spousal support' in which_orders.0.value|load_json %} - Step 7
Spousal support
+ Step {% step_order step="support" %}
Spousal support
{% if step_status.spousal_support == 'Started' %} Started {% elif step_status.spousal_support == 'Complete' %} Completed {% endif %}
diff --git a/edivorce/apps/core/templates/partials/progress.html b/edivorce/apps/core/templates/partials/progress.html index c0639c55..4c7a1039 100644 --- a/edivorce/apps/core/templates/partials/progress.html +++ b/edivorce/apps/core/templates/partials/progress.html @@ -40,10 +40,11 @@ {% elif step_status.your_separation == 'Complete' %} {% endif %} + {% if children_of_marriage == 'YES' or derived.has_children_of_marriage %} @@ -75,11 +76,12 @@ + {% endif %} {% if 'Spousal support' in want_which_orders|load_json or 'Spousal support' in which_orders.0.value|load_json %} - Step 7
Spousal support
+ Step {% step_order step="support" %}
Spousal support
{% if step_status.spousal_support == 'Started' %} {% elif step_status.spousal_support == 'Complete' %} {% endif %}
diff --git a/edivorce/apps/core/templates/question/13_review.html b/edivorce/apps/core/templates/question/13_review.html index 4c962e4a..45b92210 100644 --- a/edivorce/apps/core/templates/question/13_review.html +++ b/edivorce/apps/core/templates/question/13_review.html @@ -107,10 +107,11 @@ +{% if derived.has_children_of_marriage %}
- Step 6: Your children + Step {% step_order step="children" %}: Your children

Edit

@@ -121,13 +122,13 @@
- +{% endif %} {% if 'Spousal support' in which_orders.0.value|load_json %}
- Step 7: Spousal support + Step {% step_order step="support" %}: Spousal support

Edit

diff --git a/edivorce/apps/core/templatetags/step_order.py b/edivorce/apps/core/templatetags/step_order.py index 564d6cc6..e22c7212 100644 --- a/edivorce/apps/core/templatetags/step_order.py +++ b/edivorce/apps/core/templatetags/step_order.py @@ -11,19 +11,24 @@ register = template.Library() def _get_next_step(context, step, sub_step, direction): want_which_orders = json.loads(context.get('want_which_orders', '[]')) - sub_step_name = _get_next_sub_step(step, sub_step, want_which_orders, direction=direction) + children_of_marriage = context.get('children_of_marriage', None) + sub_step_name = _get_next_sub_step(step, sub_step, want_which_orders, + children_of_marriage=children_of_marriage, + direction=direction) if sub_step_name is not None: return sub_step_name current_step_base_order = template_step_order[step] - next_item = _adjust_for_orders(current_step_base_order, want_which_orders, direction=direction) + next_item = _adjust_for_orders(current_step_base_order, want_which_orders, + children_of_marriage=children_of_marriage, + direction=direction) # The next page or previous page could land on a sub step page so need to do lookup to find # out where may fall. return get_step_or_sub_step_name(next_item, direction=direction) -def _get_next_sub_step(step, sub_step, want_which_orders, direction): +def _get_next_sub_step(step, sub_step, want_which_orders, children_of_marriage, direction): current_step_base_order = template_step_order[step] if template_sub_step_order.get(step, None) is not None: current_sub_step_base_order = template_sub_step_order[step].get(sub_step, None) @@ -36,18 +41,23 @@ def _get_next_sub_step(step, sub_step, want_which_orders, direction): if next_sub_step is not None: return reverse('question_steps', kwargs={'step': step, 'sub_step': next_sub_step}) - next_item = _adjust_for_orders(current_step_base_order, want_which_orders, direction=direction) + next_item = _adjust_for_orders(current_step_base_order, want_which_orders, + children_of_marriage=children_of_marriage, + direction=direction) return reverse('question_steps', kwargs={'step': get_step_name(template_step_order, next_item)}) return None -def _adjust_for_orders(next_item, want_which_orders, direction): +def _adjust_for_orders(next_item, want_which_orders, children_of_marriage=None, direction=None): addend = 1 if direction != 'next': addend = -1 next_item += addend + if next_item == 6 and 'YES' != children_of_marriage: + next_item += addend + if next_item == 7 and 'Spousal support' not in want_which_orders: next_item += addend @@ -66,6 +76,12 @@ def step_order(context, step): base_order = template_step_order[step] order = base_order + 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 + ): + order -= 1 + if base_order > 6 and 'Spousal support' not in want_which_orders: order -= 1 diff --git a/edivorce/apps/core/utils/derived.py b/edivorce/apps/core/utils/derived.py index 3d63de6b..4405ad68 100644 --- a/edivorce/apps/core/utils/derived.py +++ b/edivorce/apps/core/utils/derived.py @@ -18,6 +18,7 @@ import json DERIVED_DATA = [ 'orders_wanted', 'children', + 'has_children_of_marriage', 'wants_divorce_order', 'wants_spousal_support', 'wants_property_division', @@ -86,6 +87,12 @@ def children(responses, derived): return json.loads(responses.get('claimant_children', '[]')) +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' + + def wants_divorce_order(responses, derived): """ Return whether or not the user wants an order for divorce """ @@ -167,7 +174,7 @@ def show_fact_sheet_d(responses, derived): support = json.loads(responses.get('children_financial_support', '[]')) return (len(support) > 0 and - 'NO' not in support and responses.get('children_of_marriage', '') == 'YES') + 'NO' not in support and has_children_of_marriage(responses, derived)) def show_fact_sheet_e(responses, derived): diff --git a/edivorce/apps/core/views/main.py b/edivorce/apps/core/views/main.py index 2769cd12..643079e3 100644 --- a/edivorce/apps/core/views/main.py +++ b/edivorce/apps/core/views/main.py @@ -150,6 +150,7 @@ def overview(request): # Add step status dictionary responses_dict_by_step['step_status'] = get_step_status(responses_dict_by_step) responses_dict_by_step['active_page'] = 'overview' + responses_dict_by_step['derived'] = get_derived_data(get_responses_from_db(request.user)) response = render(request, 'overview.html', context=responses_dict_by_step)