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

Add the optional header image to all pages

parent 9bff6e41
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-05 15:03
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('images', '0001_initial'),
('forms', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='formpage',
name='header_image',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='images.CustomImage'),
),
]
...@@ -2,7 +2,6 @@ from django.db import models ...@@ -2,7 +2,6 @@ from django.db import models
from modelcluster.fields import ParentalKey from modelcluster.fields import ParentalKey
from wagtail.wagtailcore.models import Page
from wagtail.wagtailcore.fields import RichTextField from wagtail.wagtailcore.fields import RichTextField
from wagtail.wagtailadmin.edit_handlers import ( from wagtail.wagtailadmin.edit_handlers import (
FieldPanel, FieldRowPanel, FieldPanel, FieldRowPanel,
...@@ -27,11 +26,11 @@ class FormPage(WagtailCaptchaEmailForm, BasePage): ...@@ -27,11 +26,11 @@ class FormPage(WagtailCaptchaEmailForm, BasePage):
thank_you_text = RichTextField(blank=True, help_text="Text displayed to the user on successful submission of the form") thank_you_text = RichTextField(blank=True, help_text="Text displayed to the user on successful submission of the form")
action_text = models.CharField(max_length=32, blank=True, help_text="Form action text. Defaults to \"Submit\"") action_text = models.CharField(max_length=32, blank=True, help_text="Form action text. Defaults to \"Submit\"")
search_fields = Page.search_fields + [ search_fields = BasePage.search_fields + [
index.SearchField('introduction'), index.SearchField('introduction'),
] ]
content_panels = Page.content_panels + [ content_panels = BasePage.content_panels + [
FieldPanel('introduction'), FieldPanel('introduction'),
InlinePanel('form_fields', label="Form fields"), InlinePanel('form_fields', label="Form fields"),
FieldPanel('action_text'), FieldPanel('action_text'),
......
# -*- coding: utf-8 -*-
# Generated by Django 1.11.8 on 2018-01-05 15:03
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('images', '0001_initial'),
('home', '0002_create_homepage'),
]
operations = [
migrations.AddField(
model_name='homepage',
name='header_image',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='images.CustomImage'),
),
]
from django.db import models from django.db import models
from wagtail.wagtailadmin.edit_handlers import FieldPanel from wagtail.wagtailadmin.edit_handlers import FieldPanel
from wagtail.wagtailcore.models import Page
from wagtail.wagtailsearch import index from wagtail.wagtailsearch import index
from wagtail.wagtailsnippets.edit_handlers import SnippetChooserPanel from wagtail.wagtailsnippets.edit_handlers import SnippetChooserPanel
...@@ -15,11 +14,11 @@ class HomePage(BasePage): ...@@ -15,11 +14,11 @@ class HomePage(BasePage):
strapline = models.CharField(blank=True, max_length=255) strapline = models.CharField(blank=True, max_length=255)
call_to_action = models.ForeignKey('utils.CallToActionSnippet', blank=True, null=True, on_delete=models.SET_NULL, related_name='+') call_to_action = models.ForeignKey('utils.CallToActionSnippet', blank=True, null=True, on_delete=models.SET_NULL, related_name='+')
search_fields = Page.search_fields + [ search_fields = BasePage.search_fields + [
index.SearchField('strapline'), index.SearchField('strapline'),
] ]
content_panels = Page.content_panels + [ content_panels = BasePage.content_panels + [
FieldPanel('strapline'), FieldPanel('strapline'),
SnippetChooserPanel('call_to_action'), SnippetChooserPanel('call_to_action'),
] ]
# -*- coding: utf-8 -*-
# Generated by Django 1.11.8 on 2018-01-05 15:03
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('images', '0001_initial'),
('news', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='newsindex',
name='header_image',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='images.CustomImage'),
),
migrations.AddField(
model_name='newspage',
name='header_image',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='images.CustomImage'),
),
]
...@@ -5,7 +5,6 @@ from django.core.paginator import EmptyPage, PageNotAnInteger, Paginator ...@@ -5,7 +5,6 @@ from django.core.paginator import EmptyPage, PageNotAnInteger, Paginator
from modelcluster.fields import ParentalKey from modelcluster.fields import ParentalKey
from wagtail.wagtailcore.models import Page
from wagtail.wagtailcore.fields import StreamField from wagtail.wagtailcore.fields import StreamField
from wagtail.wagtailadmin.edit_handlers import ( from wagtail.wagtailadmin.edit_handlers import (
StreamFieldPanel, FieldPanel, InlinePanel StreamFieldPanel, FieldPanel, InlinePanel
...@@ -62,12 +61,12 @@ class NewsPage(BasePage): ...@@ -62,12 +61,12 @@ class NewsPage(BasePage):
introduction = models.TextField(blank=True) introduction = models.TextField(blank=True)
body = StreamField(StoryBlock()) body = StreamField(StoryBlock())
search_fields = Page.search_fields + [ search_fields = BasePage.search_fields + [
index.SearchField('introduction'), index.SearchField('introduction'),
index.SearchField('body') index.SearchField('body')
] ]
content_panels = Page.content_panels + [ content_panels = BasePage.content_panels + [
FieldPanel('publication_date'), FieldPanel('publication_date'),
FieldPanel('introduction'), FieldPanel('introduction'),
StreamFieldPanel('body'), StreamFieldPanel('body'),
......
# -*- coding: utf-8 -*-
# Generated by Django 1.11.8 on 2018-01-05 15:03
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('images', '0001_initial'),
('people', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='personindexpage',
name='header_image',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='images.CustomImage'),
),
migrations.AddField(
model_name='personpage',
name='header_image',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='images.CustomImage'),
),
]
...@@ -5,7 +5,6 @@ from django.conf import settings ...@@ -5,7 +5,6 @@ from django.conf import settings
from modelcluster.fields import ParentalKey from modelcluster.fields import ParentalKey
from wagtail.wagtailcore.models import Page
from wagtail.wagtailcore.fields import StreamField from wagtail.wagtailcore.fields import StreamField
from wagtail.wagtailadmin.edit_handlers import ( from wagtail.wagtailadmin.edit_handlers import (
FieldPanel, FieldPanel,
...@@ -97,7 +96,7 @@ class PersonPage(BasePage): ...@@ -97,7 +96,7 @@ class PersonPage(BasePage):
biography = StreamField(StoryBlock(), blank=True) biography = StreamField(StoryBlock(), blank=True)
email = models.EmailField(blank=True) email = models.EmailField(blank=True)
content_panels = Page.content_panels + [ content_panels = BasePage.content_panels + [
MultiFieldPanel([ MultiFieldPanel([
FieldPanel('first_name'), FieldPanel('first_name'),
FieldPanel('last_name'), FieldPanel('last_name'),
......
# -*- coding: utf-8 -*-
# Generated by Django 1.11.8 on 2018-01-05 15:03
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('images', '0001_initial'),
('standardpages', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='indexpage',
name='header_image',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='images.CustomImage'),
),
migrations.AddField(
model_name='informationpage',
name='header_image',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='images.CustomImage'),
),
]
...@@ -9,7 +9,6 @@ from wagtail.wagtailadmin.edit_handlers import ( ...@@ -9,7 +9,6 @@ from wagtail.wagtailadmin.edit_handlers import (
) )
from wagtail.wagtailcore.fields import StreamField from wagtail.wagtailcore.fields import StreamField
from wagtail.wagtailcore.models import Page
from wagtail.wagtailsearch import index from wagtail.wagtailsearch import index
from opentech.utils.blocks import StoryBlock from opentech.utils.blocks import StoryBlock
...@@ -27,12 +26,12 @@ class InformationPage(BasePage): ...@@ -27,12 +26,12 @@ class InformationPage(BasePage):
introduction = models.TextField(blank=True) introduction = models.TextField(blank=True)
body = StreamField(StoryBlock()) body = StreamField(StoryBlock())
search_fields = Page.search_fields + [ search_fields = BasePage.search_fields + [
index.SearchField('introduction'), index.SearchField('introduction'),
index.SearchField('body'), index.SearchField('body'),
] ]
content_panels = Page.content_panels + [ content_panels = BasePage.content_panels + [
FieldPanel('introduction'), FieldPanel('introduction'),
StreamFieldPanel('body'), StreamFieldPanel('body'),
InlinePanel('related_pages', label="Related pages"), InlinePanel('related_pages', label="Related pages"),
...@@ -42,11 +41,11 @@ class InformationPage(BasePage): ...@@ -42,11 +41,11 @@ class InformationPage(BasePage):
class IndexPage(BasePage): class IndexPage(BasePage):
introduction = models.TextField(blank=True) introduction = models.TextField(blank=True)
content_panels = Page.content_panels + [ content_panels = BasePage.content_panels + [
FieldPanel('introduction'), FieldPanel('introduction'),
] ]
search_fields = Page.search_fields + [ search_fields = BasePage.search_fields + [
index.SearchField('introduction'), index.SearchField('introduction'),
] ]
......
...@@ -69,7 +69,8 @@ ...@@ -69,7 +69,8 @@
{% wagtailuserbar %} {% wagtailuserbar %}
{# {% if page.header_image %} #} {# {% if page.header_image %} #}
<!-- <header class="header header--standard header--has-bg-image" style="background-image:url('')"> --> {% image page.header_image original as header_image %}
<header class="header header--standard header--has-bg-image" style="background-image:url('{{ header_image.url }}')">
{# {% else %} #} {# {% else %} #}
<header class="header header--standard"> <header class="header header--standard">
{# {% endif %} #} {# {% endif %} #}
...@@ -167,4 +168,3 @@ ...@@ -167,4 +168,3 @@
{% block extra_js %}{% endblock %} {% block extra_js %}{% endblock %}
</body> </body>
</html> </html>
...@@ -239,9 +239,22 @@ class SystemMessagesSettings(BaseSetting): ...@@ -239,9 +239,22 @@ class SystemMessagesSettings(BaseSetting):
class BasePage(SocialFields, ListingFields, Page): class BasePage(SocialFields, ListingFields, Page):
show_in_menus_default = True show_in_menus_default = True
header_image = models.ForeignKey(
'images.CustomImage',
null=True,
blank=True,
on_delete=models.SET_NULL,
related_name='+'
)
class Meta: class Meta:
abstract = True abstract = True
content_panels = Page.content_panels + [
ImageChooserPanel('header_image')
]
promote_panels = ( promote_panels = (
Page.promote_panels + Page.promote_panels +
SocialFields.promote_panels + SocialFields.promote_panels +
......
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