diff --git a/edivorce/apps/core/templatetags/step_order.py b/edivorce/apps/core/templatetags/step_order.py
index 6eda0ce9..1310a40d 100644
--- a/edivorce/apps/core/templatetags/step_order.py
+++ b/edivorce/apps/core/templatetags/step_order.py
@@ -72,23 +72,20 @@ def _adjust_for_orders(next_item, want_which_orders, children_of_marriage=None,
@register.simple_tag(takes_context=True)
def step_order(context, step):
- want_which_orders = __parse_json_which_orders_selected(context)
base_order = template_step_order[step]
order = base_order
+ derived_data = context.get('derived', dict())
- 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
- ):
+ if base_order > 5 and not derived_data.get('has_children_of_marriage'):
order -= 1
- if base_order > 6 and 'Spousal support' not in want_which_orders:
+ if base_order > 6 and not derived_data.get('wants_spousal_support'):
order -= 1
- if base_order > 7 and 'Division of property and debts' not in want_which_orders:
+ if base_order > 7 and not derived_data.get('wants_property_division'):
order -= 1
- if base_order > 8 and 'Other orders' not in want_which_orders:
+ if base_order > 8 and not derived_data.get('wants_other_orders'):
order -= 1
return order
diff --git a/edivorce/apps/core/tests/test_api.py b/edivorce/apps/core/tests/test_api.py
index ad775003..82eca245 100644
--- a/edivorce/apps/core/tests/test_api.py
+++ b/edivorce/apps/core/tests/test_api.py
@@ -40,7 +40,8 @@ class MockRedis:
@mock.patch.object(Redis, 'get', MockRedis.get)
@mock.patch.object(Redis, 'delete', MockRedis.delete)
@mock.patch.object(Redis, 'exists', MockRedis.exists)
-@modify_settings(MIDDLEWARE={'remove': 'edivorce.apps.core.middleware.bceid_middleware.BceidMiddleware', })
+@modify_settings(MIDDLEWARE={'remove': 'edivorce.apps.core.middleware.bceid_middleware.BceidMiddleware'})
+@override_settings(CLAMAV_ENABLED=False)
class APITest(APITestCase):
def setUp(self):
self.user = BceidUser.objects.create(user_guid='1234')
@@ -73,8 +74,7 @@ class APITest(APITestCase):
}
self.client.force_authenticate(self.user)
- with self.settings(CLAMAV_ENABLED=False):
- response = self.client.post(url, data)
+ response = self.client.post(url, data)
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
@@ -101,21 +101,75 @@ class APITest(APITestCase):
}
self.client.force_authenticate(self.user)
- with self.settings(CLAMAV_ENABLED=False):
- response = self.client.post(url, data)
+ response = self.client.post(url, data)
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
self.assertEqual(Document.objects.count(), 1)
- file.seek(0) #
+ file.seek(0)
- with self.settings(CLAMAV_ENABLED=False):
- response = self.client.post(url, data)
+ response = self.client.post(url, data)
self.assertContains(response,
'This file appears to have already been uploaded for this document.',
status_code=status.HTTP_400_BAD_REQUEST)
+ def test_post_only_one_pdf(self):
+ url = reverse('documents')
+
+ file = _create_file()
+ data = {
+ 'file': file,
+ 'doc_type': 'AAI',
+ 'party_code': 1
+ }
+ self.client.force_authenticate(self.user)
+ response = self.client.post(url, data)
+ self.assertEqual(response.status_code, status.HTTP_201_CREATED)
+ self.assertEqual(Document.objects.count(), 1)
+
+ file = _create_file(extension='pdf')
+ data = {
+ 'file': file,
+ 'doc_type': 'AAI',
+ 'party_code': 1
+ }
+
+ response = self.client.post(url, data)
+
+ self.assertContains(response,
+ "Only one PDF is allowed per form, and PDF documents cannot be combined with images.",
+ status_code=status.HTTP_400_BAD_REQUEST)
+ self.assertEqual(Document.objects.count(), 1)
+
+ def test_post_no_existing_pdfs(self):
+ url = reverse('documents')
+
+ file = _create_file(extension='pdf')
+ data = {
+ 'file': file,
+ 'doc_type': 'AAI',
+ 'party_code': 1
+ }
+ self.client.force_authenticate(self.user)
+ response = self.client.post(url, data)
+ self.assertEqual(response.status_code, status.HTTP_201_CREATED)
+ self.assertEqual(Document.objects.count(), 1)
+
+ file = _create_file()
+ data = {
+ 'file': file,
+ 'doc_type': 'AAI',
+ 'party_code': 1
+ }
+
+ response = self.client.post(url, data)
+
+ self.assertContains(response,
+ "PDF documents cannot be combined with images. Only a single PDF or multiple images can be uploaded into one form.",
+ status_code=status.HTTP_400_BAD_REQUEST)
+ self.assertEqual(Document.objects.count(), 1)
+
def test_post_field_validation(self):
url = reverse('documents')
diff --git a/edivorce/apps/core/tests/test_logic.py b/edivorce/apps/core/tests/test_logic.py
index f1319fad..1d7a3365 100644
--- a/edivorce/apps/core/tests/test_logic.py
+++ b/edivorce/apps/core/tests/test_logic.py
@@ -57,6 +57,7 @@ class ConditionalLogicTestCase(TestCase):
# Has children, and marked YES to children of marriage in prequal
self.create_response('children_of_marriage', 'YES')
+ self.create_response('has_children_under_19', 'YES')
self.assertEqual(logic.get_num_children_living_with(self.questions_dict, 'Lives with you'), '1')
self.assertEqual(logic.get_num_children_living_with(self.questions_dict, 'Lives with spouse'), '2')
self.assertEqual(logic.get_num_children_living_with(self.questions_dict, 'Lives with both'), '3')
@@ -70,12 +71,34 @@ class ConditionalLogicTestCase(TestCase):
self.assertFalse(logic.determine_shared_custody(self.questions_dict))
self.create_response('children_of_marriage', 'YES')
+ self.create_response('has_children_under_19', 'YES')
self.assertTrue(logic.determine_shared_custody(self.questions_dict))
children = [self.child_live_with_spouse, self.child_live_with_you]
self.create_response('claimant_children', json.dumps(children))
self.assertFalse(logic.determine_shared_custody(self.questions_dict))
+ def test_has_children_of_marriage(self):
+ self.assertFalse(logic.determine_has_children_of_marriage(self.questions_dict))
+
+ self.create_response('children_of_marriage', 'NO')
+ self.assertFalse(logic.determine_has_children_of_marriage(self.questions_dict))
+
+ self.create_response('children_of_marriage', 'YES')
+ self.create_response('has_children_under_19', 'YES')
+ self.assertTrue(logic.determine_has_children_of_marriage(self.questions_dict))
+
+ self.create_response('has_children_under_19', 'NO')
+ self.create_response('has_children_over_19', 'NO')
+ self.assertFalse(logic.determine_has_children_of_marriage(self.questions_dict))
+
+ self.create_response('has_children_over_19', 'YES')
+ self.create_response('children_financial_support', '["NO"]')
+ self.assertFalse(logic.determine_has_children_of_marriage(self.questions_dict))
+
+ self.create_response('children_financial_support', '["Yes, attending post secondary institution"]')
+ self.assertTrue(logic.determine_has_children_of_marriage(self.questions_dict))
+
class ViewLogic(TestCase):
def test_content_type_from_filename(self):
diff --git a/edivorce/apps/core/tests/test_step_completeness.py b/edivorce/apps/core/tests/test_step_completeness.py
index 2046269d..b1e46d5f 100644
--- a/edivorce/apps/core/tests/test_step_completeness.py
+++ b/edivorce/apps/core/tests/test_step_completeness.py
@@ -466,6 +466,7 @@ class ChildrenStepCompletenessTestCase(TestCase):
self.child_live_with_spouse = {"child_name": "Child with spouse", "child_birth_date": "Jan 4, 2009", "child_live_with": "Lives with spouse", "child_relationship_to_you": "Adopted child", "child_relationship_to_spouse": "Adopted child", "child_live_with_other_details": ""}
self.child_live_with_both = {"child_name": "Child with both", "child_birth_date": "Jan 4, 2009", "child_live_with": "Lives with both", "child_relationship_to_you": "Adopted child", "child_relationship_to_spouse": "Adopted child", "child_live_with_other_details": ""}
self.create_response('children_of_marriage', 'YES')
+ self.create_response('has_children_under_19', 'YES')
def get_children_step_status(self, substep=None):
responses_dict = get_data_for_user(self.user)
@@ -499,12 +500,36 @@ class ChildrenStepCompletenessTestCase(TestCase):
def test_no_children(self):
self.create_response('children_of_marriage', 'NO')
- self.assertEqual(self.get_children_step_status(), 'Hidden')
- self.assertEqual(self.get_children_step_status('your_children'), 'Hidden')
- self.assertEqual(self.get_children_step_status('income_expenses'), 'Hidden')
- self.assertEqual(self.get_children_step_status('facts'), 'Hidden')
- self.assertEqual(self.get_children_step_status('payor_medical'), 'Hidden')
- self.assertEqual(self.get_children_step_status('what_for'), 'Hidden')
+ self.assertEqual(self.get_children_step_status(), Status.HIDDEN)
+ self.assertEqual(self.get_children_step_status('your_children'), Status.HIDDEN)
+ self.assertEqual(self.get_children_step_status('income_expenses'), Status.HIDDEN)
+ self.assertEqual(self.get_children_step_status('facts'), Status.HIDDEN)
+ self.assertEqual(self.get_children_step_status('payor_medical'), Status.HIDDEN)
+ self.assertEqual(self.get_children_step_status('what_for'), Status.HIDDEN)
+
+ def test_only_grown_children(self):
+ self.create_response('children_of_marriage', 'YES')
+ self.create_response('has_children_under_19', 'NO')
+ self.create_response('has_children_over_19', 'YES')
+ self.create_response('children_financial_support', '["NO"]')
+ self.assertEqual(self.get_children_step_status(), Status.HIDDEN)
+ self.assertEqual(self.get_children_step_status('your_children'), Status.HIDDEN)
+ self.assertEqual(self.get_children_step_status('income_expenses'), Status.HIDDEN)
+ self.assertEqual(self.get_children_step_status('facts'), Status.HIDDEN)
+ self.assertEqual(self.get_children_step_status('payor_medical'), Status.HIDDEN)
+ self.assertEqual(self.get_children_step_status('what_for'), Status.HIDDEN)
+
+ def test_has_children(self):
+ self.create_response('children_of_marriage', 'YES')
+ self.create_response('has_children_under_19', 'NO')
+ self.create_response('has_children_over_19', 'YES')
+ self.create_response('children_financial_support', '["Yes, other reason"]')
+ self.assertEqual(self.get_children_step_status(), Status.NOT_STARTED)
+ self.assertEqual(self.get_children_step_status('your_children'), Status.NOT_STARTED)
+ self.assertEqual(self.get_children_step_status('income_expenses'), Status.NOT_STARTED)
+ self.assertEqual(self.get_children_step_status('facts'), Status.NOT_STARTED)
+ self.assertEqual(self.get_children_step_status('payor_medical'), Status.NOT_STARTED)
+ self.assertEqual(self.get_children_step_status('what_for'), Status.NOT_STARTED)
def test_children_details(self):
substep = 'your_children'
diff --git a/edivorce/apps/core/utils/conditional_logic.py b/edivorce/apps/core/utils/conditional_logic.py
index 0c2fa0ac..8a57b5a3 100644
--- a/edivorce/apps/core/utils/conditional_logic.py
+++ b/edivorce/apps/core/utils/conditional_logic.py
@@ -3,21 +3,23 @@ import json
import re
+def determine_has_children_of_marriage(questions_dict):
+ has_children = questions_dict.get('children_of_marriage', '') == 'YES'
+ has_under_19 = questions_dict.get('has_children_under_19', '') == 'YES'
+ return has_children and (has_under_19 or _children_over_19_supported(questions_dict))
+
+
def if_no_children(return_val):
def decorator_no_children(func):
@functools.wraps(func)
def inner(questions_dict, *args, **kwargs):
- if questions_dict.get('children_of_marriage', '') != 'YES':
+ if not determine_has_children_of_marriage(questions_dict):
return return_val
return func(questions_dict, *args, **kwargs)
return inner
return decorator_no_children
-def determine_has_children_of_marriage(questions_dict):
- return questions_dict.get('children_of_marriage', '') == 'YES'
-
-
@if_no_children(return_val=[])
def get_children(questions_dict):
children_json = questions_dict.get('claimant_children', '[]')
@@ -69,6 +71,10 @@ def determine_split_custody(questions_dict):
@if_no_children(return_val=False)
def determine_child_over_19_supported(questions_dict):
+ return _children_over_19_supported(questions_dict)
+
+
+def _children_over_19_supported(questions_dict):
has_children_over_19 = questions_dict.get('has_children_over_19', '') == 'YES'
support = json.loads(questions_dict.get('children_financial_support', '[]'))
supporting_children = len(support) > 0 and 'NO' not in support
diff --git a/edivorce/apps/core/utils/derived.py b/edivorce/apps/core/utils/derived.py
index d1ebe9d3..f7e3afd0 100644
--- a/edivorce/apps/core/utils/derived.py
+++ b/edivorce/apps/core/utils/derived.py
@@ -117,9 +117,7 @@ def children(responses, derived):
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'
+ return conditional_logic.determine_has_children_of_marriage(responses)
def wants_divorce_order(responses, derived):
diff --git a/vue/src/components/Uploader/Uploader.vue b/vue/src/components/Uploader/Uploader.vue
index 26a84f9a..6865579a 100644
--- a/vue/src/components/Uploader/Uploader.vue
+++ b/vue/src/components/Uploader/Uploader.vue
@@ -247,8 +247,9 @@
if (newFile.file && newFile.type.substr(0, 6) === "image/") {
new Compressor(newFile.file, {
quality: 0.9,
- maxWidth: 3600,
- maxHeight: 3600,
+ maxWidth: 3300,
+ maxHeight: 3300,
+ convertSize: Infinity,
success(result) {
console.log(result);
self.$refs.upload.update(newFile, {