Merge "Set interval parameter to optional and add validation before audit create"
This commit is contained in:
commit
09de59300f
@ -55,7 +55,8 @@ class CreateForm(forms.SelfHandlingForm):
|
|||||||
'data-switch-on': 'audit_type',
|
'data-switch-on': 'audit_type',
|
||||||
'data-audit_type-continuous':
|
'data-audit_type-continuous':
|
||||||
_("Interval (in seconds or cron"
|
_("Interval (in seconds or cron"
|
||||||
" format)")}))
|
" format)")}),
|
||||||
|
required=False)
|
||||||
failure_url = 'horizon:admin:audits:index'
|
failure_url = 'horizon:admin:audits:index'
|
||||||
auto_trigger = forms.BooleanField(label=_("Auto Trigger"),
|
auto_trigger = forms.BooleanField(label=_("Auto Trigger"),
|
||||||
required=False)
|
required=False)
|
||||||
@ -85,6 +86,14 @@ class CreateForm(forms.SelfHandlingForm):
|
|||||||
choices.insert(0, ("", _("No Audit Template found")))
|
choices.insert(0, ("", _("No Audit Template found")))
|
||||||
return choices
|
return choices
|
||||||
|
|
||||||
|
def clean(self):
|
||||||
|
cleaned_data = super(CreateForm, self).clean()
|
||||||
|
audit_type = cleaned_data.get('audit_type')
|
||||||
|
if audit_type == 'continuous' and not cleaned_data.get('interval'):
|
||||||
|
msg = _('Please input an interval for continuous audit')
|
||||||
|
raise forms.ValidationError(msg)
|
||||||
|
return cleaned_data
|
||||||
|
|
||||||
def handle(self, request, data):
|
def handle(self, request, data):
|
||||||
try:
|
try:
|
||||||
params = {'audit_template_uuid': data.get('audit_template')}
|
params = {'audit_template_uuid': data.get('audit_template')}
|
||||||
|
Loading…
Reference in New Issue
Block a user