Skip to content

Commit

Permalink
forms
Browse files Browse the repository at this point in the history
  • Loading branch information
gromdimon committed Mar 1, 2023
1 parent 2f28d7f commit 5b7f6ce
Showing 1 changed file with 3 additions and 13 deletions.
16 changes: 3 additions & 13 deletions projectroles/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -631,21 +631,11 @@ def clean(self):
s_field = 'settings.{}.{}'.format(name, s_key)

if s_val['type'] == 'JSON':
# for some reason, there is a distinct possibility, that the
# initial value has been discarded and we get '' as value.
# Seems to only happen in automated tests. Will catch that
# here.
if not self.cleaned_data.get(s_field):
self.cleaned_data[s_field] = '{}'
try:
self.cleaned_data[s_field] = json.loads(
self.cleaned_data.get(s_field)
)
except json.JSONDecodeError as err:
# TODO: Shouldn't we use add_error() instead?
raise forms.ValidationError(
'Couldn\'t encode JSON\n' + str(err)
)
self.cleaned_data[s_field] = json.loads(
self.cleaned_data.get(s_field)
)
elif s_val['type'] == 'INTEGER':
# When the field is a select/dropdown the information of
# the datatype gets lost. We need to convert that here,
Expand Down

0 comments on commit 5b7f6ce

Please sign in to comment.