environment: add a setter for Variable.json (#29240)
This commit is contained in:
parent
8ced89e097
commit
09588c0de6
|
@ -72,13 +72,17 @@ class Variable(models.Model):
|
|||
raise ValidationError('invalid JSON document')
|
||||
return self.value
|
||||
|
||||
@property
|
||||
def json(self):
|
||||
def json_getter(self):
|
||||
try:
|
||||
return self._parse_value_as_json()
|
||||
except ValidationError:
|
||||
return self.value
|
||||
|
||||
def json_setter(self, value):
|
||||
self.value = json.dumps(value)
|
||||
|
||||
json = property(json_getter, json_setter)
|
||||
|
||||
def clean(self):
|
||||
self._parse_value_as_json()
|
||||
|
||||
|
|
Loading…
Reference in New Issue