You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
1.1 KiB

10 years ago
10 years ago
10 years ago
  1. from django import forms
  2. from hc.api.models import Channel
  3. class NameTagsForm(forms.Form):
  4. name = forms.CharField(max_length=100, required=False)
  5. tags = forms.CharField(max_length=500, required=False)
  6. def clean_tags(self):
  7. l = []
  8. for part in self.cleaned_data["tags"].split(" "):
  9. part = part.strip()
  10. if part != "":
  11. l.append(part)
  12. return " ".join(l)
  13. class TimeoutForm(forms.Form):
  14. timeout = forms.IntegerField(min_value=60, max_value=604800)
  15. grace = forms.IntegerField(min_value=60, max_value=604800)
  16. class AddChannelForm(forms.ModelForm):
  17. class Meta:
  18. model = Channel
  19. fields = ['kind', 'value']
  20. def clean_value(self):
  21. value = self.cleaned_data["value"]
  22. return value.strip()
  23. class AddWebhookForm(forms.Form):
  24. error_css_class = "has-error"
  25. value_down = forms.URLField(max_length=1000, required=False)
  26. value_up = forms.URLField(max_length=1000, required=False)
  27. def get_value(self):
  28. return "{value_down}\n{value_up}".format(**self.cleaned_data)