diff --git a/opentech/apply/funds/models/mixins.py b/opentech/apply/funds/models/mixins.py index 00f253ddfd135175ade8977a6247b8bd80b1633b..6698ee2bcfe624495e573adfb402ae958133a8d3 100644 --- a/opentech/apply/funds/models/mixins.py +++ b/opentech/apply/funds/models/mixins.py @@ -4,7 +4,7 @@ from django.core.files import File from django.core.files.storage import get_storage_class from opentech.apply.stream_forms.blocks import ( - FileFieldBlock, FormFieldBlock, ImageFieldBlock, MultiFileFieldBlock + FileFieldBlock, FormFieldBlock, GroupToggleBlock, ImageFieldBlock, MultiFileFieldBlock ) from opentech.apply.utils.blocks import SingleIncludeMixin @@ -124,6 +124,14 @@ class AccessFormData: elif isinstance(field.block, FormFieldBlock): yield field_id + @property + def first_group_question_field_ids(self): + for field_id, field in self.fields.items(): + if isinstance(field.block, GroupToggleBlock): + break + elif isinstance(field.block, FormFieldBlock): + yield field_id + @property def raw_fields(self): # Field ids to field class mapping - similar to raw_data @@ -157,6 +165,14 @@ class AccessFormData: if field_id not in self.named_blocks ] + @property + def first_group_normal_blocks(self): + return [ + field_id + for field_id in self.first_group_question_field_ids + if field_id not in self.named_blocks + ] + def serialize(self, field_id): field = self.field(field_id) data = self.data(field_id) @@ -180,6 +196,12 @@ class AccessFormData: for field_id in self.normal_blocks ] + def render_first_group_answers(self): + return [ + self.render_answer(field_id, include_question=True) + for field_id in self.first_group_normal_blocks + ] + def render_text_blocks_answers(self): # Returns a list of the rendered answers of type text return [ @@ -191,3 +213,6 @@ class AccessFormData: def output_answers(self): # Returns a safe string of the rendered answers return mark_safe(''.join(self.render_answers())) + + def output_first_group_answers(self): + return mark_safe(''.join(self.render_first_group_answers())) diff --git a/opentech/public/funds/templates/public_funds/open_call_index_page.html b/opentech/public/funds/templates/public_funds/open_call_index_page.html index 16cd611da8f6a489221423eff08d9d5680fabee7..ac98b04e48d822fad9b6c945b5b42c657980c1b3 100644 --- a/opentech/public/funds/templates/public_funds/open_call_index_page.html +++ b/opentech/public/funds/templates/public_funds/open_call_index_page.html @@ -15,6 +15,19 @@ <h4 class="listing__title">{{ submission.title }}</h4> <a class="listing__button" href="{% pageurl submission.page %}">Build it</a> </div> + <div> + <div> + <h5>Project Duration</h5> + {{ submission.get_duration_display }} + </div> + <div> + <h5>Name</h5> + {{ submission.get_full_name_display }} + </div> + <div class="rich-text rich-text--answers"> + {{ submission.output_first_group_answers }} + </div> + </div> {% endfor %}