From a34fc9edbfb258fb6c30dc3ab00ed988bbd70892 Mon Sep 17 00:00:00 2001
From: Charles Shin
Date: Mon, 20 Mar 2017 17:30:44 -0700
Subject: [PATCH] Updated complete state for some steps
---
edivorce/apps/core/templates/pdf/form38.html | 2 +-
.../apps/core/templates/pdf/form38_we.html | 2 +-
.../core/templates/question/06_support.html | 4 +--
edivorce/apps/core/tests.py | 30 +++++++++++++++----
.../apps/core/utils/question_step_mapping.py | 6 ++--
edivorce/apps/core/utils/user_response.py | 7 ++---
6 files changed, 33 insertions(+), 18 deletions(-)
diff --git a/edivorce/apps/core/templates/pdf/form38.html b/edivorce/apps/core/templates/pdf/form38.html
index 673c258b..ae5bda13 100644
--- a/edivorce/apps/core/templates/pdf/form38.html
+++ b/edivorce/apps/core/templates/pdf/form38.html
@@ -85,7 +85,7 @@
{% for period in periods %}
from {{ period | first }} to {{ period | last }}{% if not forloop.last %}, {% endif %}
{% endfor %}.
- {% else %}[provide dates of any periods of attempted reconciliation ] .{% endif %}
+ {% else %}[provide dates of any periods of attempted reconciliation ] {% endif %}
{% comment "This section is out of scope" %}
diff --git a/edivorce/apps/core/templates/pdf/form38_we.html b/edivorce/apps/core/templates/pdf/form38_we.html
index 32e7c375..7af5e1c7 100644
--- a/edivorce/apps/core/templates/pdf/form38_we.html
+++ b/edivorce/apps/core/templates/pdf/form38_we.html
@@ -95,7 +95,7 @@
{% for period in periods %}
from {{ period | first }} to {{ period | last }}{% if not forloop.last %}, {% endif %}
{% endfor %}.
- {% else %}[provide dates of any periods of attempted reconciliation ] .{% endif %}
+ {% else %}[provide dates of any periods of attempted reconciliation ] {% endif %}
{% comment "This section is out of scope" %}
diff --git a/edivorce/apps/core/templates/question/06_support.html b/edivorce/apps/core/templates/question/06_support.html
index 62b67bbe..54d4c031 100644
--- a/edivorce/apps/core/templates/question/06_support.html
+++ b/edivorce/apps/core/templates/question/06_support.html
@@ -100,8 +100,8 @@
Please indicate which act you are asking for support under.
-
{% input_field type="radio" name="spouse_support_act" value="divorce" data_target_id="family_law_time_limit" data_reveal_target="false" %}the Divorce Act (Canada) -
view the Divorce Act
-
{% input_field type="radio" name="spouse_support_act" value="family" data_target_id="family_law_time_limit" data_reveal_target="true" %}the Family Law Act -
view the Family Law Act
+
{% input_field type="radio" name="spouse_support_act" value="divorce" data_target_id="family_law_time_limit" data_reveal_target="false" %}the Divorce Act (Canada) -
view the Divorce Act
+
{% input_field type="radio" name="spouse_support_act" value="family" data_target_id="family_law_time_limit" data_reveal_target="true" %}the Family Law Act -
view the Family Law Act
Time limit to apply for court order
diff --git a/edivorce/apps/core/tests.py b/edivorce/apps/core/tests.py
index 7c12488e..051ecd86 100644
--- a/edivorce/apps/core/tests.py
+++ b/edivorce/apps/core/tests.py
@@ -65,7 +65,7 @@ class UserResponseTestCase(TestCase):
self.assertEqual(is_complete(step, lst), False)
# All required questions with one checking question with hidden question missing
- UserResponse.objects.filter(question_id='lived_in_bc_you').update(value="Moved to British Columbia on")
+ UserResponse.objects.filter(question_id='lived_in_bc_you').update(value="Moved to B.C. on")
lst = UserResponse.objects.filter(question_id__in=questions).values('question_id', 'value')
self.assertEqual(is_complete(step, lst), False)
@@ -144,13 +144,13 @@ class UserResponseTestCase(TestCase):
self.assertEqual(is_complete(step, lst), False)
# All required questions with two checking question with one hidden and one shown
- create_response(user, 'other_name_spouse', 'Smith')
+ create_response(user, 'other_name_spouse', '[["also known as","Smith"]]')
lst = UserResponse.objects.filter(question_id__in=questions).values('question_id', 'value')
self.assertEqual(is_complete(step, lst), True)
# All required questions with two checking question with one hidden question missing
- UserResponse.objects.filter(question_id='lived_in_bc_spouse').update(value="Moved to British Columbia on")
+ UserResponse.objects.filter(question_id='lived_in_bc_spouse').update(value="Moved to B.C. on")
lst = UserResponse.objects.filter(question_id__in=questions).values('question_id', 'value')
self.assertEqual(is_complete(step, lst), False)
@@ -167,6 +167,12 @@ class UserResponseTestCase(TestCase):
lst = UserResponse.objects.filter(question_id__in=questions).values('question_id', 'value')
self.assertEqual(is_complete(step, lst), False)
+ # Put empty response
+ UserResponse.objects.filter(question_id='other_name_spouse').update(value='[["also known as",""]]')
+
+ lst = UserResponse.objects.filter(question_id__in=questions).values('question_id', 'value')
+ self.assertEqual(is_complete(step, lst), False)
+
def test_your_marriage(self):
pass
@@ -237,7 +243,7 @@ class UserResponseTestCase(TestCase):
create_response(user, 'deal_with_property_debt', 'equal division')
lst = UserResponse.objects.filter(question_id__in=questions).values('question_id', 'value')
- self.assertEqual(is_complete(step, lst), True)
+ self.assertEqual(is_complete(step, lst), False)
# All required question with hidden shown but no response
UserResponse.objects.filter(question_id='deal_with_property_debt').update(value="unequal division")
@@ -245,14 +251,26 @@ class UserResponseTestCase(TestCase):
lst = UserResponse.objects.filter(question_id__in=questions).values('question_id', 'value')
self.assertEqual(is_complete(step, lst), False)
- # All required question with hidden shown and answered
+ # Only one required question with hidden shown and answered
create_response(user, 'how_to_divide_property_debt', 'Do not divide them')
+ lst = UserResponse.objects.filter(question_id__in=questions).values('question_id', 'value')
+ self.assertEqual(is_complete(step, lst), False)
+
+ # Only two required question with hidden shown and answered
+ create_response(user, 'want_other_property_claims', 'Ask for other property claims')
+
+ lst = UserResponse.objects.filter(question_id__in=questions).values('question_id', 'value')
+ self.assertEqual(is_complete(step, lst), False)
+
+ # All required question with hidden shown and answered
+ create_response(user, 'other_property_claims', 'Want these property claims')
+
lst = UserResponse.objects.filter(question_id__in=questions).values('question_id', 'value')
self.assertEqual(is_complete(step, lst), True)
# Put empty response
- UserResponse.objects.filter(question_id='how_to_divide_property_debt').update(value="")
+ UserResponse.objects.filter(question_id='want_other_property_claims').update(value="")
lst = UserResponse.objects.filter(question_id__in=questions).values('question_id', 'value')
self.assertEqual(is_complete(step, lst), False)
diff --git a/edivorce/apps/core/utils/question_step_mapping.py b/edivorce/apps/core/utils/question_step_mapping.py
index f34ba747..e3bbfc34 100644
--- a/edivorce/apps/core/utils/question_step_mapping.py
+++ b/edivorce/apps/core/utils/question_step_mapping.py
@@ -55,16 +55,16 @@ complete_state_for_step = {'which_orders': {'required': ['want_which_orders']},
'your_information': {'required': ['name_you', 'last_name_born_you',
'last_name_before_married_you', 'birthday_you', 'occupation_you'],
'conditional': {'any_other_name_you': ['YES', 'other_name_you'],
- 'lived_in_bc_you': ['Moved to British Columbia on', 'moved_to_bc_date_you']},},
+ 'lived_in_bc_you': ['Moved to B.C. on', 'moved_to_bc_date_you']},},
'your_spouse': {'required': ['name_spouse', 'last_name_born_spouse',
'last_name_before_married_spouse', 'birthday_spouse', 'occupation_spouse'],
'conditional': {'any_other_name_spouse': ['YES', 'other_name_spouse'],
- 'lived_in_bc_spouse': ['Moved to British Columbia on', 'moved_to_bc_date_spouse']},},
+ 'lived_in_bc_spouse': ['Moved to B.C. on', 'moved_to_bc_date_spouse']},},
'your_marriage': {'required': ['when_were_you_live_married_like', 'marital_status_before_you', 'marital_status_before_spouse'],
'conditional': {'married_marriage_like': ['Legally married', 'when_were_you_married']}},
'your_separation': {'required': ['no_reconciliation_possible', 'no_collusion']},
'spousal_support': {'required': ['spouse_support_details', 'spouse_support_act']},
- 'property_and_debt': {'required': [],
+ 'property_and_debt': {'required': ['want_other_property_claims', 'other_property_claims'],
'conditional': {'deal_with_property_debt': ['unequal division', 'how_to_divide_property_debt']}},
'other_orders': {'required': ['other_orders_detail']},
'other_questions': {'required': ['address_to_send_official_document_street_you',
diff --git a/edivorce/apps/core/utils/user_response.py b/edivorce/apps/core/utils/user_response.py
index a97a465c..ef9266dc 100644
--- a/edivorce/apps/core/utils/user_response.py
+++ b/edivorce/apps/core/utils/user_response.py
@@ -16,7 +16,7 @@ def get_responses_from_db_grouped_by_steps(bceid_user):
responses = UserResponse.objects.filter(bceid_user=bceid_user)
responses_dict = {}
for step, questions in question_step_mapping.items():
- responses_dict[step] = responses.filter(question_id__in=questions).values('question_id', 'value', 'question__name')
+ responses_dict[step] = responses.filter(question_id__in=questions).exclude(value__in=['', '[]']).values('question_id', 'value', 'question__name')
return responses_dict
@@ -92,10 +92,7 @@ def is_complete(step, lst):
hidden_q_id = conditional_list[q_id][1]
for key in lst:
if key['question_id'] == hidden_q_id:
- # print("H: %s, V: %s|" %(hidden_q_id, key['value']))
- if hidden_q_id == 'other_name_you' and not json.loads(key['value'])[0][1]:
- break
- elif not key['value'] or key['value'].strip() == '':
+ if (hidden_q_id == 'other_name_you' or hidden_q_id == 'other_name_spouse') and not json.loads(key['value'])[0][1]:
break
else:
key_in_list = True