aboutsummaryrefslogtreecommitdiffstats
path: root/src/workflow/forms.py
diff options
context:
space:
mode:
authorSawyer Bergeron <sbergeron@iol.unh.edu>2019-07-10 13:39:27 +0000
committerGerrit Code Review <gerrit@opnfv.org>2019-07-10 13:39:27 +0000
commit5f9a48539b49ad7be0a8366fed8b2a24d83208ef (patch)
tree5093b8392ce55b12dd1969c8b9c2210dd5483f99 /src/workflow/forms.py
parent3bc9170d34ee6cd10bb02fa7641cccd2037562bb (diff)
parent38b4412f8b6cf21371b67e8de917f5a24b2bf72d (diff)
Merge "Fixes and adds Tests"
Diffstat (limited to 'src/workflow/forms.py')
-rw-r--r--src/workflow/forms.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/workflow/forms.py b/src/workflow/forms.py
index a2746f9..4d5e9e2 100644
--- a/src/workflow/forms.py
+++ b/src/workflow/forms.py
@@ -121,7 +121,12 @@ class SearchableSelectMultipleField(forms.Field):
raise ValidationError("Nothing was selected")
else:
return []
- data_as_list = json.loads(data)
+ try:
+ data_as_list = json.loads(data)
+ except json.decoder.JSONDecodeError:
+ data_as_list = None
+ if not data_as_list:
+ raise ValidationError("Contents Not JSON")
if self.selectable_limit != -1:
if len(data_as_list) > self.selectable_limit:
raise ValidationError("Too many items were selected")
@@ -271,7 +276,11 @@ class MultipleSelectFilterField(forms.Field):
super().__init__(**kwargs)
def to_python(self, value):
- return json.loads(value)
+ try:
+ return json.loads(value)
+ except json.decoder.JSONDecodeError:
+ pass
+ raise ValidationError("content is not valid JSON")
class FormUtils: