diff --git a/edivorce/apps/core/templates/question/07_property.html b/edivorce/apps/core/templates/question/07_property.html
index 2b3a24ea..ca69425a 100644
--- a/edivorce/apps/core/templates/question/07_property.html
+++ b/edivorce/apps/core/templates/question/07_property.html
@@ -1,12 +1,16 @@
{% extends 'base.html' %}
{% load input_field %}
+{% load step_order %}
+{% load next_step %}
+{% load prev_step %}
+
{% block title %}{{ block.super }}: Application Location{% endblock %}
{% block progress %}{% include "progress.html" %}{% endblock %}
{% block content %}
-
After you separate, the law says that all family property
@@ -115,8 +119,8 @@
{% endblock %}
-{% block formBack %}{% url 'question_steps' '06_support' %}{% endblock %}
-{% block formNext %}{% url 'question_steps' '08_other_orders' %}{% endblock %}
+{% block formBack %}{% prev_step step='property' %}{% endblock %}
+{% block formNext %}{% next_step step='property' %}{% endblock %}
{% block sidebarText %}
diff --git a/edivorce/apps/core/templates/question/08_other_orders.html b/edivorce/apps/core/templates/question/08_other_orders.html
index e654768c..99893f0c 100644
--- a/edivorce/apps/core/templates/question/08_other_orders.html
+++ b/edivorce/apps/core/templates/question/08_other_orders.html
@@ -1,4 +1,8 @@
-{% extends 'base.html' %}{% load input_field %}
+{% extends 'base.html' %}
+{% load input_field %}
+{% load step_order %}
+{% load next_step %}
+{% load prev_step %}
{% block title %}{{ block.super }}: Other Orders{% endblock %}
@@ -7,14 +11,14 @@
{% block content %}
-
Step 8:Other Orders
+
Step {% step_order step="other_orders" %}:Other Orders
Want other orders as follows:
{% input_field type="textarea" name="other_orders_detail" rows="8" cols="65" class="response-textarea" %}
{% endblock %}
-{% block formBack %}{% url 'question_steps' '07_property' %}{% endblock %}
-{% block formNext %}{% url 'question_steps' '09_other_questions' %}{% endblock %}
+{% block formBack %}{% prev_step step='other_orders' %}{% endblock %}
+{% block formNext %}{% next_step step='other_orders' %}{% endblock %}
{% block sidebarNav %}
diff --git a/edivorce/apps/core/templates/question/09_other_questions.html b/edivorce/apps/core/templates/question/09_other_questions.html
index ded1dcf8..20a43916 100644
--- a/edivorce/apps/core/templates/question/09_other_questions.html
+++ b/edivorce/apps/core/templates/question/09_other_questions.html
@@ -1,5 +1,8 @@
{% extends 'base.html' %}
{% load input_field %}
+{% load step_order %}
+{% load next_step %}
+{% load prev_step %}
{% block title %}{{ block.super }}: Spousal Support{% endblock %}
@@ -8,7 +11,7 @@
{% block content %}
-
Step 9:Other Questions
+
Step {% step_order step="other_questions" %}:Other Questions
@@ -96,8 +99,8 @@
{% endblock %}
-{% block formBack %}{% url 'question_steps' '08_other_orders' %}{% endblock %}
-{% block formNext %}{% url 'question_steps' '10_location' %}{% endblock %}
+{% block formBack %}{% prev_step step='other_questions' %}{% endblock %}
+{% block formNext %}{% next_step step='other_questions' %}{% endblock %}
{% block sidebarNav %}
diff --git a/edivorce/apps/core/templates/question/10_location.html b/edivorce/apps/core/templates/question/10_location.html
index 0419032d..2d266ab8 100644
--- a/edivorce/apps/core/templates/question/10_location.html
+++ b/edivorce/apps/core/templates/question/10_location.html
@@ -1,5 +1,8 @@
{% extends 'base.html' %}
{% load input_field %}
+{% load step_order %}
+{% load next_step %}
+{% load prev_step %}
{% block title %}{{ block.super }}: Property And Debts{% endblock %}
@@ -8,7 +11,7 @@
{% block content %}
-
Step 10:Filing Location
+
Step {% step_order step="location" %}:Filing Location
Ok, we're almost done asking you questions. The last set of information that we need to know is where
you will be filing your divorce document. You will need to file your documents in person at a court registry.
@@ -34,8 +37,8 @@
{% endblock %}
-{% block formBack %}{% url 'question_steps' '09_other_questions' %}{% endblock %}
-{% block formNext %}{% url 'question_steps' '11_review' %}{% endblock %}
+{% block formBack %}{% prev_step step='location' %}{% endblock %}
+{% block formNext %}{% next_step step='location' %}{% endblock %}
{% block sidebarText %}
diff --git a/edivorce/apps/core/templates/question/11_review.html b/edivorce/apps/core/templates/question/11_review.html
index 376e4125..a0e2ea15 100644
--- a/edivorce/apps/core/templates/question/11_review.html
+++ b/edivorce/apps/core/templates/question/11_review.html
@@ -1,4 +1,7 @@
-{% extends 'base.html' %}{% load input_field %}
+{% extends 'base.html' %}
+{% load input_field %}
+{% load step_order %}
+{% load load_json %}
{% block title %}{{ block.super }}: Review{% endblock %}
@@ -6,7 +9,7 @@
{% block content %}
-
Step 11:Review
+
Step {% step_order step="review" %}:Review
-
Pre-qualification questions
@@ -32,24 +35,34 @@
Step 5: Your separation
{% include "partials/review_user_responses.html" with questions=your_separation %}
+
+ {% if 'Spousal support' in want_which_orders|load_json %}
-
Step 6: Spousal support
{% include "partials/review_user_responses.html" with questions=spousal_support %}
+ {% endif %}
+
+ {% if 'Division of property and debts' in want_which_orders|load_json %}
-
-
Step 7: Property and debt
+ Step {% step_order step="property" %}: Property and debt
{% include "partials/review_user_responses.html" with questions=property_and_debt %}
+ {% endif %}
+
+ {% if 'Other orders' in want_which_orders|load_json %}
-
-
Step 8: Other orders
+ Step {% step_order step="other_orders" %}: Other orders
{% include "partials/review_user_responses.html" with questions=other_orders %}
+ {% endif %}
+
-
-
Step 9: Other questions
+ Step {% step_order step="other_questions" %}: Other questions
{% include "partials/review_user_responses.html" with questions=other_questions %}
-
-
Step 10: Filing locations
+ Step {% step_order step="location" %}: Filing locations
{% include "partials/review_user_responses.html" with questions=filing_locations %}
diff --git a/edivorce/apps/core/templatetags/load_json.py b/edivorce/apps/core/templatetags/load_json.py
new file mode 100644
index 00000000..42380fb3
--- /dev/null
+++ b/edivorce/apps/core/templatetags/load_json.py
@@ -0,0 +1,9 @@
+import json
+
+from django import template
+
+register = template.Library()
+
+@register.filter
+def load_json(data):
+ return json.loads(data)
\ No newline at end of file
diff --git a/edivorce/apps/core/templatetags/next_step.py b/edivorce/apps/core/templatetags/next_step.py
new file mode 100644
index 00000000..9d15390c
--- /dev/null
+++ b/edivorce/apps/core/templatetags/next_step.py
@@ -0,0 +1,27 @@
+from django import template
+import json
+from ..utils.template_step_order import template_step_order, get_step_name
+
+register = template.Library()
+
+
+@register.simple_tag(takes_context=True)
+def next_step(context, step):
+ want_which_orders = json.loads(context.get('want_which_orders', '[]'))
+ current_step_base_order = template_step_order[step]
+
+ next = current_step_base_order + 1
+
+ if current_step_base_order == 5 and 'Spousal support' not in want_which_orders:
+ next += 1
+
+ if next == 6 and 'Division of property and debts' not in want_which_orders:
+ next += 1
+
+ if next == 7 and 'Other orders' not in want_which_orders:
+ next += 1
+
+ return get_step_name(next)
+
+
+
diff --git a/edivorce/apps/core/templatetags/prev_step.py b/edivorce/apps/core/templatetags/prev_step.py
new file mode 100644
index 00000000..b7bb1f27
--- /dev/null
+++ b/edivorce/apps/core/templatetags/prev_step.py
@@ -0,0 +1,42 @@
+from django import template
+import json
+from ..utils.template_step_order import template_step_order, get_step_name
+
+register = template.Library()
+
+
+@register.simple_tag(takes_context=True)
+def step_order(context, step):
+ want_which_orders = json.loads(context.get('want_which_orders', '[]'))
+ base_order = template_step_order[step]
+ order = base_order
+
+ if base_order > 6 and 'Spousal support' not in want_which_orders:
+ order -= 1
+
+ if base_order > 7 and 'Division of property and debts' not in want_which_orders:
+ order -= 1
+
+ if base_order > 8 and 'Other orders' not in want_which_orders:
+ order -= 1
+
+ return order
+
+
+@register.simple_tag(takes_context=True)
+def prev_step(context, step):
+ want_which_orders = json.loads(context.get('want_which_orders', '[]'))
+ current_step_base_order = template_step_order[step]
+
+ prev = current_step_base_order - 1
+
+ if current_step_base_order > 6 and 'Spousal support' not in want_which_orders:
+ prev -= 1
+
+ if current_step_base_order > 7 and 'Division of property and debts' not in want_which_orders:
+ prev -= 1
+
+ if current_step_base_order > 8 and 'Other orders' not in want_which_orders:
+ prev -= 1
+
+ return get_step_name(prev)
diff --git a/edivorce/apps/core/templatetags/step_order.py b/edivorce/apps/core/templatetags/step_order.py
new file mode 100644
index 00000000..1b26b3aa
--- /dev/null
+++ b/edivorce/apps/core/templatetags/step_order.py
@@ -0,0 +1,25 @@
+from django import template
+import json
+from ..utils.template_step_order import template_step_order
+
+register = template.Library()
+
+
+@register.simple_tag(takes_context=True)
+def step_order(context, step):
+ want_which_orders = json.loads(context.get('want_which_orders', '[]'))
+ base_order = template_step_order[step]
+ order = base_order
+
+ if base_order > 6 and 'Spousal support' not in want_which_orders:
+ order -= 1
+
+ if base_order > 7 and 'Division of property and debts' not in want_which_orders:
+ order -= 1
+
+ if base_order > 8 and 'Other orders' not in want_which_orders:
+ order -= 1
+
+ return order
+
+
diff --git a/edivorce/apps/core/urls.py b/edivorce/apps/core/urls.py
index e0bc6d6f..9640c218 100644
--- a/edivorce/apps/core/urls.py
+++ b/edivorce/apps/core/urls.py
@@ -24,7 +24,7 @@ urlpatterns = [
url(r'^pdf-form(?P
[0-9]{1,3})$', pdf.form, name="pdf_form"),
url(r'^prequalification/step_(?P[0-9]{2})$', main.prequalification, name="prequalification"),
- url(r'^question/(?P.*)', main.question, name="question_steps"),
+ url(r'^question/(?P.*)$', main.question, name="question_steps"),
url(r'^', main.intro, name="intro"),
]
diff --git a/edivorce/apps/core/utils/template_step_order.py b/edivorce/apps/core/utils/template_step_order.py
new file mode 100644
index 00000000..90e945b2
--- /dev/null
+++ b/edivorce/apps/core/utils/template_step_order.py
@@ -0,0 +1,25 @@
+"""
+ Mapping between question step names and the numerical values assigned
+ to their templates
+"""
+template_step_order = {
+ 'orders': 1,
+ 'claimant': 2,
+ 'respondent': 3,
+ 'marriage': 4,
+ 'separation': 5,
+ 'support': 6,
+ 'property': 7,
+ 'other_orders': 8,
+ 'other_questions': 9,
+ 'location': 10,
+ 'review': 11
+}
+
+def get_step_name(step_order):
+ """
+ Preforms a reverse lookup in the template_step_order dictionary
+ """
+ return next(k for k, v in template_step_order.items() if v == step_order)
+
+
diff --git a/edivorce/apps/core/views/main.py b/edivorce/apps/core/views/main.py
index 189790e3..b31440b1 100644
--- a/edivorce/apps/core/views/main.py
+++ b/edivorce/apps/core/views/main.py
@@ -1,6 +1,7 @@
from django.conf import settings
from django.shortcuts import render, redirect
from django.utils import timezone
+from edivorce.apps.core.utils.template_step_order import template_step_order
from ..decorators import bceid_required
import datetime
from ..models import BceidUser
@@ -109,7 +110,8 @@ def question(request, step):
View rendering main questions
For review page, use response grouped by step to render page
"""
- template = 'question/%s.html' % step
+ template = 'question/%02d_%s.html' % (template_step_order[step], step)
+
user = __get_bceid_user(request)
responses_dict_by_step = get_responses_from_db_grouped_by_steps(user)