From 5f90b98ee38a9c5e07d79ff9071e51493cd04247 Mon Sep 17 00:00:00 2001 From: Fredrik Jonsson <frjo@xdeb.org> Date: Sat, 28 Mar 2020 16:12:37 +0100 Subject: [PATCH] Add ability to add top news link to top of home page. --- .../home/migrations/0012_add_news_homepage.py | 30 +++++++++++++++++++ hypha/public/home/models.py | 9 ++++++ .../public/home/templates/home/home_page.html | 13 ++++++++ 3 files changed, 52 insertions(+) create mode 100644 hypha/public/home/migrations/0012_add_news_homepage.py diff --git a/hypha/public/home/migrations/0012_add_news_homepage.py b/hypha/public/home/migrations/0012_add_news_homepage.py new file mode 100644 index 000000000..c342becc2 --- /dev/null +++ b/hypha/public/home/migrations/0012_add_news_homepage.py @@ -0,0 +1,30 @@ +# Generated by Django 2.2.11 on 2020-03-28 15:06 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('wagtailcore', '0045_assign_unlock_grouppagepermission'), + ('home', '0011_correct_related_page_behaviour'), + ] + + operations = [ + migrations.AddField( + model_name='homepage', + name='news_link', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='+', to='wagtailcore.Page'), + ), + migrations.AddField( + model_name='homepage', + name='news_link_text', + field=models.CharField(blank=True, max_length=255), + ), + migrations.AddField( + model_name='homepage', + name='news_title', + field=models.CharField(blank=True, max_length=255), + ), + ] diff --git a/hypha/public/home/models.py b/hypha/public/home/models.py index d2598eb8e..741530081 100644 --- a/hypha/public/home/models.py +++ b/hypha/public/home/models.py @@ -70,6 +70,10 @@ class HomePage(BasePage): strapline_link = models.ForeignKey('wagtailcore.Page', related_name='+', on_delete=models.PROTECT) strapline_link_text = models.CharField(max_length=255) + news_title = models.CharField(blank=True, max_length=255) + news_link = models.ForeignKey('wagtailcore.Page', blank=True, null=True, related_name='+', on_delete=models.PROTECT) + news_link_text = models.CharField(blank=True, max_length=255) + our_work_title = models.CharField(max_length=255) our_work = StreamField([ ('work', OurWorkBlock()), @@ -100,6 +104,11 @@ class HomePage(BasePage): PageChooserPanel('strapline_link'), FieldPanel('strapline_link_text'), ], heading='Introduction'), + MultiFieldPanel([ + FieldPanel('news_title'), + PageChooserPanel('news_link'), + FieldPanel('news_link_text'), + ], heading='News'), MultiFieldPanel([ FieldPanel('our_work_title'), StreamFieldPanel('our_work'), diff --git a/hypha/public/home/templates/home/home_page.html b/hypha/public/home/templates/home/home_page.html index 56ad6b704..f3f5cb7e3 100644 --- a/hypha/public/home/templates/home/home_page.html +++ b/hypha/public/home/templates/home/home_page.html @@ -81,6 +81,19 @@ {% endblock %} {% block content %} + {% if page.news_title and page.news_link and page.news_link_text %} + <div class="wrapper wrapper--inner-space-large"> + <h2 class="heading heading--center heading--focus-areas">{{ page.news_title }}</h2> + <div class="wrapper wrapper--center"> + <h5 class="heading heading--contains-link"> + <a class="link link--arrow-pixels-blue" href="{% pageurl page.news_link %}"> + {{ page.news_link_text }} + <svg><use xlink:href="#arrow-head-pixels--solid"></use></svg> + </a> + </h5> + </div> + </div> + {% endif %} <div class="wrapper wrapper--inner-space-large"> <h2 class="heading heading--center heading--focus-areas">{{ page.our_work_title }}</h2> <div class="grid grid--focus-areas"> -- GitLab