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.

33 lines
808 B

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()