From 07ae174c5854e19c28d93f68a170180c8107fd6d Mon Sep 17 00:00:00 2001 From: ariannedee Date: Wed, 21 Oct 2020 20:21:59 -0700 Subject: [PATCH] DIV-1179: Fix a bunch of forms --- edivorce/apps/core/templates/pdf/form1.html | 69 ++++++++++--------- edivorce/apps/core/templates/pdf/form37.html | 4 +- edivorce/apps/core/templates/pdf/form38.html | 2 +- edivorce/apps/core/templates/pdf/form52.html | 4 +- .../question/06_children_what_for.html | 8 +-- .../apps/core/templatetags/format_utils.py | 18 ++++- 6 files changed, 57 insertions(+), 48 deletions(-) diff --git a/edivorce/apps/core/templates/pdf/form1.html b/edivorce/apps/core/templates/pdf/form1.html index 7a0bdbc8..27b117c4 100644 --- a/edivorce/apps/core/templates/pdf/form1.html +++ b/edivorce/apps/core/templates/pdf/form1.html @@ -364,7 +364,7 @@ Children:

- {% checkbox children_of_marriage='NO' %} + {% checkbox has_children_of_marriage='False' %}
There are no children of the marriage, as defined by the Divorce Act (Canada), or children of whom @@ -372,7 +372,7 @@ of the Family Law Act.

OR

- {% checkbox children_of_marriage='YES' %} + {% checkbox derived.has_children_of_marriage %}
There are children of the marriage, as defined by the Divorce Act (Canada), or children of whom @@ -385,8 +385,8 @@ Full name Birth date
[dd/mmm/yyyy] Resides with - + {% if derived.has_children_of_marriage %} {% for child in responses.children %} {{ child.child_name }} @@ -418,14 +418,14 @@ - A. {% checkbox want_parenting_arrangements='YES' children_of_marriage='YES' want_which_orders='Child support' %} + A. {% checkbox derived.has_children_of_marriage derived.wants_child_support want_parenting_arrangements='YES' %}
Claimant 1 and Claimant 2 are asking for the following order respecting arrangements for parenting or contact: - {% if responses.children_of_marriage == 'YES' and responses.want_parenting_arrangements == 'YES' and responses.order_respecting_arrangement and 'Child support' in responses.want_which_orders %} + {% if derived.has_children_of_marriage and responses.want_parenting_arrangements == 'YES' and responses.order_respecting_arrangement and derived.wants_child_support %}
    {{ responses.order_respecting_arrangement|striptags|linebreaksli }}
{% endif %}
@@ -435,18 +435,18 @@ - B. + B. {% if responses.child_support_in_order == 'NO' %} {% checkbox false %} {% else %} - {% checkbox responses.order_for_child_support children_of_marriage='YES' want_which_orders='Child support' %} + {% checkbox responses.order_for_child_support derived.has_children_of_marriage derived.wants_child_support %} {% endif %}
Claimant 1 and Claimant 2 are asking for an order for child support as follows: - {% if responses.children_of_marriage == 'YES' and responses.order_for_child_support and 'Child support' in responses.want_which_orders and responses.child_support_in_order != 'NO' %} + {% if derived.has_children_of_marriage and responses.order_for_child_support and derived.wants_child_support and responses.child_support_in_order != 'NO' %}
    {{ responses.order_for_child_support|striptags|linebreaksli }}
{% endif %}
@@ -456,12 +456,12 @@ - C. {% checkbox responses.describe_order_special_extra_expenses children_of_marriage='YES' want_which_orders='Child support' special_extraordinary_expenses='YES' %} + C. {% checkbox derived.wants_child_support derived.has_children_of_marriage special_extraordinary_expenses='YES' %}
Claimant 1 and Claimant 2 are asking for an order for Special and Extraordinary Expenses as follows:
- {% if responses.children_of_marriage == 'YES' and responses.special_extraordinary_expenses == 'YES' and 'Child support' in responses.want_which_orders %} + {% if derived.has_children_of_marriage and responses.special_extraordinary_expenses == 'YES' and derived.wants_child_support %}
    {{ responses.describe_order_special_extra_expenses|striptags|linebreaksli }}
{% endif %}
@@ -472,7 +472,7 @@ - D. {% checkbox responses.child_support_act children_of_marriage='YES' want_which_orders='Child support' %} + D. {% checkbox responses.child_support_act derived.has_children_of_marriage derived.wants_child_support %}
Claimant 1 and Claimant 2 are asking for the orders @@ -480,10 +480,10 @@ following statute(s):
[Check one or both of the following boxes, as applicable.]

