forked from GithubBackups/healthchecks
TimeoutForm prepares timedelta objects.
This commit is contained in:
parent
f6c585a10c
commit
f3c6b0fb0d
@ -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,
|
||||
|
@ -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():
|
||||
|
Loading…
x
Reference in New Issue
Block a user