From c7f4acb055a9c34426cb76985a97f73940d741f8 Mon Sep 17 00:00:00 2001
From: Fredrik Jonsson <frjo@xdeb.org>
Date: Fri, 16 Nov 2018 10:34:03 +0100
Subject: [PATCH] Add introduction text to news index pages.

---
 .../migrations/0007_newsindex_introduction.py  | 18 ++++++++++++++++++
 opentech/public/news/models.py                 |  6 ++++++
 .../public/news/templates/news/news_index.html |  4 ++++
 3 files changed, 28 insertions(+)
 create mode 100644 opentech/public/news/migrations/0007_newsindex_introduction.py

diff --git a/opentech/public/news/migrations/0007_newsindex_introduction.py b/opentech/public/news/migrations/0007_newsindex_introduction.py
new file mode 100644
index 000000000..82caa035d
--- /dev/null
+++ b/opentech/public/news/migrations/0007_newsindex_introduction.py
@@ -0,0 +1,18 @@
+# Generated by Django 2.0.9 on 2018-11-16 09:28
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('news', '0006_newspage_drupal_id'),
+    ]
+
+    operations = [
+        migrations.AddField(
+            model_name='newsindex',
+            name='introduction',
+            field=models.TextField(blank=True),
+        ),
+    ]
diff --git a/opentech/public/news/models.py b/opentech/public/news/models.py
index dbb645c76..4cd4d5a91 100644
--- a/opentech/public/news/models.py
+++ b/opentech/public/news/models.py
@@ -128,6 +128,12 @@ class NewsIndex(BasePage):
     subpage_types = ['NewsPage']
     parent_page_types = ['home.HomePage']
 
+    introduction = models.TextField(blank=True)
+
+    content_panels = BasePage.content_panels + [
+        FieldPanel('introduction')
+    ]
+
     def get_context(self, request, *args, **kwargs):
         news = NewsPage.objects.live().public().descendant_of(self).annotate(
             date=Coalesce('publication_date', 'first_published_at')
diff --git a/opentech/public/news/templates/news/news_index.html b/opentech/public/news/templates/news/news_index.html
index deceffbd7..6a4b6f427 100644
--- a/opentech/public/news/templates/news/news_index.html
+++ b/opentech/public/news/templates/news/news_index.html
@@ -5,6 +5,10 @@
 {% block content %}
 <div class="wrapper wrapper--small wrapper--inner-space-medium">
 
+        {% if page.introduction %}
+            <h4 class="heading heading--listings-introduction">{{ page.introduction }}</h4>
+        {% endif %}
+
         <form class="form" method="GET">
             <div class="form__select form__select--narrow form__select--inline">
                 <select name="news_type">
-- 
GitLab