From 8062da344c6231073a56447b086d83ef5a2299de Mon Sep 17 00:00:00 2001 From: Todd Dembrey <todd.dembrey@torchbox.com> Date: Wed, 14 Feb 2018 15:55:54 +0000 Subject: [PATCH] Add the basic listing template to the apply homepage --- opentech/apply/funds/models.py | 8 ++++++ .../templates/apply_home/apply_home_page.html | 12 ++++++++- .../apply_home/includes/apply_listing.html | 24 +++++++++++++++++ .../public/funds/migrations/0001_initial.py | 2 +- .../funds/migrations/0002_labindex_labpage.py | 2 +- ..._optional.py => 0005_lab_link_optional.py} | 0 .../migrations/0006_fundindex_introduction.py | 2 +- .../migrations/0007_auto_20180214_1553.py | 26 +++++++++++++++++++ opentech/public/funds/models.py | 4 +-- 9 files changed, 74 insertions(+), 6 deletions(-) create mode 100644 opentech/apply/home/templates/apply_home/includes/apply_listing.html rename opentech/public/funds/migrations/{005_link_text_optional.py => 0005_lab_link_optional.py} (100%) create mode 100644 opentech/public/funds/migrations/0007_auto_20180214_1553.py diff --git a/opentech/apply/funds/models.py b/opentech/apply/funds/models.py index 2b2b7833b..7f115f117 100644 --- a/opentech/apply/funds/models.py +++ b/opentech/apply/funds/models.py @@ -176,6 +176,10 @@ class FundType(EmailForm, WorkflowStreamForm): # type: ignore parent_page_types = ['apply_home.ApplyHomePage'] subpage_types = ['funds.Round'] + def detail(self): + # The location to find out more information + return self.fund_public.first() + @property def open_round(self): rounds = Round.objects.child_of(self).live().public().specific() @@ -380,6 +384,10 @@ class LabType(EmailForm, WorkflowStreamForm, SubmittableStreamForm): # type: ig ObjectList(WorkflowStreamForm.promote_panels, heading='Promote'), ]) + def detail(self): + # The location to find out more information + return self.lab_public.first() + def get_submit_meta_data(self, **kwargs): return super().get_submit_meta_data( page=self, diff --git a/opentech/apply/home/templates/apply_home/apply_home_page.html b/opentech/apply/home/templates/apply_home/apply_home_page.html index df0e1750b..455a52f6c 100644 --- a/opentech/apply/home/templates/apply_home/apply_home_page.html +++ b/opentech/apply/home/templates/apply_home/apply_home_page.html @@ -6,5 +6,15 @@ {% block header_modifier %}header--light-bg{% endblock %} {% block content %} -{{ page.strapline }} +<div class="wrapper wrapper--small wrapper--top-bottom-inner-space"> + {% if page.strapline %} + <h4 class="heading heading--listings-introduction">{{ page.strapline }}</h4> + {% endif %} + + <div class="wrapper wrapper--listings"> + {% for child_page in page.get_children.public.live %} + {% include "apply_home/includes/apply_listing.html" with page=child_page %} + {% endfor %} + </div> +</div> {% endblock %} diff --git a/opentech/apply/home/templates/apply_home/includes/apply_listing.html b/opentech/apply/home/templates/apply_home/includes/apply_listing.html new file mode 100644 index 000000000..1b459f7a6 --- /dev/null +++ b/opentech/apply/home/templates/apply_home/includes/apply_listing.html @@ -0,0 +1,24 @@ +{% load wagtailcore_tags %} + +{% with details=page.specific.detail.specific %} +<div class="listing"> + <h4 class="listing__title"> + {# details may be None, so be more verbose in the handling of the title #} + {% if page.title %} + {{ page.title }} + {% else %} + {{ details.listing_title|default:details.title }} + {% endif %} + </h4> + + {% if details.listing_summary or details.introduction %} + <h6 class="listing__teaser">{{ details.listing_summary|default:details.introduction|truncatechars_html:155 }}</h6> + {% endif %} + + {% if details %} + <a href="{% pageurl details %}">More info...</a> + {% endif %} + + <a class="" href="{% pageurl page %}">Apply</a> +</div> +{% endwith %} diff --git a/opentech/public/funds/migrations/0001_initial.py b/opentech/public/funds/migrations/0001_initial.py index 5cab88a42..056aff4ce 100644 --- a/opentech/public/funds/migrations/0001_initial.py +++ b/opentech/public/funds/migrations/0001_initial.py @@ -48,7 +48,7 @@ class Migration(migrations.Migration): ('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))))), ('project_list', opentech.public.funds.blocks.ProjectsBlock()), ('reviewer_list', opentech.public.funds.blocks.ReviewersBlock())))), - ('fund_type', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='wagtailcore.Page')), + ('fund_type', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='fund_public', 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')), ('social_image', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='images.CustomImage')), diff --git a/opentech/public/funds/migrations/0002_labindex_labpage.py b/opentech/public/funds/migrations/0002_labindex_labpage.py index 3678f0f6e..09de0c4d5 100644 --- a/opentech/public/funds/migrations/0002_labindex_labpage.py +++ b/opentech/public/funds/migrations/0002_labindex_labpage.py @@ -51,7 +51,7 @@ class Migration(migrations.Migration): ('link_text', models.CharField(help_text='Text to display on the button', max_length=255)), ('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))))), ('reviewer_list', opentech.public.funds.blocks.ReviewersBlock())))), ('header_image', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='images.CustomImage')), - ('lab_type', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='wagtailcore.Page')), + ('lab_type', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='lab_public', to='wagtailcore.Page')), ('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')), ('social_image', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='images.CustomImage')), ], diff --git a/opentech/public/funds/migrations/005_link_text_optional.py b/opentech/public/funds/migrations/0005_lab_link_optional.py similarity index 100% rename from opentech/public/funds/migrations/005_link_text_optional.py rename to opentech/public/funds/migrations/0005_lab_link_optional.py diff --git a/opentech/public/funds/migrations/0006_fundindex_introduction.py b/opentech/public/funds/migrations/0006_fundindex_introduction.py index a6664aac3..8c3b62a68 100644 --- a/opentech/public/funds/migrations/0006_fundindex_introduction.py +++ b/opentech/public/funds/migrations/0006_fundindex_introduction.py @@ -8,7 +8,7 @@ from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ - ('public_funds', '005_link_text_optional'), + ('public_funds', '0005_link_text_optional'), ] operations = [ diff --git a/opentech/public/funds/migrations/0007_auto_20180214_1553.py b/opentech/public/funds/migrations/0007_auto_20180214_1553.py new file mode 100644 index 000000000..129c10361 --- /dev/null +++ b/opentech/public/funds/migrations/0007_auto_20180214_1553.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.8 on 2018-02-14 15:53 +from __future__ import unicode_literals + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('public_funds', '0006_fundindex_introduction'), + ] + + operations = [ + migrations.AlterField( + model_name='fundpage', + name='fund_type', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='fund_public', to='wagtailcore.Page'), + ), + migrations.AlterField( + model_name='labpage', + name='lab_type', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='lab_public', to='wagtailcore.Page'), + ), + ] diff --git a/opentech/public/funds/models.py b/opentech/public/funds/models.py index 2c505abac..21ff7eadc 100644 --- a/opentech/public/funds/models.py +++ b/opentech/public/funds/models.py @@ -37,7 +37,7 @@ class FundPage(BasePage): blank=True, null=True, on_delete=models.SET_NULL, - related_name='+', + related_name='fund_public', ) body = StreamField(FundBlock()) @@ -106,7 +106,7 @@ class LabPage(BasePage): blank=True, null=True, on_delete=models.SET_NULL, - related_name='+', + related_name='lab_public', ) lab_link = models.URLField(blank=True, verbose_name='External link') link_text = models.CharField(max_length=255, help_text='Text to display on the button for external links', blank=True) -- GitLab