- {% checkbox child_support_act='the Divorce Act (Canada)' children_of_marriage='YES' want_which_orders='Child support' %} + {% checkbox derived.has_children_of_marriage derived.wants_child_support child_support_act='the Divorce Act (Canada)' %} the Divorce Act (Canada)      - {% checkbox child_support_act='the Family Law Act' children_of_marriage='YES' want_which_orders='Child support' %} + {% checkbox derived.has_children_of_marriage derived.wants_child_support child_support_act='the Family Law Act' %} the Family Law Act
@@ -496,11 +496,11 @@ - {% checkbox want_which_orders='Spousal support' %} + {% checkbox derived.wants_spousal_support %}
Claimant 1 and Claimant 2 are asking for an order for spousal support as follows:
- {% if 'Spousal support' in responses.want_which_orders and responses.spouse_support_details %} + {% if derived.wants_spousal_support and responses.spouse_support_details %}
    {{responses.spouse_support_details|striptags|linebreaksli }}
{% endif %}
@@ -510,16 +510,16 @@ - {% checkbox responses.spouse_support_act want_which_orders='Spousal support' %} + {% checkbox responses.spouse_support_act derived.wants_spousal_support %}
Claimant 1 and Claimant 2 are asking for an order for spousal support under:
[Check one or both of the following boxes, as applicable.]

- {% checkbox want_which_orders='Spousal support' spouse_support_act='The Divorce Act (Canada)' %} + {% checkbox derived.wants_spousal_support spouse_support_act='The Divorce Act (Canada)' %} the Divorce Act (Canada)      - {% checkbox want_which_orders='Spousal support' spouse_support_act='The Family Law Act' %} + {% checkbox derived.wants_spousal_support spouse_support_act='The Family Law Act' %} the Family Law Act
@@ -535,13 +535,13 @@
A. Property claims under the Family Law Act

- {% checkbox want_which_orders='Division of property and debts' %} + {% checkbox derived.wants_property_division %}
Claimant 1 and Claimant 2 are asking for an order for:

- {% checkbox want_which_orders='Division of property and debts' deal_with_property_debt='Equal division' %} + {% checkbox derived.wants_property_division deal_with_property_debt='Equal division' %}
an equal division of family property and family debt

@@ -549,12 +549,12 @@
- {% checkbox want_which_orders='Division of property and debts' deal_with_property_debt='Unequal division' %} + {% checkbox derived.wants_property_division deal_with_property_debt='Unequal division' %}
an unequal division of family property and family debt as follows: - {% if responses.deal_with_property_debt == 'Unequal division' and responses.how_to_divide_property_debt and 'Division of property and debts' in responses.want_which_orders %} + {% if derived.wants_property_division and responses.deal_with_property_debt == 'Unequal division' and responses.how_to_divide_property_debt %}
    {{ responses.how_to_divide_property_debt|striptags|linebreaksli }}
{% endif %}
@@ -566,13 +566,13 @@
B. Other property claims

