further improvements to create/edit alerts
This commit is contained in:
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user