From 7ae726e2e34c433c0dd764c6139022edff74d98d Mon Sep 17 00:00:00 2001 From: ariannedee Date: Mon, 14 Sep 2020 11:55:07 -0700 Subject: [PATCH] DIV-1114: Update prequal questions to not ask for number of children, just Yes/NO --- .../migrations/0020_auto_20200903_2328.py | 50 +++++ edivorce/apps/core/static/js/functions.js | 9 - edivorce/apps/core/static/js/main.js | 9 - .../partials/fact_sheets/fact_sheet_d.html | 2 +- .../templates/pdf/partials/fact_sheet_d.html | 4 +- .../templates/prequalification/step_04.html | 28 ++- .../core/templates/question/01_orders.html | 4 +- edivorce/apps/core/utils/conditional_logic.py | 12 +- .../apps/core/utils/question_step_mapping.py | 8 +- edivorce/apps/core/views/pdf.py | 10 +- edivorce/fixtures/Question.json | 178 ++++++++++-------- 11 files changed, 185 insertions(+), 129 deletions(-) create mode 100644 edivorce/apps/core/migrations/0020_auto_20200903_2328.py diff --git a/edivorce/apps/core/migrations/0020_auto_20200903_2328.py b/edivorce/apps/core/migrations/0020_auto_20200903_2328.py new file mode 100644 index 00000000..c463e8ec --- /dev/null +++ b/edivorce/apps/core/migrations/0020_auto_20200903_2328.py @@ -0,0 +1,50 @@ +# Generated by Django 2.2.15 on 2020-09-03 23:28 + +from django.db import migrations + + +def migrate_number_children_questions_forward(apps, schema_editor): + def _convert_value(value): + if int(response.value) > 0: + return 'YES' + else: + return'NO' + + UserResponse = apps.get_model('core', 'UserResponse') + under_19_responses = UserResponse.objects.filter(question_id='number_children_under_19') + print(f"Converting {under_19_responses.count()} under 19 responses") + for response in under_19_responses: + response.value = _convert_value(response.value) + response.question_id = 'has_children_under_19' + response.save() + + over_19_responses = UserResponse.objects.filter(question_id='number_children_over_19') + print(f"Converting {over_19_responses.count()} over 19 responses") + for response in over_19_responses: + UserResponse.objects.create(bceid_user=response.bceid_user, value=response.value, question_id='number_children_over_19_need_support') + response.value = _convert_value(response.value) + response.question_id = 'has_children_over_19' + response.save() + + +def migrate_number_children_questions_backwards(apps, schema_editor): + UserResponse = apps.get_model('core', 'UserResponse') + under_19_responses = UserResponse.objects.filter(question_id='has_children_under_19') + print(f"Converting {under_19_responses.count()} under 19 responses") + for response in under_19_responses: + response.value = 1 if response.value == 'YES' else 0 + response.question_id = 'number_children_under_19' + response.save() + + UserResponse.objects.filter(question_id='has_children_over_19').delete() + UserResponse.objects.filter(question_id='number_children_over_19_need_support').update(question_id='number_children_over_19') + + +class Migration(migrations.Migration): + dependencies = [ + ('core', '0019_auto_20191008_2141'), + ] + + operations = [ + migrations.RunPython(migrate_number_children_questions_forward, migrate_number_children_questions_backwards) + ] diff --git a/edivorce/apps/core/static/js/functions.js b/edivorce/apps/core/static/js/functions.js index 2ded45e7..67d2a445 100644 --- a/edivorce/apps/core/static/js/functions.js +++ b/edivorce/apps/core/static/js/functions.js @@ -117,15 +117,6 @@ var showHideTargetId = function(el, id, relatedId, revealControlGroup) { if (relatedId !== undefined) { $('#' + relatedId).hide(); } - // Special case of pre-qualification step 4 children. - if (id === "#has_children") { - reveal($("input[name=number_children_over_19]")); - var over_19_children = parseInt($("input[name=number_children_over_19]").val()); - - if (over_19_children >= 0) { - reveal($("input[name=number_children_over_19]:checked")); - } - } // Special case of hide child support description. if (id === "#child_support_in_order_detail") { $("#child_support_description").hide(); diff --git a/edivorce/apps/core/static/js/main.js b/edivorce/apps/core/static/js/main.js index 2ef04cb1..27bdc0a3 100755 --- a/edivorce/apps/core/static/js/main.js +++ b/edivorce/apps/core/static/js/main.js @@ -198,15 +198,6 @@ $(function () { $('input[type=number], input[type=radio], input[type=checkbox], input[type=text], .response-textarea, .response-dropdown').on('change', ajaxOnChange); - // The designers want the dependent elements to be revealed as soon as the user completes input but before - // they click on the next button. Using the keypress event with a small timeout to mimic an on change event - // that does not require the current element to loose focus. - $('input[name=number_children_over_19]').on('keypress', function() { - var self = $(this); - setTimeout(function(){ self.trigger('change');}, 50); - }); - - // If relationship is common law and they want spousal support, update spouse_support_act with hidden input field, spouse_support_act_common_law if ($("#spouse_support_act_common_law").length) { var el = $("#spouse_support_act_common_law"); diff --git a/edivorce/apps/core/templates/partials/fact_sheets/fact_sheet_d.html b/edivorce/apps/core/templates/partials/fact_sheets/fact_sheet_d.html index e74f7fc2..12af2027 100644 --- a/edivorce/apps/core/templates/partials/fact_sheets/fact_sheet_d.html +++ b/edivorce/apps/core/templates/partials/fact_sheets/fact_sheet_d.html @@ -11,7 +11,7 @@ How many child(ren) are 19 years or older for whom you are asking for support?

- {% input_field type="number" name="number_children_over_19_need_support" value="number_children_over_19" class="fact-sheet-input input-narrow positive-integer" readonly="" %} + {% input_field type="number" name="number_children_over_19_need_support" class="fact-sheet-input input-narrow positive-integer" %}
diff --git a/edivorce/apps/core/templates/pdf/partials/fact_sheet_d.html b/edivorce/apps/core/templates/pdf/partials/fact_sheet_d.html index 08f0879a..6a78f3ce 100644 --- a/edivorce/apps/core/templates/pdf/partials/fact_sheet_d.html +++ b/edivorce/apps/core/templates/pdf/partials/fact_sheet_d.html @@ -9,7 +9,7 @@
  1. Number of child(ren) 19 years of age or older for whom support is claimed: - {{ responses.number_children_over_19 }} + {{ responses.number_children_over_19_need_support }}
  2. Child support is to be paid by {{ derived.child_support_payor }} (the “payor”) @@ -20,7 +20,7 @@
- {% if responses.child_support_in_order == 'MATCH' %} + {% if responses.child_support_in_order == 'MATCH' %}

The person swearing this affidavit says that the Guidelines table amount is appropriate. diff --git a/edivorce/apps/core/templates/prequalification/step_04.html b/edivorce/apps/core/templates/prequalification/step_04.html index 55756761..766d01dd 100644 --- a/edivorce/apps/core/templates/prequalification/step_04.html +++ b/edivorce/apps/core/templates/prequalification/step_04.html @@ -135,15 +135,35 @@