Browse Source

Merge branch 'master' of https://github.com/bcgov/eDivorce

pull/172/head
ariannedee 5 years ago
parent
commit
8a409de7d6
3 changed files with 28 additions and 8 deletions
  1. +6
    -1
      edivorce/apps/core/templates/question/01_orders.html
  2. +14
    -7
      edivorce/apps/core/tests/test_step_completeness.py
  3. +8
    -0
      edivorce/apps/core/utils/user_response.py

+ 6
- 1
edivorce/apps/core/templates/question/01_orders.html View File

@ -29,12 +29,17 @@
asked to provide details for each request.</p>
<div class="checkbox-group">
<div class="question-well">
<div class="question-well {% if want_which_orders_error %}error{% endif %}">
<div class="checkbox">
<label class="checkbox-header">
{% input_field type="checkbox" name="want_which_orders" value="A legal end to the marriage" %}<b>A legal end to the marriage</b>
</label>
</div>
{% if want_which_orders_error %}
<p class="warning">
You must select this option in order to complete a divorce using this tool.
</p>
{% endif %}
<p>
Divorce is the end of a legal marriage. To get a divorce, you must
go through a legal process and get a court order that says the


+ 14
- 7
edivorce/apps/core/tests/test_step_completeness.py View File

@ -26,7 +26,9 @@ class StepCompletenessTestCase(TestCase):
return step_completeness[step]
def create_response(self, question, value):
UserResponse.objects.create(bceid_user=self.user, question=Question.objects.get(key=question), value=value)
response, _ = UserResponse.objects.get_or_create(bceid_user=self.user, question_id=question)
response.value = value
response.save()
def test_prequalification(self):
step = 'prequalification'
@ -97,14 +99,19 @@ class StepCompletenessTestCase(TestCase):
self.assertEqual(self.check_completeness(step), False)
self.assertEqual(self.check_step_status(step), Status.NOT_STARTED)
# All required question
self.create_response('want_which_orders', '["nothing"]')
self.assertEqual(self.check_completeness(step), True)
self.assertEqual(self.check_step_status(step), Status.COMPLETED)
# Empty response
self.create_response('want_which_orders', '[]')
self.assertEqual(self.check_completeness(step), False)
self.assertEqual(self.check_step_status(step), Status.NOT_STARTED)
# Put empty response
UserResponse.objects.filter(question_id='want_which_orders').update(value="[]")
# Divorce order is required
self.create_response('want_which_orders', '["Child support"]')
self.assertEqual(self.check_completeness(step), False)
self.assertEqual(self.check_step_status(step), Status.STARTED)
self.create_response('want_which_orders', '["A legal end to the marriage"]')
self.assertEqual(self.check_completeness(step), True)
self.assertEqual(self.check_step_status(step), Status.COMPLETED)
def test_your_info(self):
step = 'your_information'


+ 8
- 0
edivorce/apps/core/utils/user_response.py View File

@ -106,6 +106,8 @@ def _get_question_details(question, questions_dict, responses_by_key):
if response:
value = get_cleaned_response_value(response)
error = required and not value
if not error:
error = _other_errors(question, value)
else:
value = None
error = None
@ -118,6 +120,12 @@ def _get_question_details(question, questions_dict, responses_by_key):
return details
def _other_errors(question, value):
if question == 'want_which_orders' and 'A legal end to the marriage' not in value:
return True
return False
def _is_question_required(question, questions_dict, responses_by_key):
"""
returns REQUIRED, HIDDEN, or OPTIONAL


Loading…
Cancel
Save