Private
Public Access
1
0

further improvements to create/edit alerts

This commit is contained in:
Sander Roosendaal
2019-08-17 17:38:39 +02:00
parent 729ed0d4f8
commit f9231f94e0
4 changed files with 20 additions and 14 deletions

View File

@@ -1022,7 +1022,7 @@ class Condition(models.Model):
)
metric = models.CharField(max_length=50,choices=parchoicesy1,verbose_name='Metric')
value1 = models.FloatField(default=0)
value2 = models.FloatField(default=0)
value2 = models.FloatField(default=0,null=True,blank=True)
condition = models.CharField(max_length=20,choices=conditionchoices,null=True)
class ConditionEditForm(ModelForm):
@@ -1030,6 +1030,11 @@ class ConditionEditForm(ModelForm):
model = Condition
fields = ['metric','condition','value1','value2']
def clean(self):
cd = self.cleaned_data
if cd['condition'] == 'between' and cd['value2'] is None:
raise forms.ValidationError('When using between, you must fill value 1 and value 2')
class BaseConditionFormSet(BaseFormSet):
def clean(self):
if any(self.errors):