Skip to content

Commit

Permalink
Initiatives Page (#1674)
Browse files Browse the repository at this point in the history
This is a build of just the new Initiatives page.

Related : #1648
  • Loading branch information
gvn committed Jul 31, 2018
1 parent defb142 commit e84214b
Show file tree
Hide file tree
Showing 11 changed files with 299 additions and 134 deletions.
1 change: 1 addition & 0 deletions network-api/networkapi/settings.py
Expand Up @@ -264,6 +264,7 @@
'settings_value': 'networkapi.utility.templatetags.settings_value',
'mini_site_tags': 'networkapi.wagtailpages.templatetags.mini_site_tags',
'homepage_tags': 'networkapi.wagtailpages.templatetags.homepage_tags',
'card_tags': 'networkapi.wagtailpages.templatetags.card_tags',
'primary_page_tags': 'networkapi.wagtailpages.templatetags.primary_page_tags',
}
},
Expand Down
@@ -0,0 +1,77 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.14 on 2018-07-27 18:51
from __future__ import unicode_literals

from django.db import migrations, models
import django.db.models.deletion
import modelcluster.fields


class Migration(migrations.Migration):

dependencies = [
('highlights', '0007_nullify_homepage'),
('wagtailimages', '0020_add-verbose-name'),
('wagtailpages', '0033_donationmodal_donationmodals'),
]

operations = [
migrations.CreateModel(
name='InitiativeSection',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('sectionHeader', models.CharField(max_length=250, verbose_name='Header')),
('sectionCopy', models.TextField(verbose_name='Subheader')),
('sectionButtonTitle', models.CharField(max_length=250, verbose_name='Button Text')),
('sectionButtonURL', models.TextField(verbose_name='Button URL')),
],
),
migrations.CreateModel(
name='InitiativesHighlights',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('sort_order', models.IntegerField(blank=True, editable=False, null=True)),
('highlight', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='+', to='highlights.Highlight')),
],
options={
'verbose_name': 'highlight',
'verbose_name_plural': 'highlights',
'ordering': ['sort_order'],
},
),
migrations.AddField(
model_name='initiativespage',
name='h3',
field=models.TextField(blank=True),
),
migrations.AddField(
model_name='initiativespage',
name='primaryHero',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='primary_hero', to='wagtailimages.Image', verbose_name='Primary Hero Image'),
),
migrations.AddField(
model_name='initiativespage',
name='sub_h3',
field=models.TextField(blank=True),
),
migrations.AddField(
model_name='initiativespage',
name='subheader',
field=models.TextField(blank=True),
),
migrations.AddField(
model_name='initiativeshighlights',
name='page',
field=modelcluster.fields.ParentalKey(on_delete=django.db.models.deletion.CASCADE, related_name='featured_highlights', to='wagtailpages.InitiativesPage'),
),
migrations.AddField(
model_name='initiativesection',
name='page',
field=modelcluster.fields.ParentalKey(on_delete=django.db.models.deletion.CASCADE, related_name='initiative_sections', to='wagtailpages.InitiativesPage'),
),
migrations.AddField(
model_name='initiativesection',
name='sectionImage',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='section_image', to='wagtailimages.Image', verbose_name='Hero Image'),
),
]
92 changes: 92 additions & 0 deletions network-api/networkapi/wagtailpages/models.py
Expand Up @@ -410,6 +410,48 @@ class NewsPage(PrimaryPage):
template = 'wagtailpages/static/news_page.html'


class InitiativeSection(models.Model):
page = ParentalKey(
'wagtailpages.InitiativesPage',
related_name='initiative_sections',
)

sectionImage = models.ForeignKey(
'wagtailimages.Image',
null=True,
blank=True,
on_delete=models.SET_NULL,
related_name='section_image',
verbose_name='Hero Image',
)

sectionHeader = models.CharField(
verbose_name='Header',
max_length=250,
)

sectionCopy = models.TextField(
verbose_name='Subheader',
)

sectionButtonTitle = models.CharField(
verbose_name='Button Text',
max_length=250,
)

sectionButtonURL = models.TextField(
verbose_name='Button URL',
)

panels = [
ImageChooserPanel('sectionImage'),
FieldPanel('sectionHeader'),
FieldPanel('sectionCopy'),
FieldPanel('sectionButtonTitle'),
FieldPanel('sectionButtonURL'),
]


class InitiativesPage(PrimaryPage):
parent_page_types = ['Homepage']
template = 'wagtailpages/static/initiatives_page.html'
Expand All @@ -420,6 +462,37 @@ class InitiativesPage(PrimaryPage):
'OpportunityPage',
]

primaryHero = models.ForeignKey(
'wagtailimages.Image',
null=True,
blank=True,
on_delete=models.SET_NULL,
related_name='primary_hero',
verbose_name='Primary Hero Image',
)

subheader = models.TextField(
blank=True,
)

h3 = models.TextField(
blank=True,
)

sub_h3 = models.TextField(
blank=True,
)

content_panels = Page.content_panels + [
ImageChooserPanel('primaryHero'),
FieldPanel('header'),
FieldPanel('subheader'),
FieldPanel('h3'),
FieldPanel('sub_h3'),
InlinePanel('initiative_sections', label="Initiatives"),
InlinePanel('featured_highlights', label='Highlights', max_num=9),
]


class ParticipatePage(PrimaryPage):
parent_page_types = ['Homepage']
Expand Down Expand Up @@ -477,6 +550,25 @@ def __str__(self):
return self.page.title + '->' + self.highlight.title


class InitiativesHighlights(WagtailOrderable, models.Model):
page = ParentalKey(
'wagtailpages.InitiativesPage',
related_name='featured_highlights',
)
highlight = models.ForeignKey('highlights.Highlight', related_name='+')
panels = [
SnippetChooserPanel('highlight'),
]

class Meta:
verbose_name = 'highlight'
verbose_name_plural = 'highlights'
ordering = ['sort_order'] # not automatically inherited!

def __str__(self):
return self.page.title + '->' + self.highlight.title


class Homepage(MetadataPageMixin, Page):
hero_headline = models.CharField(
max_length=140,
Expand Down
@@ -1,5 +1,5 @@
{% extends "pages/base.html" %}
{% load wagtailcore_tags wagtailimages_tags homepage_tags wagtailmetadata_tags %}
{% load wagtailcore_tags wagtailimages_tags homepage_tags card_tags wagtailmetadata_tags %}

{% block bodyID %}home{% endblock %}

Expand Down Expand Up @@ -103,18 +103,10 @@ <h4 class="h2-heading">Happening now</h4>
{% for highlight in page.featured_highlights.all %}
{% if forloop.counter <= 2 %}
<div class="col-md-6">
<div class="pb-5">
{% homepage_image_with_class highlight.highlight.image "full-bleed-xs" %}
<div class="full-bleed-xs">
<div class="key-item mx-2 mx-md-4 p-3">
<h5 class="h4-heading mb-2">{{highlight.highlight.title}}</h5>
<p>{{highlight.highlight.description}}</p>
<a class="cta-link mb-2" href="{{highlight.highlight.link_url}}">{{highlight.highlight.link_label}}</a>
</div>
</div>
</div>
</div>
{% card "md_width" highlight.highlight.image.url highlight.highlight.title highlight.highlight.description highlight.highlight.link_url highlight.highlight.link_label %}
</div>
{% endif %} {% endfor %}
</div>
</div>
{% for highlight in page.featured_highlights.all %} {% if forloop.counter > 2 %}
<div class="row my-3">
Expand Down

0 comments on commit e84214b

Please sign in to comment.