diff --git a/edivorce/apps/core/templates/overview.html b/edivorce/apps/core/templates/overview.html index afcad776..6af101c9 100644 --- a/edivorce/apps/core/templates/overview.html +++ b/edivorce/apps/core/templates/overview.html @@ -1,4 +1,6 @@ {% extends 'base.html' %} +{% load step_order %} +{% load load_json %} {% block title %}{{ block.super }}: Overview{% endblock %} @@ -8,69 +10,79 @@

Answer the Questions Related to Your Divorce Questionnaire

- + Qualifying Questions - + Step 1
What Are You Asking For?
{% if step_status.which_orders == 'Started' %} {% endif %}
- + Step 2
Your information
{% if step_status.your_information == 'Started' %} {% endif %}
- + Step 3
Your spouse
{% if step_status.your_spouse == 'Started' %} {% endif %}
- + Step 4
Your marriage
{% if step_status.your_marriage == 'Started' %} {% endif %}
- + Step 5
Your separation
{% if step_status.your_separation == 'Started' %} {% endif %}
- + + {% if 'Spousal support' in want_which_orders|load_json %} + Step 6
Spousal support
{% if step_status.spousal_support == 'Started' %} {% endif %}
- + {% 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
{% if step_status.property_and_debt == 'Started' %} {% endif %}
- + {% endif %} + + {% if 'Other orders' in want_which_orders|load_json %} + - Step 8
Other orders
+ Step {% step_order step="other_orders" %}
Other orders
{% if step_status.other_orders == 'Started' %} {% endif %}
- + {% endif %} + + - Step 9
Other questions
+ Step {% step_order step="other_questions" %}
Other questions
{% if step_status.other_questions == 'Started' %} {% endif %}
- + - Step 10
Filing locations
+ Step {% step_order step="location" %}
Filing locations
{% if step_status.filing_locations == 'Started' %} {% endif %}
- + - Step 11
Review
+ Step {% step_order step="review" %}
Review
{% endblock %} diff --git a/edivorce/apps/core/templates/progress.html b/edivorce/apps/core/templates/progress.html index 6f0c4ffe..2846073c 100644 --- a/edivorce/apps/core/templates/progress.html +++ b/edivorce/apps/core/templates/progress.html @@ -1,3 +1,6 @@ +{% load step_order %} +{% load load_json %} +

Questionnaire

@@ -5,59 +8,69 @@ Qualifying Questions - + Step 1
What Are You Asking For?
{% if step_status.which_orders == 'Started' %} {% endif %}
- + Step 2
Your information
{% if step_status.your_information == 'Started' %} {% endif %}
- + Step 3
Your spouse
{% if step_status.your_spouse == 'Started' %} {% endif %}
- + Step 4
Your marriage
{% if step_status.your_marriage == 'Started' %} {% endif %}
- + Step 5
Your separation
{% if step_status.your_separation == 'Started' %} {% endif %}
- + + {% if 'Spousal support' in want_which_orders|load_json %} + Step 6
Spousal support
{% if step_status.spousal_support == 'Started' %} {% endif %}
- + {% 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
{% if step_status.property_and_debt == 'Started' %} {% endif %}
- + {% endif %} + + {% if 'Other orders' in want_which_orders|load_json %} + - Step 8
Other orders
+ Step {% step_order step="other_orders" %}
Other orders
{% if step_status.other_orders == 'Started' %} {% endif %}
- + {% endif %} + + - Step 9
Other questions
+ Step {% step_order step="other_questions" %}
Other questions
{% if step_status.other_questions == 'Started' %} {% endif %}
- + - Step 10
Filing locations
+ Step {% step_order step="location" %}
Filing locations
{% if step_status.filing_locations == 'Started' %} {% endif %}
- + - Step 11
Review
+ Step {% step_order step="review" %}
Review
diff --git a/edivorce/apps/core/templates/question/01_orders.html b/edivorce/apps/core/templates/question/01_orders.html index 4fb92fc2..f5c5be63 100644 --- a/edivorce/apps/core/templates/question/01_orders.html +++ b/edivorce/apps/core/templates/question/01_orders.html @@ -1,5 +1,7 @@ {% extends 'base.html' %} {% load input_field %} +{% load next_step %} +{% load prev_step %} {% block title %}{{ block.super }}: Prequalification{% endblock %} @@ -135,7 +137,7 @@ {% endblock %} {% block formBack %}{% url 'overview' %}{% endblock %} -{% block formNext %}{% url 'question_steps' '02_claimant' %}{% endblock %} +{% block formNext %}{% next_step step='orders' %}{% endblock %} {% block sidebarText %}

An order is the record of the judge's decision. It is filed at the court registry.

diff --git a/edivorce/apps/core/templates/question/02_claimant.html b/edivorce/apps/core/templates/question/02_claimant.html index f73aefaa..d74b4620 100644 --- a/edivorce/apps/core/templates/question/02_claimant.html +++ b/edivorce/apps/core/templates/question/02_claimant.html @@ -1,5 +1,8 @@ {% extends 'base.html' %} {% load input_field %} +{% load next_step %} +{% load prev_step %} + {% block title %}{{ block.super }}: Your Information{% endblock %} @@ -170,8 +173,8 @@ {% endblock %} -{% block formBack %}{% url 'question_steps' '01_orders' %}{% endblock %} -{% block formNext %}{% url 'question_steps' '03_respondent' %}{% endblock %} +{% block formBack %}{% prev_step step='claimant' %}{% endblock %} +{% block formNext %}{% next_step step='claimant' %}{% endblock %} {% block sidebarText %}

The Meaning of "Ordinary Residence" and "Habitual Residence" in the Common Law Provinces in a Family Law Context: http://www.justice.gc.ca/eng/rp-pr/fl-lf/divorce/rhro_cl/p4.html

diff --git a/edivorce/apps/core/templates/question/03_respondent.html b/edivorce/apps/core/templates/question/03_respondent.html index dee402f4..f0d0cefe 100644 --- a/edivorce/apps/core/templates/question/03_respondent.html +++ b/edivorce/apps/core/templates/question/03_respondent.html @@ -1,4 +1,8 @@ -{% extends 'base.html' %}{% load input_field %} +{% extends 'base.html' %} +{% load input_field %} +{% load next_step %} +{% load prev_step %} + {% block title %}{{ block.super }}: Your Spouse{% endblock %} @@ -166,8 +170,8 @@
{% endblock %} -{% block formBack %}{% url 'question_steps' '02_claimant' %}{% endblock %} -{% block formNext %}{% url 'question_steps' '04_marriage' %}{% endblock %} +{% block formBack %}{% prev_step step='respondent' %}{% endblock %} +{% block formNext %}{% next_step step='respondent' %}{% endblock %} {% block sidebarNav %} diff --git a/edivorce/apps/core/templates/question/04_marriage.html b/edivorce/apps/core/templates/question/04_marriage.html index 7fddac1d..a0afd922 100644 --- a/edivorce/apps/core/templates/question/04_marriage.html +++ b/edivorce/apps/core/templates/question/04_marriage.html @@ -1,5 +1,8 @@ {% extends 'base.html' %} {% load input_field %} +{% load next_step %} +{% load prev_step %} + {% block title %}{{ block.super }}: Your Marriage{% endblock %} @@ -113,8 +116,8 @@ {% endblock %} -{% block formBack %}{% url 'question_steps' '03_respondent' %}{% endblock %} -{% block formNext %}{% url 'question_steps' '05_separation' %}{% endblock %} +{% block formBack %}{% prev_step step='marriage' %}{% endblock %} +{% block formNext %}{% next_step step='marriage' %}{% endblock %} {% block sidebarText %}
diff --git a/edivorce/apps/core/templates/question/05_separation.html b/edivorce/apps/core/templates/question/05_separation.html index 8ae3bab4..3c944c1c 100644 --- a/edivorce/apps/core/templates/question/05_separation.html +++ b/edivorce/apps/core/templates/question/05_separation.html @@ -1,5 +1,8 @@ {% extends 'base.html' %} {% load input_field %} +{% load next_step %} +{% load prev_step %} + {% block title %}{{ block.super }}: Reason For Divorce{% endblock %} @@ -67,8 +70,8 @@ {% endblock %} -{% block formBack %}{% url 'question_steps' '04_marriage' %}{% endblock %} -{% block formNext %}{% url 'question_steps' '06_support' %}{% endblock %} +{% block formBack %}{% prev_step step='separation' %}{% endblock %} +{% block formNext %}{% next_step step='separation' %}{% endblock %} {% block sidebarText %}
diff --git a/edivorce/apps/core/templates/question/06_support.html b/edivorce/apps/core/templates/question/06_support.html index b2802107..d2972ca4 100644 --- a/edivorce/apps/core/templates/question/06_support.html +++ b/edivorce/apps/core/templates/question/06_support.html @@ -1,5 +1,8 @@ {% extends 'base.html' %} {% load input_field %} +{% load next_step %} +{% load prev_step %} + {% block title %}{{ block.super }}: Declarations{% endblock %} @@ -125,8 +128,8 @@
{% endblock %} -{% block formBack %}{% url 'question_steps' '05_separation' %}{% endblock %} -{% block formNext %}{% url 'question_steps' '07_property' %}{% endblock %} +{% block formBack %}{% prev_step step='support' %}{% endblock %} +{% block formNext %}{% next_step step='support' %}{% endblock %} {% block sidebarText %}
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 %} -

Step 7:Property and Debt

+

Step {% step_order step="property" %}:Property and Debt

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)