From c1873a1b60690fa8bb06e13588b455d3d0810c2a Mon Sep 17 00:00:00 2001 From: Henry Doupe Date: Tue, 22 May 2018 09:49:35 -0400 Subject: [PATCH 1/3] Place holders for messages --- webapp/apps/taxbrain/views.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/webapp/apps/taxbrain/views.py b/webapp/apps/taxbrain/views.py index cadda1ff..a09f91d8 100644 --- a/webapp/apps/taxbrain/views.py +++ b/webapp/apps/taxbrain/views.py @@ -70,11 +70,12 @@ JOB_PROC_TIME_IN_SECONDS = 100 -OUT_OF_RANGE_ERROR_MSG = ("Some fields have warnings or errors. Values " - "outside of suggested ranges will be accepted if " - "they only cause warnings and are submitted again " - "from this page. Warning messages begin with " - "'WARNING', and error messages begin with 'ERROR'.") +INIT_MESSAGE = ("Some fields have warnings or errors.") +OUT_OF_RANGE_ERROR_MSG = (INIT_MESSAGE, + 'out of range', + 'warn instructions', + 'error instructions') + def log_ip(request): """ From a7def444435b7ccc3f2a8e2fed5799e9abb90bb6 Mon Sep 17 00:00:00 2001 From: Henry Doupe Date: Tue, 22 May 2018 10:14:42 -0400 Subject: [PATCH 2/3] Separate error messages: --- webapp/apps/taxbrain/views.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/webapp/apps/taxbrain/views.py b/webapp/apps/taxbrain/views.py index a09f91d8..23d876f1 100644 --- a/webapp/apps/taxbrain/views.py +++ b/webapp/apps/taxbrain/views.py @@ -71,10 +71,15 @@ JOB_PROC_TIME_IN_SECONDS = 100 INIT_MESSAGE = ("Some fields have warnings or errors.") -OUT_OF_RANGE_ERROR_MSG = (INIT_MESSAGE, - 'out of range', - 'warn instructions', - 'error instructions') +OUT_OF_RANGE_ERROR_MSG = ( + INIT_MESSAGE, + ("Fields with warnings have message(s) below them beginning with 'WARNING'," + " and fields with errors have message(s) below them beginning with 'ERROR'."), + ("If the field has a warning message , then review the input to make sure" + " it is correct and click 'SUBMIT' to run the model with these inputs."), + ("If the field has an error message, then the parameter value must be " + "changed so that it is in a valid range.") +) def log_ip(request): @@ -297,8 +302,8 @@ def submit_reform(request, user=None, json_reform_id=None): "Please specify a tax-law change before submitting." ) if taxcalc_warnings or taxcalc_errors: - msg = OUT_OF_RANGE_ERROR_MSG - personal_inputs.add_error(None, msg) + for msg in OUT_OF_RANGE_ERROR_MSG: + personal_inputs.add_error(None, msg) if has_parse_errors: msg = ("Some fields have unrecognized values. Enter comma " "separated values for each input.") From d98925033be43b32c411570eb4c53d715eb8f2ac Mon Sep 17 00:00:00 2001 From: Henry Doupe Date: Wed, 23 May 2018 13:08:08 -0400 Subject: [PATCH 3/3] Add some formatting to the error message --- webapp/apps/constants.py | 15 +++++++++++++++ webapp/apps/taxbrain/views.py | 16 ++-------------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/webapp/apps/constants.py b/webapp/apps/constants.py index d93f9eb2..6e76f9af 100644 --- a/webapp/apps/constants.py +++ b/webapp/apps/constants.py @@ -1,5 +1,7 @@ import os +from django.utils.safestring import mark_safe + DISTRIBUTION_TOOLTIP = "Key variables in the computation of tax liabilities." DIFFERENCE_TOOLTIP = "Key variables that highlight the differences between two tax plans." PAYROLL_TOOLTIP = " Include employee and employer payroll taxes in output." @@ -22,3 +24,16 @@ DEFAULT_SOURCE = os.environ.get('DEFAULT_SOURCE', 'PUF') TAXCALC_VERS_RESULTS_BACKWARDS_INCOMPATIBLE = "0.13.0" + +OUT_OF_RANGE_ERROR_MSG = mark_safe(""" +
+ Some fields have warnings or errors. Fields with warnings have message(s) + below them beginning with \'WARNING\', and fields with errors have + message(s) below them beginning with \'ERROR\'. +

+  - If the field has a warning message , then review the input to make sure + it is correct and click \'SUBMIT\' to run the model with these inputs. +
+  - If the field has an error message, then the parameter value must be + changed so that it is in a valid range. +
""") diff --git a/webapp/apps/taxbrain/views.py b/webapp/apps/taxbrain/views.py index 23d876f1..fb3c6557 100644 --- a/webapp/apps/taxbrain/views.py +++ b/webapp/apps/taxbrain/views.py @@ -54,7 +54,7 @@ REFORM_TOOLTIP, FISCAL_CURRENT_LAW, FISCAL_REFORM, FISCAL_CHANGE, INCOME_BINS_TOOLTIP, INCOME_DECILES_TOOLTIP, START_YEAR, START_YEARS, - DATA_SOURCES, DEFAULT_SOURCE) + DATA_SOURCES, DEFAULT_SOURCE, OUT_OF_RANGE_ERROR_MSG) from ..formatters import get_version from .param_formatters import (get_reform_from_file, get_reform_from_gui, @@ -70,17 +70,6 @@ JOB_PROC_TIME_IN_SECONDS = 100 -INIT_MESSAGE = ("Some fields have warnings or errors.") -OUT_OF_RANGE_ERROR_MSG = ( - INIT_MESSAGE, - ("Fields with warnings have message(s) below them beginning with 'WARNING'," - " and fields with errors have message(s) below them beginning with 'ERROR'."), - ("If the field has a warning message , then review the input to make sure" - " it is correct and click 'SUBMIT' to run the model with these inputs."), - ("If the field has an error message, then the parameter value must be " - "changed so that it is in a valid range.") -) - def log_ip(request): """ @@ -302,8 +291,7 @@ def submit_reform(request, user=None, json_reform_id=None): "Please specify a tax-law change before submitting." ) if taxcalc_warnings or taxcalc_errors: - for msg in OUT_OF_RANGE_ERROR_MSG: - personal_inputs.add_error(None, msg) + personal_inputs.add_error(None, OUT_OF_RANGE_ERROR_MSG) if has_parse_errors: msg = ("Some fields have unrecognized values. Enter comma " "separated values for each input.")