From bc87e0c48d6870e65d9ffc6471d7d49e6b8fa93d Mon Sep 17 00:00:00 2001 From: Michael Olund Date: Thu, 5 Nov 2020 15:30:02 -0800 Subject: [PATCH] DIV-1127 - Extra decimal places get saved to the system even though they get trimmed on the input field --- edivorce/apps/core/static/js/ajax.js | 6 ++++++ edivorce/apps/core/static/js/main.js | 6 ------ edivorce/apps/core/views/api.py | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/edivorce/apps/core/static/js/ajax.js b/edivorce/apps/core/static/js/ajax.js index 0ba06d65..4924ff9f 100644 --- a/edivorce/apps/core/static/js/ajax.js +++ b/edivorce/apps/core/static/js/ajax.js @@ -2,6 +2,12 @@ var ajaxOnChange = function () { var el = $(this); + // strip money fields down to 2 decimal places + if (el.hasClass('money')) { + var moneyValue = parseFloat(el.val()); + el.val(moneyValue.toFixed(2)); + } + // show/hide additional information if needed reveal(el); diff --git a/edivorce/apps/core/static/js/main.js b/edivorce/apps/core/static/js/main.js index a6b05486..b6218daa 100755 --- a/edivorce/apps/core/static/js/main.js +++ b/edivorce/apps/core/static/js/main.js @@ -775,12 +775,6 @@ $(function () { showHideChildrenLiveWithOthers(); $('input[name="has_children_under_19"], input[name="has_children_over_19"], input[name="children_financial_support"]').change(showHideChildrenLiveWithOthers); - - $('.money').on('change', function() { - var value = parseFloat($(this).val()); - $(this).val(value.toFixed(2)); - }); - $('.positive-integer').on('keypress', function(e) { // keyCode [95-105] - number page // keyCode [48-57] - 0-9 diff --git a/edivorce/apps/core/views/api.py b/edivorce/apps/core/views/api.py index d246334c..2fed06c2 100644 --- a/edivorce/apps/core/views/api.py +++ b/edivorce/apps/core/views/api.py @@ -49,7 +49,7 @@ class UserResponseHandler(APIView): if question is None and not user_attribute_updated: return Response(data="Question: '%s' does not exist" % question_key, status=status.HTTP_400_BAD_REQUEST) - return Response(status=status.HTTP_500_INTERNAL_ERROR) + return Response(status=status.HTTP_500_INTERNAL_SERVER_ERROR) return Response(status=status.HTTP_200_OK)