From 5e2bfc147384886afba95d4016bd8c56632ca877 Mon Sep 17 00:00:00 2001 From: chill0r <1339474+chill0r@users.noreply.github.com> Date: Sat, 6 Feb 2021 14:38:30 +0100 Subject: [PATCH 1/4] Update inference_views.py Fix for issue #314 --- aligulac/ratings/inference_views.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/aligulac/ratings/inference_views.py b/aligulac/ratings/inference_views.py index 5000a84..dffe192 100644 --- a/aligulac/ratings/inference_views.py +++ b/aligulac/ratings/inference_views.py @@ -290,11 +290,17 @@ def match(request): if not form.is_valid(): return redirect('/inference/') + # Issue #314: Check for numeric value or reset to 0 + if not str.isnumeric(s1): + s1 = 0 + if not str.isnumeric(s2): + s2 = 0 + result = MatchPredictionResult( dbpl=form.cleaned_data['ps'], bos=form.cleaned_data['bo'], - s1=get_param(request, 's1', 0), - s2=get_param(request, 's2', 0), + s1=s1, + s2=s2, ) # }}} From 9bc420e1cb0221e7f6037320350c131c876d057f Mon Sep 17 00:00:00 2001 From: chill0r <1339474+chill0r@users.noreply.github.com> Date: Sat, 6 Feb 2021 14:43:05 +0100 Subject: [PATCH 2/4] Update inference_views.py --- aligulac/ratings/inference_views.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/aligulac/ratings/inference_views.py b/aligulac/ratings/inference_views.py index dffe192..1719ad8 100644 --- a/aligulac/ratings/inference_views.py +++ b/aligulac/ratings/inference_views.py @@ -291,6 +291,9 @@ def match(request): return redirect('/inference/') # Issue #314: Check for numeric value or reset to 0 + s1 = get_param(request, 's1', 0) + s2 = get_param(request, 's1', 0) + if not str.isnumeric(s1): s1 = 0 if not str.isnumeric(s2): From aebf0db888294a1d75587aeda19d9d6d8e0137f4 Mon Sep 17 00:00:00 2001 From: chill0r <1339474+chill0r@users.noreply.github.com> Date: Sat, 6 Feb 2021 14:49:01 +0100 Subject: [PATCH 3/4] Update inference_views.py Ready for testing --- aligulac/ratings/inference_views.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/aligulac/ratings/inference_views.py b/aligulac/ratings/inference_views.py index 1719ad8..fdc8c35 100644 --- a/aligulac/ratings/inference_views.py +++ b/aligulac/ratings/inference_views.py @@ -292,11 +292,11 @@ def match(request): # Issue #314: Check for numeric value or reset to 0 s1 = get_param(request, 's1', 0) - s2 = get_param(request, 's1', 0) + s2 = get_param(request, 's2', 0) - if not str.isnumeric(s1): + if type(s1) == str and not str.isnumeric(s1): s1 = 0 - if not str.isnumeric(s2): + if type(s2) == str and not str.isnumeric(s2): s2 = 0 result = MatchPredictionResult( From 20b8a0be0ca418cf25105060d89426ae1f1b1ce1 Mon Sep 17 00:00:00 2001 From: chill0r <1339474+chill0r@users.noreply.github.com> Date: Sat, 6 Feb 2021 15:12:50 +0100 Subject: [PATCH 4/4] Update inference_views.py simplified Online tests: https://pythononlines.com/result/Z03Zyx8mJ1 --- aligulac/ratings/inference_views.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/aligulac/ratings/inference_views.py b/aligulac/ratings/inference_views.py index fdc8c35..1e30e08 100644 --- a/aligulac/ratings/inference_views.py +++ b/aligulac/ratings/inference_views.py @@ -294,9 +294,9 @@ def match(request): s1 = get_param(request, 's1', 0) s2 = get_param(request, 's2', 0) - if type(s1) == str and not str.isnumeric(s1): + if not unicode(s1).isnumeric(): s1 = 0 - if type(s2) == str and not str.isnumeric(s2): + if not unicode(s2).isnumeric(): s2 = 0 result = MatchPredictionResult(