Don't allow textchoices on numeric answers in feedback setup
authorMagnus Hagander <magnus@hagander.net>
Thu, 5 Jul 2018 14:51:00 +0000 (16:51 +0200)
committerMagnus Hagander <magnus@hagander.net>
Thu, 5 Jul 2018 14:52:17 +0000 (16:52 +0200)
postgresqleu/confreg/backendforms.py

index 91c966c32438c5e70b09aeb4945678041900d4b7..d7619105a6032b5d0644763a15db96f3df061fb2 100644 (file)
@@ -579,6 +579,13 @@ class BackendFeedbackQuestionForm(BackendForm):
                'Sortkey': ['nosearch' ],
        }
 
+       def clean(self):
+               cleaned_data = super(BackendFeedbackQuestionForm, self).clean()
+               if not self.cleaned_data.get('isfreetext', 'False'):
+                       if self.cleaned_data.get('textchoices', ''):
+                               self.add_error('textchoices', 'Textchoices can only be specified for freetext fields')
+               return cleaned_data
+
        @classmethod
        def copy_from_conference(self, targetconf, sourceconf, idlist):
                # Conference feedback questions are copied straight over, but we disallow duplicates