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

Allow non responded named fields to be rendered

parent 461ec88c
No related branches found
No related tags found
No related merge requests found
...@@ -36,8 +36,13 @@ class AccessFormData: ...@@ -36,8 +36,13 @@ class AccessFormData:
data = self.form_data.copy() data = self.form_data.copy()
for field_name, field_id in self.named_blocks.items(): for field_name, field_id in self.named_blocks.items():
if field_id not in data: if field_id not in data:
response = data[field_name] try:
data[field_id] = response response = data[field_name]
except KeyError:
# There was no value supplied for the named field
pass
else:
data[field_id] = response
return data return data
@classmethod @classmethod
......
...@@ -468,6 +468,13 @@ class TestSubmissionRenderMethods(TestCase): ...@@ -468,6 +468,13 @@ class TestSubmissionRenderMethods(TestCase):
answers = submission.render_answers() answers = submission.render_answers()
self.assertNotIn(rich_text_label, answers) self.assertNotIn(rich_text_label, answers)
def test_named_blocks_dont_break_if_no_response(self):
submission = ApplicationSubmissionFactory()
# the user didn't respond
del submission.form_data['value']
self.assertTrue('value' not in submission.raw_data)
self.assertTrue('duration' in submission.raw_data)
class TestRequestForPartners(TestCase): class TestRequestForPartners(TestCase):
def test_message_when_no_round(self): def test_message_when_no_round(self):
......
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