diff --git a/opentech/apply/funds/blocks.py b/opentech/apply/funds/blocks.py index 58d9944699f5d77353b0021efcf66ff88ec8523c..6957921214ef3ddac61583ddc9d3797b3411496a 100644 --- a/opentech/apply/funds/blocks.py +++ b/opentech/apply/funds/blocks.py @@ -80,6 +80,9 @@ class DurationBlock(ApplicationMustIncludeFieldBlock): field_kwargs['choices'] = self.DURATION_OPTIONS.items() return field_kwargs + def format_data(self, data): + return self.DURATION_OPTIONS[int(data)] + class Meta: icon = 'date' diff --git a/opentech/apply/stream_forms/blocks.py b/opentech/apply/stream_forms/blocks.py index 903f232283e80dfb22b0fa149d045c8c65b5f344..77692d430db347d4f637f0761c874160f43d6726 100644 --- a/opentech/apply/stream_forms/blocks.py +++ b/opentech/apply/stream_forms/blocks.py @@ -50,9 +50,20 @@ class FormFieldBlock(StructBlock): return self.get_field_class(struct_value)( **self.get_field_kwargs(struct_value)) + def get_context(self, value, parent_context): + context = super().get_context(value, parent_context) + parent_context['data'] = self.format_data(parent_context['data']) or self.no_response() + return context + def get_searchable_content(self, value, data): return str(data) + def format_data(self, data): + return data + + def no_responose(self): + return "No response" + class OptionalFormFieldBlock(FormFieldBlock): required = BooleanBlock(label=_('Required'), required=False) @@ -126,6 +137,9 @@ class CheckboxFieldBlock(FormFieldBlock): def get_searchable_content(self, value, data): return None + def no_responose(self): + return False + class RadioButtonsFieldBlock(OptionalFormFieldBlock): choices = ListBlock(CharBlock(label=_('Choice'))) diff --git a/opentech/apply/stream_forms/templates/stream_forms/render_field.html b/opentech/apply/stream_forms/templates/stream_forms/render_field.html index 049375a32c6fc5d22bf2a4516b101452ffbbb17c..668d58eac6c19249078b570df26afb5d2a71bc4c 100644 --- a/opentech/apply/stream_forms/templates/stream_forms/render_field.html +++ b/opentech/apply/stream_forms/templates/stream_forms/render_field.html @@ -1,4 +1,4 @@ <div> <h5>{{ value.field_label }}</h5> - <div>{% block data_display %}{{ data|default:"No response" }}{% endblock %}</div> + <div>{% block data_display %}{{ data }}{% endblock %}</div> </div>