diff --git a/hc/front/forms.py b/hc/front/forms.py index 1e2d58ed..1617a5ef 100644 --- a/hc/front/forms.py +++ b/hc/front/forms.py @@ -1,3 +1,5 @@ +from datetime import timedelta as td + from django import forms from django.core.validators import RegexValidator from hc.front.validators import (CronExpressionValidator, TimezoneValidator, @@ -23,6 +25,12 @@ class TimeoutForm(forms.Form): timeout = forms.IntegerField(min_value=60, max_value=2592000) grace = forms.IntegerField(min_value=60, max_value=2592000) + def clean_timeout(self): + return td(seconds=self.cleaned_data["timeout"]) + + def clean_grace(self): + return td(seconds=self.cleaned_data["grace"]) + class CronForm(forms.Form): schedule = forms.CharField(max_length=100, diff --git a/hc/front/views.py b/hc/front/views.py index 0173e0c5..151cbff8 100644 --- a/hc/front/views.py +++ b/hc/front/views.py @@ -190,8 +190,8 @@ def update_timeout(request, code): return HttpResponseBadRequest() check.kind = "simple" - check.timeout = td(seconds=form.cleaned_data["timeout"]) - check.grace = td(seconds=form.cleaned_data["grace"]) + check.timeout = form.cleaned_data["timeout"] + check.grace = form.cleaned_data["grace"] elif kind == "cron": form = CronForm(request.POST) if not form.is_valid():