diff --git a/opentech/apply/funds/models.py b/opentech/apply/funds/models.py index 2b2b7833b703650237f1941fdb645713ef68f0f0..7f115f11779149f3164c3bbc621d68ca28cda2ae 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 new file mode 100644 index 0000000000000000000000000000000000000000..455a52f6c236b9b0045267e248b2d2815f0cbb7f --- /dev/null +++ b/opentech/apply/home/templates/apply_home/apply_home_page.html @@ -0,0 +1,20 @@ +{% extends "base.html" %} + +{% load wagtailcore_tags static i18n %} +{# Dont include fixed apply button on this page #} +{% block apply_button %}{% endblock %} +{% block header_modifier %}header--light-bg{% endblock %} + +{% block content %} +<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 0000000000000000000000000000000000000000..1b459f7a6c280fa3be761df5b1f53f5307aed3be --- /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 5cab88a42287d90cf2fffadd5b55930b9aa7fbfc..056aff4ce603d4bce56ad6f1a88da87c66a6b723 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 3678f0f6e941f63daab2ef611b81b3ad00452e5c..09de0c4d5c53bdb4533702d65521e3c47f6ada83 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_link_text_optional.py similarity index 100% rename from opentech/public/funds/migrations/005_link_text_optional.py rename to opentech/public/funds/migrations/0005_link_text_optional.py diff --git a/opentech/public/funds/migrations/0006_fundindex_introduction.py b/opentech/public/funds/migrations/0006_fundindex_introduction.py index a6664aac3ee87756de405867fa70cd262f00092b..8c3b62a68fc2514241b2529e5a018b3da1d53047 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/models.py b/opentech/public/funds/models.py index 2c505abac30df5f85f46c8b61aa8465693712096..21ff7eadcc1d02df66f55ef56b59653ed95fa775 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) diff --git a/opentech/public/utils/context_processors.py b/opentech/public/utils/context_processors.py index 25bc4c7cdda11f6dfedc5f39f4f2f9f40745ba29..330053296b778a10ef308e74095f8bf0c2efe668 100644 --- a/opentech/public/utils/context_processors.py +++ b/opentech/public/utils/context_processors.py @@ -1,7 +1,10 @@ from django.conf import settings +from opentech.apply.home.models import ApplyHomePage + def global_vars(request): return { 'GOOGLE_TAG_MANAGER_ID': getattr(settings, 'GOOGLE_TAG_MANAGER_ID', None), + 'APPLY_SITE': ApplyHomePage.objects.first(), } diff --git a/opentech/templates/includes/apply_button.html b/opentech/templates/includes/apply_button.html index 477d0ed9074b8da8a2115754fa573c5c193c4ade..53c5218e43f4e15d8f2b5b2387eb1ac1b24ef27c 100644 --- a/opentech/templates/includes/apply_button.html +++ b/opentech/templates/includes/apply_button.html @@ -1 +1,2 @@ -<a href="#" class="link link--fixed-apply">Apply</a> +{% load wagtailcore_tags %} +<a href="{% pageurl APPLY_SITE %}" class="link link--fixed-apply">Apply</a>