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 0000000000000000000000000000000000000000..82caa035da714a9a9ff7c56c56a34dd8064c9824 --- /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 dbb645c7657cfc354b8d50d01919bfd2834658df..4cd4d5a915264bc040f4beeb88bc46761bdfac3a 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 deceffbd78fde0d2591f6fa1fade967d0a2b091e..6a4b6f42721aaab26e1d9f3e2225820a9cfd36eb 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">