Skip to content
Snippets Groups Projects
Commit 1fde8f8e authored by Todd Dembrey's avatar Todd Dembrey
Browse files

Make sure we render the category block in the event of no responses

parent fc6a6e3c
No related branches found
No related tags found
No related merge requests found
......@@ -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']
......@@ -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)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment