Browse Source

TimeoutForm prepares timedelta objects.

pull/140/head
Pēteris Caune 7 years ago
parent
commit
f3c6b0fb0d
2 changed files with 10 additions and 2 deletions
  1. +8
    -0
      hc/front/forms.py
  2. +2
    -2
      hc/front/views.py

+ 8
- 0
hc/front/forms.py View File

@ -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,


+ 2
- 2
hc/front/views.py View File

@ -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…
Cancel
Save