- {% checkbox responses.other_property_claims %} + {% checkbox derived.wants_property_division responses.other_property_claims %}
Claimant 1 and Claimant 2 ask for an order respecting an interest in property or for compensation instead of an interest in that property, as follows:
- {% if responses.other_property_claims %} + {% if derived.wants_property_division and responses.other_property_claims %}
    {{ responses.other_property_claims|striptags|linebreaksli }}
{% endif %}
@@ -586,14 +586,17 @@ - {% check_list source=responses.want_which_orders value='Other orders' as order_wanted %}
- {% if order_wanted and responses.other_orders_detail or responses.name_change_you == 'YES' or responses.name_change_spouse == 'YES' %} - {% checkbox %} - {% else %} + {% if derived.wants_other_orders %} + {% if responses.other_orders_detail or responses.name_change_you == 'YES' or responses.name_change_spouse == 'YES' %} + {% checkbox %} + {% else %} + {% checkbox False %} + {% endif %} + {% else %} {% checkbox False %} - {% endif %} + {% endif %}
Claimant 1 and Claimant 2 are asking for an order in the @@ -601,11 +604,11 @@
    - {% if responses.other_orders_detail and order_wanted %} + {% if derived.wants_other_orders and responses.other_orders_detail %} {{ responses.other_orders_detail|striptags|linebreaksli }} {% endif %} - {% if responses.name_change_you == 'YES' %} + {% if derived.wants_other_orders and responses.name_change_you == 'YES' %}
  • Pursuant to Section 5 of the Name Act, Claimant 1 shall bear the name of {{ responses.name_change_you_fullname }} @@ -613,7 +616,7 @@
  • {% endif %} - {% if responses.name_change_spouse == 'YES' %} + {% if derived.wants_other_orders and responses.name_change_spouse == 'YES' %}
  • Pursuant to Section 5 of the Name Act, Claimant 2 shall bear the name of {{ responses.name_change_spouse_fullname }} diff --git a/edivorce/apps/core/templates/pdf/form37.html b/edivorce/apps/core/templates/pdf/form37.html index e275257d..14b0a251 100644 --- a/edivorce/apps/core/templates/pdf/form37.html +++ b/edivorce/apps/core/templates/pdf/form37.html @@ -278,9 +278,9 @@ out in the proposed order for the expenses under section 7 of the Guidelines is {{ derived.total_section_seven_expenses|money }}. - Claimant 1's proportionate share is + Claimant 1's proportionate share is {{ derived.claimant_1_share|money }}. - Claimant 2's proportionate share is + Claimant 2's proportionate share is {{ derived.claimant_2_share|money }}. {% endif %}
  • diff --git a/edivorce/apps/core/templates/pdf/form38.html b/edivorce/apps/core/templates/pdf/form38.html index 14c77a68..e8da1a13 100644 --- a/edivorce/apps/core/templates/pdf/form38.html +++ b/edivorce/apps/core/templates/pdf/form38.html @@ -174,7 +174,7 @@
  • - {% if responses.children_of_marriage == 'YES' %} + {% if derived.has_children_of_marriage %}

    There are children of the marriage as defined by {{ derived.child_support_acts }}, and diff --git a/edivorce/apps/core/templates/pdf/form52.html b/edivorce/apps/core/templates/pdf/form52.html index 1bc3e42f..1cdf54b5 100644 --- a/edivorce/apps/core/templates/pdf/form52.html +++ b/edivorce/apps/core/templates/pdf/form52.html @@ -110,7 +110,7 @@

  • {% endif %} - {% if responses.children_of_marriage == 'YES' and derived.wants_child_support %} + {% if derived.has_children_of_marriage and derived.wants_child_support %} {% for order in derived.pursuant_parenting_arrangement %}
  • {{ order }}
  • {% endfor %} @@ -121,7 +121,7 @@ {% endif %} {% endif %} - {% if responses.children_of_marriage == 'YES' and responses.special_extraordinary_expenses == 'YES' %} + {% if derived.has_children_of_marriage and responses.special_extraordinary_expenses == 'YES' %} {{ responses.describe_order_special_extra_expenses|striptags|linebreaksli }} {% endif %} diff --git a/edivorce/apps/core/templates/question/06_children_what_for.html b/edivorce/apps/core/templates/question/06_children_what_for.html index 88d9e1ed..f0faaee9 100644 --- a/edivorce/apps/core/templates/question/06_children_what_for.html +++ b/edivorce/apps/core/templates/question/06_children_what_for.html @@ -367,7 +367,7 @@ {% input_field type="textarea" name="order_respecting_arrangement" class="response-textarea form-control" maxlength="20000" rows="7"%}
- {% if 'Child support' in want_which_orders|load_json %} + {% if derived.wants_child_support %}

If you are asking for an

- - - {% endblock content %} - {% block formBack %}{% prev_step step='children' sub_step='what_for' %}{% endblock %} {% block formNext %}{% next_step step='children' sub_step='what_for' %}{% endblock %} @@ -530,6 +526,4 @@
  • where the children are going to live, and
  • how much time the children will spend with each parent who is a guardian.
  • - - {% endblock %} \ No newline at end of file diff --git a/edivorce/apps/core/templatetags/format_utils.py b/edivorce/apps/core/templatetags/format_utils.py index 907687de..98790dba 100644 --- a/edivorce/apps/core/templatetags/format_utils.py +++ b/edivorce/apps/core/templatetags/format_utils.py @@ -81,8 +81,16 @@ def checkbox(context, *args, **kwargs): pass a False value as an argument. """ args_pass = all(args) - kwargs_pass = all([value in context['responses'].get(question, '') - for question, value in kwargs.items()]) + kwargs_list = [] + for question, value in kwargs.items(): + if question in context['responses']: + dict_with_question = context['responses'] + elif question in context['derived']: + dict_with_question = context['derived'] + else: + raise KeyError(f'{question} not found in responses or derived') + kwargs_list.append(str(value) in str(dict_with_question[question])) + kwargs_pass = all(kwargs_list) return mark_safe('' % ('-check' if args_pass and kwargs_pass else '')) @@ -130,7 +138,11 @@ def money(amount, symbol=True): except ValueError: pass - return '' + try: + amount = float(amount) + return '{:.2f}'.format(amount) + except ValueError: + return amount @register.simple_tag(takes_context=True)