Skip to content
Snippets Groups Projects
Commit 9d1e526c authored by Todd Dembrey's avatar Todd Dembrey
Browse files

add a project relation to the news page

parent 43856ddb
No related branches found
No related tags found
No related merge requests found
# -*- coding: utf-8 -*-
# Generated by Django 1.11.8 on 2018-01-29 10:41
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
import modelcluster.fields
class Migration(migrations.Migration):
dependencies = [
('wagtailcore', '0040_page_draft_title'),
('news', '0004_make_author_required'),
]
operations = [
migrations.CreateModel(
name='NewsProjectRelatedPage',
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)),
('page', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='wagtailcore.Page')),
('source_page', modelcluster.fields.ParentalKey(on_delete=django.db.models.deletion.CASCADE, related_name='related_projects', to='news.NewsPage')),
],
options={
'ordering': ['sort_order'],
'abstract': False,
},
),
]
...@@ -52,6 +52,17 @@ class NewsPageRelatedPage(RelatedPage): ...@@ -52,6 +52,17 @@ class NewsPageRelatedPage(RelatedPage):
) )
class NewsProjectRelatedPage(RelatedPage):
source_page = ParentalKey(
'news.NewsPage',
related_name='related_projects'
)
panels = [
PageChooserPanel('page', 'projects.ProjectPage'),
]
class NewsPageAuthor(Orderable): class NewsPageAuthor(Orderable):
source_page = ParentalKey( source_page = ParentalKey(
'news.NewsPage', 'news.NewsPage',
...@@ -92,6 +103,7 @@ class NewsPage(BasePage): ...@@ -92,6 +103,7 @@ class NewsPage(BasePage):
FieldPanel('introduction'), FieldPanel('introduction'),
StreamFieldPanel('body'), StreamFieldPanel('body'),
InlinePanel('news_types', label="News types"), InlinePanel('news_types', label="News types"),
InlinePanel('related_projects', label="Mentioned project"),
InlinePanel('related_pages', label="Related pages"), InlinePanel('related_pages', label="Related pages"),
] ]
......
...@@ -30,6 +30,15 @@ ...@@ -30,6 +30,15 @@
</ul> </ul>
{% endif %} {% endif %}
{% if page.related_projects.all %}
<h4 class="heading">Projects Mentioned</h4>
<ul class="list">
{% for project in page.related_projects.all %}
<li><a href="{% pageurl project.page %}">{{ project.page }}</a></li>
{% endfor %}
</ul>
{% endif %}
{% include "includes/share.html" %} {% include "includes/share.html" %}
</div> </div>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment