Merge "handle missing access_rules"
This commit is contained in:
commit
0b6ac97fcd
|
@ -132,12 +132,15 @@ class CreateApplicationCredentialForm(forms.SelfHandlingForm):
|
||||||
|
|
||||||
def clean(self):
|
def clean(self):
|
||||||
cleaned_data = super().clean()
|
cleaned_data = super().clean()
|
||||||
try:
|
# access_rules field exists only when keystone API >= 3.13 and
|
||||||
cleaned_data['access_rules'] = yaml.safe_load(
|
# the field is deleted above when a lower version of API is used.
|
||||||
cleaned_data['access_rules'])
|
if 'access_rules' in cleaned_data:
|
||||||
except yaml.YAMLError:
|
try:
|
||||||
msg = (_('Access rules must be a valid JSON or YAML list.'))
|
cleaned_data['access_rules'] = yaml.safe_load(
|
||||||
raise forms.ValidationError(msg)
|
cleaned_data['access_rules'])
|
||||||
|
except yaml.YAMLError:
|
||||||
|
msg = (_('Access rules must be a valid JSON or YAML list.'))
|
||||||
|
raise forms.ValidationError(msg)
|
||||||
return cleaned_data
|
return cleaned_data
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue