diff --git a/opentech/apply/categories/blocks.py b/opentech/apply/categories/blocks.py index ffa193a4e5112d43bbf815ea2c0226d1420fe0a1..b50ebba7ef8c4217c865dd9cccf4bd79e76d3da6 100644 --- a/opentech/apply/categories/blocks.py +++ b/opentech/apply/categories/blocks.py @@ -77,11 +77,12 @@ class CategoryQuestionBlock(OptionalFormFieldBlock): def render(self, value, context): data = context['data'] category = value['category'] - context['data'] = category.options.filter(id__in=data).values_list('value', flat=True) + if data != self.no_response(): + context['data'] = category.options.filter(id__in=data).values_list('value', flat=True) return super().render(value, context) def get_searchable_content(self, value, data): return None def no_response(self): - return None + return ['No Response'] diff --git a/opentech/apply/categories/tests/test_blocks.py b/opentech/apply/categories/tests/test_blocks.py index fa8bee4ea1240337661588cc3ccbc5215c840076..979b4df24b1f67136d247612a6724e306df7f0f2 100644 --- a/opentech/apply/categories/tests/test_blocks.py +++ b/opentech/apply/categories/tests/test_blocks.py @@ -52,3 +52,9 @@ class TestCategoryQuestionBlock(TestCase): field.choices, [(option.id, option.value) for option in self.category.options.all()] ) + + def test_can_render_if_no_response(self): + context = self.block.get_context(None, {'data': None}) + self.assertEqual(context['data'], self.block.no_response()) + display = self.block.render({'category': self.category}, context) + self.assertIn(self.block.no_response()[0], display)