diff --git a/network-api/networkapi/wagtailpages/migrations/0071_indexpage.py b/network-api/networkapi/wagtailpages/migrations/0071_indexpage.py new file mode 100644 index 00000000000..37e0f428294 --- /dev/null +++ b/network-api/networkapi/wagtailpages/migrations/0071_indexpage.py @@ -0,0 +1,42 @@ +# Generated by Django 2.2.3 on 2019-07-24 22:15 + +from django.db import migrations, models +import django.db.models.deletion +import wagtailmetadata.models + + +class Migration(migrations.Migration): + + dependencies = [ + ('wagtailcore', '0041_group_collection_permissions_verbose_name_plural'), + ('wagtailimages', '0001_squashed_0021'), + ('wagtailpages', '0070_auto_20190716_1200'), + ] + + operations = [ + migrations.CreateModel( + name='IndexPage', + fields=[ + ('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='wagtailcore.Page')), + ('header', models.CharField(blank=True, max_length=250)), + ('header_en', models.CharField(blank=True, max_length=250, null=True)), + ('header_de', models.CharField(blank=True, max_length=250, null=True)), + ('header_pt', models.CharField(blank=True, max_length=250, null=True)), + ('header_es', models.CharField(blank=True, max_length=250, null=True)), + ('header_fr', models.CharField(blank=True, max_length=250, null=True)), + ('header_pl', models.CharField(blank=True, max_length=250, null=True)), + ('intro', models.CharField(blank=True, help_text='Intro paragraph to show in hero cutout box', max_length=250)), + ('intro_en', models.CharField(blank=True, help_text='Intro paragraph to show in hero cutout box', max_length=250, null=True)), + ('intro_de', models.CharField(blank=True, help_text='Intro paragraph to show in hero cutout box', max_length=250, null=True)), + ('intro_pt', models.CharField(blank=True, help_text='Intro paragraph to show in hero cutout box', max_length=250, null=True)), + ('intro_es', models.CharField(blank=True, help_text='Intro paragraph to show in hero cutout box', max_length=250, null=True)), + ('intro_fr', models.CharField(blank=True, help_text='Intro paragraph to show in hero cutout box', max_length=250, null=True)), + ('intro_pl', models.CharField(blank=True, help_text='Intro paragraph to show in hero cutout box', max_length=250, null=True)), + ('search_image', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='wagtailimages.Image', verbose_name='Search image')), + ], + options={ + 'abstract': False, + }, + bases=(wagtailmetadata.models.MetadataMixin, 'wagtailcore.page', models.Model), + ), + ] diff --git a/network-api/networkapi/wagtailpages/models.py b/network-api/networkapi/wagtailpages/models.py index 21514394dc6..fce24f22e07 100644 --- a/network-api/networkapi/wagtailpages/models.py +++ b/network-api/networkapi/wagtailpages/models.py @@ -1,4 +1,5 @@ import json + from django.db import models from django.conf import settings from django.http import HttpResponseRedirect @@ -531,6 +532,37 @@ def get_context(self, request): return get_page_tree_information(self, context) +class IndexPage(FoundationMetadataPageMixin, Page): + """ + This is a page type for creating "index" pages that + can show cards for all their child content. + E.g. a page that list "all blog posts" under it, + or "all the various campaigns", etc. + """ + + header = models.CharField( + max_length=250, + blank=True + ) + + intro = models.CharField( + max_length=250, + blank=True, + help_text='Intro paragraph to show in hero cutout box' + ) + + content_panels = Page.content_panels + [ + FieldPanel('header'), + FieldPanel('intro'), + ] + + def get_context(self, request): + context = super().get_context(request) + context = set_main_site_nav_information(self, context, 'Homepage') + context = get_page_tree_information(self, context) + return context + + class NewsPage(PrimaryPage): parent_page_types = ['Homepage'] template = 'wagtailpages/static/news_page.html' @@ -1085,6 +1117,7 @@ class Homepage(FoundationMetadataPageMixin, Page): 'RedirectingPage', 'OpportunityPage', 'BanneredCampaignPage', + 'IndexPage', ] def get_context(self, request): diff --git a/network-api/networkapi/wagtailpages/templates/wagtailpages/fragments/blog-card.html b/network-api/networkapi/wagtailpages/templates/wagtailpages/fragments/blog-card.html new file mode 100644 index 00000000000..5d499ccbb29 --- /dev/null +++ b/network-api/networkapi/wagtailpages/templates/wagtailpages/fragments/blog-card.html @@ -0,0 +1,15 @@ +{% extends "./generic-card.html" %} + +{% load wagtailcore_tags %} + +{% block tags-DISABLED-FOR-NOW %} +
+ {% with tag=page.specific.tags.first %} + {{ tag }} + {% endwith %} +
+{% endblock %} + +{% block byline %} +By {{ page.specific.author }} on {{ page.first_published_at|date:"F j, Y" }} +{% endblock%} diff --git a/network-api/networkapi/wagtailpages/templates/wagtailpages/fragments/blog-cards.html b/network-api/networkapi/wagtailpages/templates/wagtailpages/fragments/blog-cards.html new file mode 100644 index 00000000000..d306ba65b10 --- /dev/null +++ b/network-api/networkapi/wagtailpages/templates/wagtailpages/fragments/blog-cards.html @@ -0,0 +1,5 @@ +{% load wagtailcore_tags %} + +{% for page in entries %} +{% include "./blog-card.html" %} +{% endfor %} diff --git a/network-api/networkapi/wagtailpages/templates/wagtailpages/fragments/generic-card.html b/network-api/networkapi/wagtailpages/templates/wagtailpages/fragments/generic-card.html new file mode 100644 index 00000000000..3da529b0131 --- /dev/null +++ b/network-api/networkapi/wagtailpages/templates/wagtailpages/fragments/generic-card.html @@ -0,0 +1,14 @@ +{% load wagtailcore_tags wagtailimages_tags %} + +
+
+ + {% image page.specific.get_meta_image fill-400x225 %} + +
+ {% block tags %}{% endblock %} + {{ page.title }} +

