From 3725d5ab170a60510380b81e94765149aee39f51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20Beaul=C3=A9?= Date: Fri, 29 Nov 2024 16:42:49 -0500 Subject: [PATCH 1/2] Allow 0 as min/max adj feedback range --- tabbycat/adjfeedback/admin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tabbycat/adjfeedback/admin.py b/tabbycat/adjfeedback/admin.py index 9d22d15339a..14a64ca8b66 100644 --- a/tabbycat/adjfeedback/admin.py +++ b/tabbycat/adjfeedback/admin.py @@ -40,7 +40,7 @@ class Meta: def clean(self): integer_scale = AdjudicatorFeedbackQuestion.ANSWER_TYPE_INTEGER_SCALE if self.cleaned_data.get('answer_type') == integer_scale: - if not self.cleaned_data.get('min_value') or not self.cleaned_data.get('max_value'): + if self.cleaned_data.get('min_value') is None or self.cleaned_data.get('max_value') is None: raise forms.ValidationError(_("Integer scales must have a minimum and maximum")) return self.cleaned_data From 109f097c67e515ada28550fc619c80d045816636 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20Beaul=C3=A9?= Date: Sun, 1 Dec 2024 16:38:20 -0400 Subject: [PATCH 2/2] Add validation for min <= max for feedback questions --- tabbycat/adjfeedback/admin.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tabbycat/adjfeedback/admin.py b/tabbycat/adjfeedback/admin.py index 14a64ca8b66..169bc793810 100644 --- a/tabbycat/adjfeedback/admin.py +++ b/tabbycat/adjfeedback/admin.py @@ -42,6 +42,8 @@ def clean(self): if self.cleaned_data.get('answer_type') == integer_scale: if self.cleaned_data.get('min_value') is None or self.cleaned_data.get('max_value') is None: raise forms.ValidationError(_("Integer scales must have a minimum and maximum")) + if self.cleaned_data['max_value'] < self.cleaned_data['min_value']: + raise forms.ValidationError(_("Maximum value must be greater than the minimum")) return self.cleaned_data