Skip to content
Snippets Groups Projects
Commit 196b603e authored by Todd Dembrey's avatar Todd Dembrey
Browse files

Update the lab templates

parent df923461
No related branches found
No related tags found
No related merge requests found
# -*- coding: utf-8 -*-
# Generated by Django 1.11.8 on 2018-01-11 14:09
# Generated by Django 1.11.8 on 2018-01-11 14:47
from __future__ import unicode_literals
from django.db import migrations, models
......@@ -16,8 +16,8 @@ import wagtail.wagtailsnippets.blocks
class Migration(migrations.Migration):
dependencies = [
('wagtailcore', '0040_page_draft_title'),
('images', '0001_initial'),
('wagtailcore', '0040_page_draft_title'),
('public_funds', '0001_initial'),
]
......@@ -47,7 +47,8 @@ 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)),
('lab_link', models.URLField()),
('lab_link', models.URLField(blank=True, verbose_name='External link')),
('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))))), ('project_list', opentech.public.funds.blocks.ProjectsBlock()), ('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')),
......
......@@ -48,14 +48,14 @@ class FundIndex(BasePage):
page = request.GET.get('page', 1)
paginator = Paginator(funds, settings.DEFAULT_PER_PAGE)
try:
news = paginator.page(page)
funds = paginator.page(page)
except PageNotAnInteger:
news = paginator.page(1)
funds = paginator.page(1)
except EmptyPage:
news = paginator.page(paginator.num_pages)
funds = paginator.page(paginator.num_pages)
context = super().get_context(request, *args, **kwargs)
context.update(news=news)
context.update(subpages=funds)
return context
......@@ -64,6 +64,13 @@ class LabPage(BasePage):
parent_page_types = ['LabIndex']
introduction = models.TextField(blank=True)
icon = models.ForeignKey(
'images.CustomImage',
null=True,
blank=True,
related_name='+',
on_delete=models.SET_NULL
)
lab_type = models.ForeignKey(
'wagtailcore.Page',
blank=True,
......@@ -71,19 +78,26 @@ class LabPage(BasePage):
on_delete=models.SET_NULL,
related_name='+',
)
lab_link = models.URLField(blank=True, verbose_name="External link")
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')
body = StreamField(FundBlock())
content_panels = BasePage.content_panels + [
FieldPanel('icon'),
FieldPanel('introduction'),
MultiFieldPanel([
# Limit to lab pages once created
PageChooserPanel('lab_type'),
FieldPanel('lab_link'),
FieldPanel('link_text'),
], heading='Link for lab application'),
StreamFieldPanel('body'),
]
@property
def link_to_lab(self):
return self.lab_link or self.lab_type.get_url()
def clean(self):
if self.lab_type and self.lab_link:
raise ValidationError({
......@@ -109,18 +123,18 @@ class LabIndex(BasePage):
]
def get_context(self, request, *args, **kwargs):
funds = LabPage.objects.live().public().descendant_of(self)
labs = LabPage.objects.live().public().descendant_of(self)
# Pagination
page = request.GET.get('page', 1)
paginator = Paginator(funds, settings.DEFAULT_PER_PAGE)
paginator = Paginator(labs, settings.DEFAULT_PER_PAGE)
try:
news = paginator.page(page)
labs = paginator.page(page)
except PageNotAnInteger:
news = paginator.page(1)
labs = paginator.page(1)
except EmptyPage:
news = paginator.page(paginator.num_pages)
labs = paginator.page(paginator.num_pages)
context = super().get_context(request, *args, **kwargs)
context.update(news=news)
context.update(subpages=labs)
return context
{% extends "standardpages/index_page.html" %}
{% extends "base.html" %}
{% load wagtailcore_tags wagtailimages_tags navigation_tags static %}
{% block content %}
<div class="wrapper wrapper--flex">
<section class="section section--main">
<h1>{{ page.icon }}{{ page.title }}</h1>
<h5>{{ page.introduction }}</h5>
{% include_block page.body %}
</section>
<section>
<a href="{{ page.link_to_lab }}">{{ page.link_text }}</a>
</section>
</div>
{% include "includes/relatedcontent.html" with related_pages=page.related_pages.all %}
{% endblock %}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment