From 1e55d2ad2fc6fe02d453032d83de78b0662dd385 Mon Sep 17 00:00:00 2001 From: Todd Dembrey <todd.dembrey@torchbox.com> Date: Fri, 16 Feb 2018 11:25:59 +0000 Subject: [PATCH] Add a non-response check to the data being rendered --- opentech/apply/funds/models.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/opentech/apply/funds/models.py b/opentech/apply/funds/models.py index 4f6e3c9a6..97cb1f4d2 100644 --- a/opentech/apply/funds/models.py +++ b/opentech/apply/funds/models.py @@ -497,7 +497,11 @@ class ApplicationSubmission(WorkflowHelpers, AbstractFormSubmission): return render_to_string(self.field_template, context) def prepare_value(self, field, data): + NO_RESPONSE = 'No response' if hasattr(field, 'choices'): + if not data: + return [NO_RESPONSE] + if isinstance(data, str): data = [data] choices = dict(field.choices) @@ -506,7 +510,11 @@ class ApplicationSubmission(WorkflowHelpers, AbstractFormSubmission): except KeyError: data = [choices[int(value)] for value in data if value] else: + if not data and not isinstance(data, bool): + return NO_RESPONSE + data = str(data) + return data def get_data(self): -- GitLab