+ {% block byline %}{% endblock %} +

+
diff --git a/network-api/networkapi/wagtailpages/templates/wagtailpages/fragments/related_posts.html b/network-api/networkapi/wagtailpages/templates/wagtailpages/fragments/related_posts.html index 3fce9498751..9a850d7e74f 100644 --- a/network-api/networkapi/wagtailpages/templates/wagtailpages/fragments/related_posts.html +++ b/network-api/networkapi/wagtailpages/templates/wagtailpages/fragments/related_posts.html @@ -9,17 +9,7 @@

Related content

diff --git a/network-api/networkapi/wagtailpages/templates/wagtailpages/index_page.html b/network-api/networkapi/wagtailpages/templates/wagtailpages/index_page.html new file mode 100644 index 00000000000..e233aa0197e --- /dev/null +++ b/network-api/networkapi/wagtailpages/templates/wagtailpages/index_page.html @@ -0,0 +1,39 @@ +{% extends "./modular_page.html" %} + +{% load wagtailcore_tags mini_site_tags %} + + +{% block content %} +
+
+
+

+ {% if root.title %}{{ root.title }}{% elif page.header %}{{ page.header }}{% else %}{{ page.title }}{% endif %} +

+

{{ page.intro }}

+
+
+ +
+
+
+
+
+ +
+ {% block subcontent %} + + {% for entry in page.get_children.live %} + {% with type=entry.specific_class.get_verbose_name|lower %} + {% if type == "blog page" %} + {% include "./fragments/blog-card.html" with page=entry %} + {% else %} + {% include "./fragments/generic-card.html" with page=entry %} + {% endif %} + {% endwith %} + {% endfor %} + + {% endblock %} +
+
+{% endblock %} diff --git a/network-api/networkapi/wagtailpages/translation.py b/network-api/networkapi/wagtailpages/translation.py index 1813f0915ee..453970bfe64 100644 --- a/network-api/networkapi/wagtailpages/translation.py +++ b/network-api/networkapi/wagtailpages/translation.py @@ -2,6 +2,7 @@ ModularPage, MiniSiteNameSpace, PrimaryPage, + IndexPage, NewsPage, InitiativesPage, ParticipatePage2, @@ -107,6 +108,14 @@ class BanneredCampaignPageTR(TranslationOptions): ) +@register(IndexPage) +class IndexPageTR(TranslationOptions): + fields = ( + 'header', + 'intro', + ) + + @register(NewsPage) class NewsPageTR(TranslationOptions): fields = () diff --git a/package-lock.json b/package-lock.json index 6dcdd1c4d4b..877ff5b3912 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1320,7 +1320,7 @@ }, "ansi-escapes": { "version": "3.2.0", - "resolved": "http://registry.npmjs.org/ansi-escapes/-/ansi-escapes-3.2.0.tgz", + "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-3.2.0.tgz", "integrity": "sha512-cBhpre4ma+U0T1oM5fXg7Dy1Jw7zzwv7lt/GoCpr+hDQJoYnKVPLL4dCvSEFMmQurOQvSrwT7SL/DAlhBI97RQ==", "dev": true }, @@ -1672,7 +1672,7 @@ }, "json5": { "version": "0.5.1", - "resolved": "http://registry.npmjs.org/json5/-/json5-0.5.1.tgz", + "resolved": "https://registry.npmjs.org/json5/-/json5-0.5.1.tgz", "integrity": "sha1-Hq3nrMASA0rYTiOWdn6tn6VJWCE=" }, "ms": { @@ -1699,7 +1699,7 @@ "dependencies": { "jsesc": { "version": "1.3.0", - "resolved": "http://registry.npmjs.org/jsesc/-/jsesc-1.3.0.tgz", + "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-1.3.0.tgz", "integrity": "sha1-RsP+yMGJKxKwgz25vHYiF226s0s=" } } @@ -2086,7 +2086,7 @@ }, "p-cancelable": { "version": "0.4.1", - "resolved": "http://registry.npmjs.org/p-cancelable/-/p-cancelable-0.4.1.tgz", + "resolved": "https://registry.npmjs.org/p-cancelable/-/p-cancelable-0.4.1.tgz", "integrity": "sha512-HNa1A8LvB1kie7cERyy21VNeHb2CWJJYqyyC2o3klWFfMGlFmWv2Z7sFgZH8ZiaYL95ydToKTFVXgMV/Os0bBQ==", "dev": true }, @@ -2172,7 +2172,7 @@ }, "bootstrap": { "version": "4.0.0-alpha.6", - "resolved": "https://registry.npmjs.org/bootstrap/-/bootstrap-4.0.0-alpha.6.tgz", + "resolved": "http://registry.npmjs.org/bootstrap/-/bootstrap-4.0.0-alpha.6.tgz", "integrity": "sha1-T1TdM6wN6sOyhAe8LffsYIhpycg=", "requires": { "jquery": ">=1.9.1", @@ -2222,7 +2222,7 @@ }, "browserify-aes": { "version": "1.2.0", - "resolved": "https://registry.npmjs.org/browserify-aes/-/browserify-aes-1.2.0.tgz", + "resolved": "http://registry.npmjs.org/browserify-aes/-/browserify-aes-1.2.0.tgz", "integrity": "sha512-+7CHXqGuspUn/Sl5aO7Ea0xWGAtETPXNSAjHo48JfLdPWcMng33Xe4znFvQweqc/uzk5zSOI3H52CYnjCfb5hA==", "requires": { "buffer-xor": "^1.0.3", @@ -2256,7 +2256,7 @@ }, "browserify-rsa": { "version": "4.0.1", - "resolved": "https://registry.npmjs.org/browserify-rsa/-/browserify-rsa-4.0.1.tgz", + "resolved": "http://registry.npmjs.org/browserify-rsa/-/browserify-rsa-4.0.1.tgz", "integrity": "sha1-IeCr+vbyApzy+vsTNWenAdQTVSQ=", "requires": { "bn.js": "^4.1.0", @@ -2458,7 +2458,7 @@ "dependencies": { "callsites": { "version": "2.0.0", - "resolved": "http://registry.npmjs.org/callsites/-/callsites-2.0.0.tgz", + "resolved": "https://registry.npmjs.org/callsites/-/callsites-2.0.0.tgz", "integrity": "sha1-BuuE8A7qQT2oav/vrL/7Ngk7PFA=" } } @@ -2765,7 +2765,7 @@ }, "commander": { "version": "2.8.1", - "resolved": "http://registry.npmjs.org/commander/-/commander-2.8.1.tgz", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.8.1.tgz", "integrity": "sha1-Br42f+v9oMMwqh4qBy09yXYkJdQ=", "dev": true, "requires": { @@ -2932,7 +2932,7 @@ }, "create-hash": { "version": "1.2.0", - "resolved": "https://registry.npmjs.org/create-hash/-/create-hash-1.2.0.tgz", + "resolved": "http://registry.npmjs.org/create-hash/-/create-hash-1.2.0.tgz", "integrity": "sha512-z00bCGNHDG8mHAkP7CtT1qVu+bFQUPjYq/4Iv3C3kWjTFV10zIjfSoeqXo9Asws8gwSHDGj/hl2u4OGIjapeCg==", "requires": { "cipher-base": "^1.0.1", @@ -2944,7 +2944,7 @@ }, "create-hmac": { "version": "1.1.7", - "resolved": "https://registry.npmjs.org/create-hmac/-/create-hmac-1.1.7.tgz", + "resolved": "http://registry.npmjs.org/create-hmac/-/create-hmac-1.1.7.tgz", "integrity": "sha512-MJG9liiZ+ogc4TzUwuvbER1JRdgvUFSB5+VR/g5h82fGaIRWMWddtKBHi7/sVhfjQZ6SehlyhvQYrcYkaUIpLg==", "requires": { "cipher-base": "^1.0.3", @@ -3117,7 +3117,7 @@ "dependencies": { "pify": { "version": "2.3.0", - "resolved": "http://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", "dev": true } @@ -3189,13 +3189,13 @@ "dependencies": { "file-type": { "version": "3.9.0", - "resolved": "http://registry.npmjs.org/file-type/-/file-type-3.9.0.tgz", + "resolved": "https://registry.npmjs.org/file-type/-/file-type-3.9.0.tgz", "integrity": "sha1-JXoHg4TR24CHvESdEH1SpSZyuek=", "dev": true }, "get-stream": { "version": "2.3.1", - "resolved": "http://registry.npmjs.org/get-stream/-/get-stream-2.3.1.tgz", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-2.3.1.tgz", "integrity": "sha1-Xzj5PzRgCWZu4BUKBUFn+Rvdld4=", "dev": true, "requires": { @@ -3205,7 +3205,7 @@ }, "pify": { "version": "2.3.0", - "resolved": "http://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", "dev": true } @@ -3301,7 +3301,7 @@ }, "diffie-hellman": { "version": "5.0.3", - "resolved": "https://registry.npmjs.org/diffie-hellman/-/diffie-hellman-5.0.3.tgz", + "resolved": "http://registry.npmjs.org/diffie-hellman/-/diffie-hellman-5.0.3.tgz", "integrity": "sha512-kqag/Nl+f3GwyK25fhUMYj81BUOrZ9IuJsjIcDE5icNM9FJHAVm3VcUDxdLPoQtTuUylWm6ZIknYJwwaPxsUzg==", "requires": { "bn.js": "^4.1.0", @@ -3412,7 +3412,7 @@ }, "duplexer": { "version": "0.1.1", - "resolved": "https://registry.npmjs.org/duplexer/-/duplexer-0.1.1.tgz", + "resolved": "http://registry.npmjs.org/duplexer/-/duplexer-0.1.1.tgz", "integrity": "sha1-rOb/gIwc5mtX0ev5eXessCM0z8E=" }, "duplexer3": { @@ -3781,7 +3781,7 @@ }, "events": { "version": "3.0.0", - "resolved": "http://registry.npmjs.org/events/-/events-3.0.0.tgz", + "resolved": "https://registry.npmjs.org/events/-/events-3.0.0.tgz", "integrity": "sha512-Dc381HFWJzEOhQ+d8pkNon++bk9h6cdAoAj4iE6Q4y6xgTzySWXlKn05/TVNpjnfRqi/X0EpJEJohPjNI3zpVA==" }, "evp_bytestokey": { @@ -3828,7 +3828,7 @@ "dependencies": { "pify": { "version": "2.3.0", - "resolved": "http://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", "dev": true } @@ -5546,7 +5546,7 @@ }, "is-builtin-module": { "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-builtin-module/-/is-builtin-module-1.0.0.tgz", + "resolved": "http://registry.npmjs.org/is-builtin-module/-/is-builtin-module-1.0.0.tgz", "integrity": "sha1-VAVy0096wxGfj3bDDLwbHgN6/74=", "requires": { "builtin-modules": "^1.0.0" @@ -5671,7 +5671,7 @@ }, "is-obj": { "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-obj/-/is-obj-1.0.1.tgz", + "resolved": "http://registry.npmjs.org/is-obj/-/is-obj-1.0.1.tgz", "integrity": "sha1-PkcprB9f3gJc19g6iW2rn09n2w8=", "dev": true }, @@ -5991,7 +5991,7 @@ "dependencies": { "pify": { "version": "2.3.0", - "resolved": "http://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=" } } @@ -6013,7 +6013,7 @@ "dependencies": { "json5": { "version": "0.5.1", - "resolved": "http://registry.npmjs.org/json5/-/json5-0.5.1.tgz", + "resolved": "https://registry.npmjs.org/json5/-/json5-0.5.1.tgz", "integrity": "sha1-Hq3nrMASA0rYTiOWdn6tn6VJWCE=" } } @@ -7265,14 +7265,14 @@ "dependencies": { "pify": { "version": "2.3.0", - "resolved": "http://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=" } } }, "pause-stream": { "version": "0.0.11", - "resolved": "https://registry.npmjs.org/pause-stream/-/pause-stream-0.0.11.tgz", + "resolved": "http://registry.npmjs.org/pause-stream/-/pause-stream-0.0.11.tgz", "integrity": "sha1-/lo0sMvOErWqaitAPuLnO2AvFEU=", "requires": { "through": "~2.3" @@ -7603,7 +7603,7 @@ }, "pretty-hrtime": { "version": "1.0.3", - "resolved": "https://registry.npmjs.org/pretty-hrtime/-/pretty-hrtime-1.0.3.tgz", + "resolved": "http://registry.npmjs.org/pretty-hrtime/-/pretty-hrtime-1.0.3.tgz", "integrity": "sha1-t+PqQkNaTJsnWdmeDyAesZWALuE=" }, "private": { @@ -7808,7 +7808,7 @@ "dependencies": { "pify": { "version": "2.3.0", - "resolved": "http://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=" } } @@ -7853,7 +7853,7 @@ }, "readable-stream": { "version": "2.3.6", - "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", "requires": { "core-util-is": "~1.0.0", @@ -8240,7 +8240,7 @@ }, "safe-regex": { "version": "1.1.0", - "resolved": "https://registry.npmjs.org/safe-regex/-/safe-regex-1.1.0.tgz", + "resolved": "http://registry.npmjs.org/safe-regex/-/safe-regex-1.1.0.tgz", "integrity": "sha1-QKNmnzsHfR6UPURinhV91IAjvy4=", "requires": { "ret": "~0.1.10" @@ -8282,7 +8282,7 @@ }, "os-locale": { "version": "1.4.0", - "resolved": "http://registry.npmjs.org/os-locale/-/os-locale-1.4.0.tgz", + "resolved": "https://registry.npmjs.org/os-locale/-/os-locale-1.4.0.tgz", "integrity": "sha1-IPnxeuKe00XoveWDsT0gCYA8FNk=", "requires": { "lcid": "^1.0.0" @@ -8441,7 +8441,7 @@ }, "sha.js": { "version": "2.4.11", - "resolved": "https://registry.npmjs.org/sha.js/-/sha.js-2.4.11.tgz", + "resolved": "http://registry.npmjs.org/sha.js/-/sha.js-2.4.11.tgz", "integrity": "sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ==", "requires": { "inherits": "^2.0.1", @@ -8834,7 +8834,7 @@ }, "stream-browserify": { "version": "2.0.2", - "resolved": "http://registry.npmjs.org/stream-browserify/-/stream-browserify-2.0.2.tgz", + "resolved": "https://registry.npmjs.org/stream-browserify/-/stream-browserify-2.0.2.tgz", "integrity": "sha512-nX6hmklHs/gr2FuxYDltq8fJA1GDlxKQCz8O/IM4atRqBH8OORmBNgfvW5gG10GT/qQ9u0CzIvr2X5Pkt6ntqg==", "requires": { "inherits": "~2.0.1", @@ -8962,7 +8962,7 @@ }, "strip-eof": { "version": "1.0.0", - "resolved": "https://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz", + "resolved": "http://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz", "integrity": "sha1-u0P/VZim6wXYm1n80SnJgzE2Br8=" }, "strip-indent": { @@ -9676,7 +9676,7 @@ }, "through": { "version": "2.3.8", - "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", + "resolved": "http://registry.npmjs.org/through/-/through-2.3.8.tgz", "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=" }, "through2": { @@ -9850,7 +9850,7 @@ }, "tty-browserify": { "version": "0.0.0", - "resolved": "https://registry.npmjs.org/tty-browserify/-/tty-browserify-0.0.0.tgz", + "resolved": "http://registry.npmjs.org/tty-browserify/-/tty-browserify-0.0.0.tgz", "integrity": "sha1-oVe6QC2iTpv5V/mqadUk7tQpAaY=" }, "tunnel-agent": {