diff --git a/opentech/people/templates/people/includes/person_listing.html b/opentech/people/templates/people/includes/person_listing.html new file mode 100644 index 0000000000000000000000000000000000000000..9ec5a19cbe6311e9c0e4bb839555fb5ea021c83e --- /dev/null +++ b/opentech/people/templates/people/includes/person_listing.html @@ -0,0 +1,7 @@ +<article class="person"> + <h2><a href="{% pageurl person %}">{{ person.first_name }} {{ person.last_name }}</a></h2> + + {% if person.listing_summary or person.introduction %} + <p>{{ person.listing_summary|default:person.introduction }}</p> + {% endif %} +</article> diff --git a/opentech/public/people/templates/people/person_index_page.html b/opentech/public/people/templates/people/person_index_page.html index 873be5204e224b625139572257f885dca388005e..7d5f4d3a2c2ac5fb60f06e5e1ac632e0eb7012b4 100644 --- a/opentech/public/people/templates/people/person_index_page.html +++ b/opentech/public/people/templates/people/person_index_page.html @@ -13,13 +13,7 @@ <div class="container"> {% if people.paginator.count %} {% for person in people %} - <article class="person"> - <h2><a href="{% pageurl person %}">{{ person.first_name }} {{ person.last_name }}</a></h2> - - {% if person.listing_summary or person.introduction %} - <p>{{ person.listing_summary|default:person.introduction }}</p> - {% endif %} - </article> + {% include "people/includes/person_listing.html" with person=person %} {% endfor %} {% include "includes/pagination.html" with paginator_page=people %} diff --git a/opentech/publicpages/blocks.py b/opentech/publicpages/blocks.py new file mode 100644 index 0000000000000000000000000000000000000000..556a0090c98a9a0adb594aa2fc1fac1f343bd4ac --- /dev/null +++ b/opentech/publicpages/blocks.py @@ -0,0 +1,22 @@ +from wagtail.wagtailcore.blocks import StaticBlock + +from opentech.utils.blocks import StoryBlock + + +class ProjectsBlock(StaticBlock): + class Meta: + icon = 'grip' + label = 'List of Projects funded' + template = 'publicpages/blocks/related_projects.html' + + +class ReviewersBlock(StaticBlock): + class Meta: + icon = 'grip' + label = 'List of fund Reviewers' + template = 'publicpages/blocks/related_reviewers.html' + + +class FundBlock(StoryBlock): + project_list = ProjectsBlock() + reviewer_list = ReviewersBlock() diff --git a/opentech/publicpages/migrations/0001_initial.py b/opentech/publicpages/migrations/0001_initial.py index de11954b9a6e54c9fd8101cb9244c6cd4321089a..b630540646676927296e2764497f458db03b47fd 100644 --- a/opentech/publicpages/migrations/0001_initial.py +++ b/opentech/publicpages/migrations/0001_initial.py @@ -11,6 +11,7 @@ import wagtail.wagtailembeds.blocks import wagtail.wagtailimages.blocks import wagtail.wagtailsnippets.blocks +import opentech class Migration(migrations.Migration): @@ -46,7 +47,7 @@ class Migration(migrations.Migration): ('listing_title', models.CharField(blank=True, help_text='Override the page title used when this page appears in listings', max_length=255)), ('listing_summary', models.CharField(blank=True, help_text="The text summary used when this page appears in listings. It's also used as the description for search engines if the 'Search description' field above is not defined.", max_length=255)), ('introduction', models.TextField(blank=True)), - ('body', wagtail.wagtailcore.fields.StreamField((('heading', wagtail.wagtailcore.blocks.CharBlock(classname='full title', icon='title')), ('paragraph', wagtail.wagtailcore.blocks.RichTextBlock()), ('image', wagtail.wagtailcore.blocks.StructBlock((('image', wagtail.wagtailimages.blocks.ImageChooserBlock()), ('caption', wagtail.wagtailcore.blocks.CharBlock(required=False))))), ('quote', wagtail.wagtailcore.blocks.StructBlock((('quote', wagtail.wagtailcore.blocks.CharBlock(classname='title')), ('attribution', wagtail.wagtailcore.blocks.CharBlock(required=False)), ('job_title', wagtail.wagtailcore.blocks.CharBlock(required=False))))), ('embed', wagtail.wagtailembeds.blocks.EmbedBlock()), ('call_to_action', wagtail.wagtailsnippets.blocks.SnippetChooserBlock('utils.CallToActionSnippet', template='blocks/call_to_action_block.html')), ('document', wagtail.wagtailcore.blocks.StructBlock((('document', wagtail.wagtaildocs.blocks.DocumentChooserBlock()), ('title', wagtail.wagtailcore.blocks.CharBlock(required=False)))))))), + ('body', wagtail.wagtailcore.fields.StreamField((('heading', wagtail.wagtailcore.blocks.CharBlock(classname='full title', icon='title')), ('paragraph', wagtail.wagtailcore.blocks.RichTextBlock()), ('image', wagtail.wagtailcore.blocks.StructBlock((('image', wagtail.wagtailimages.blocks.ImageChooserBlock()), ('caption', wagtail.wagtailcore.blocks.CharBlock(required=False))))), ('quote', wagtail.wagtailcore.blocks.StructBlock((('quote', wagtail.wagtailcore.blocks.CharBlock(classname='title')), ('attribution', wagtail.wagtailcore.blocks.CharBlock(required=False)), ('job_title', wagtail.wagtailcore.blocks.CharBlock(required=False))))), ('embed', wagtail.wagtailembeds.blocks.EmbedBlock()), ('call_to_action', wagtail.wagtailsnippets.blocks.SnippetChooserBlock('utils.CallToActionSnippet', template='blocks/call_to_action_block.html')), ('document', wagtail.wagtailcore.blocks.StructBlock((('document', wagtail.wagtaildocs.blocks.DocumentChooserBlock()), ('title', wagtail.wagtailcore.blocks.CharBlock(required=False))))), ('project_list', opentech.publicpages.blocks.ProjectsBlock()), ('reviewer_list', opentech.publicpages.blocks.ReviewersBlock())))), ('fund_type', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='wagtailcore.Page')), ('header_image', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='images.CustomImage')), ('listing_image', models.ForeignKey(blank=True, help_text='Choose the image you wish to be displayed when this page appears in listings', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='images.CustomImage')), diff --git a/opentech/publicpages/models.py b/opentech/publicpages/models.py index 65aaab64e53963da415cae20c0cabf89ab6fbb17..0702a6af48e04bcafa9550e3d9f4ce29c46ffec4 100644 --- a/opentech/publicpages/models.py +++ b/opentech/publicpages/models.py @@ -10,9 +10,10 @@ from wagtail.wagtailadmin.edit_handlers import ( ) from wagtail.wagtailcore.fields import StreamField -from opentech.utils.blocks import StoryBlock from opentech.utils.models import BasePage +from .blocks import FundBlock + class FundPage(BasePage): subpage_types = [] @@ -26,7 +27,7 @@ class FundPage(BasePage): on_delete=models.SET_NULL, related_name='+', ) - body = StreamField(StoryBlock()) + body = StreamField(FundBlock()) content_panels = BasePage.content_panels + [ FieldPanel('introduction'), diff --git a/opentech/publicpages/templates/publicpages/blocks/related_projects.html b/opentech/publicpages/templates/publicpages/blocks/related_projects.html new file mode 100644 index 0000000000000000000000000000000000000000..692e68dbbe4d49dd6d91d729ce479f260b5ccd06 --- /dev/null +++ b/opentech/publicpages/templates/publicpages/blocks/related_projects.html @@ -0,0 +1,3 @@ +{% for project in page.projects %} + {% include "publicpages/includes/project_listing.html" with project=project %} +{% endfor %} diff --git a/opentech/publicpages/templates/publicpages/blocks/related_reviewers.html b/opentech/publicpages/templates/publicpages/blocks/related_reviewers.html new file mode 100644 index 0000000000000000000000000000000000000000..fbb24ea53fcda8740a0a674ee0eac2823d5dd179 --- /dev/null +++ b/opentech/publicpages/templates/publicpages/blocks/related_reviewers.html @@ -0,0 +1,3 @@ +{% for person in page.reviewers %} + {% include "person/includes/person_listing.html" with person=person %} +{% endfor %} diff --git a/opentech/publicpages/templates/publicpages/includes/project_listing.html b/opentech/publicpages/templates/publicpages/includes/project_listing.html new file mode 100644 index 0000000000000000000000000000000000000000..0ff5422e2a71c5442863900d835cfbc15ba70eae --- /dev/null +++ b/opentech/publicpages/templates/publicpages/includes/project_listing.html @@ -0,0 +1 @@ +<p>A PROJECT</p> diff --git a/opentech/templates/blocks/stream_block.html b/opentech/templates/blocks/stream_block.html index aa12d231f21b0b23a618942e32b387c21f10572e..2341b05106d47c549891d7f02bd7daae9d6f879a 100644 --- a/opentech/templates/blocks/stream_block.html +++ b/opentech/templates/blocks/stream_block.html @@ -1,7 +1,8 @@ +{% load wagtailcore_tags %} {% for block in value %} {% if block.block_type == 'heading' %} <h2>{{ block.value }}</h2> {% else %} - {{ block }} + {% include_block block %} {% endif %} {% endfor %}