from django import forms
|
|
from hc.api.models import Channel
|
|
|
|
|
|
class NameTagsForm(forms.Form):
|
|
name = forms.CharField(max_length=100, required=False)
|
|
tags = forms.CharField(max_length=500, required=False)
|
|
|
|
def clean_tags(self):
|
|
l = []
|
|
|
|
for part in self.cleaned_data["tags"].split(" "):
|
|
part = part.strip()
|
|
if part != "":
|
|
l.append(part)
|
|
|
|
return " ".join(l)
|
|
|
|
|
|
class TimeoutForm(forms.Form):
|
|
timeout = forms.IntegerField(min_value=60, max_value=604800)
|
|
grace = forms.IntegerField(min_value=60, max_value=604800)
|
|
|
|
|
|
class AddChannelForm(forms.ModelForm):
|
|
|
|
class Meta:
|
|
model = Channel
|
|
fields = ['kind', 'value']
|
|
|
|
def clean_value(self):
|
|
value = self.cleaned_data["value"]
|
|
return value.strip()
|