From 176ebb4f4b28813cb85b4ecfc0f3126a385e0019 Mon Sep 17 00:00:00 2001
From: Todd Dembrey <todd.dembrey@torchbox.com>
Date: Wed, 10 Jan 2018 15:10:39 +0000
Subject: [PATCH] Add the initial migration

---
 .../publicpages/migrations/0001_initial.py    | 60 +++++++++++++++++++
 opentech/publicpages/models.py                |  8 +--
 opentech/settings/base.py                     |  1 +
 3 files changed, 65 insertions(+), 4 deletions(-)
 create mode 100644 opentech/publicpages/migrations/0001_initial.py

diff --git a/opentech/publicpages/migrations/0001_initial.py b/opentech/publicpages/migrations/0001_initial.py
new file mode 100644
index 000000000..de11954b9
--- /dev/null
+++ b/opentech/publicpages/migrations/0001_initial.py
@@ -0,0 +1,60 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.11.8 on 2018-01-09 11:20
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+import django.db.models.deletion
+import wagtail.wagtailcore.blocks
+import wagtail.wagtailcore.fields
+import wagtail.wagtaildocs.blocks
+import wagtail.wagtailembeds.blocks
+import wagtail.wagtailimages.blocks
+import wagtail.wagtailsnippets.blocks
+
+
+class Migration(migrations.Migration):
+
+    initial = True
+
+    dependencies = [
+        ('wagtailcore', '0040_page_draft_title'),
+        ('images', '0001_initial'),
+    ]
+
+    operations = [
+        migrations.CreateModel(
+            name='FundIndex',
+            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')),
+                ('social_text', models.CharField(blank=True, max_length=255)),
+                ('listing_title', models.CharField(blank=True, help_text='Override the page title used when this page appears in listings', max_length=255)),
+                ('listing_summary', models.CharField(blank=True, help_text="The text summary used when this page appears in listings. It's also used as the description for search engines if the 'Search description' field above is not defined.", max_length=255)),
+                ('header_image', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='images.CustomImage')),
+                ('listing_image', models.ForeignKey(blank=True, help_text='Choose the image you wish to be displayed when this page appears in listings', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='images.CustomImage')),
+                ('social_image', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='images.CustomImage')),
+            ],
+            options={
+                'abstract': False,
+            },
+            bases=('wagtailcore.page', models.Model),
+        ),
+        migrations.CreateModel(
+            name='FundPage',
+            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')),
+                ('social_text', models.CharField(blank=True, max_length=255)),
+                ('listing_title', models.CharField(blank=True, help_text='Override the page title used when this page appears in listings', max_length=255)),
+                ('listing_summary', models.CharField(blank=True, help_text="The text summary used when this page appears in listings. It's also used as the description for search engines if the 'Search description' field above is not defined.", max_length=255)),
+                ('introduction', models.TextField(blank=True)),
+                ('body', wagtail.wagtailcore.fields.StreamField((('heading', wagtail.wagtailcore.blocks.CharBlock(classname='full title', icon='title')), ('paragraph', wagtail.wagtailcore.blocks.RichTextBlock()), ('image', wagtail.wagtailcore.blocks.StructBlock((('image', wagtail.wagtailimages.blocks.ImageChooserBlock()), ('caption', wagtail.wagtailcore.blocks.CharBlock(required=False))))), ('quote', wagtail.wagtailcore.blocks.StructBlock((('quote', wagtail.wagtailcore.blocks.CharBlock(classname='title')), ('attribution', wagtail.wagtailcore.blocks.CharBlock(required=False)), ('job_title', wagtail.wagtailcore.blocks.CharBlock(required=False))))), ('embed', wagtail.wagtailembeds.blocks.EmbedBlock()), ('call_to_action', wagtail.wagtailsnippets.blocks.SnippetChooserBlock('utils.CallToActionSnippet', template='blocks/call_to_action_block.html')), ('document', wagtail.wagtailcore.blocks.StructBlock((('document', wagtail.wagtaildocs.blocks.DocumentChooserBlock()), ('title', wagtail.wagtailcore.blocks.CharBlock(required=False)))))))),
+                ('fund_type', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='wagtailcore.Page')),
+                ('header_image', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='images.CustomImage')),
+                ('listing_image', models.ForeignKey(blank=True, help_text='Choose the image you wish to be displayed when this page appears in listings', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='images.CustomImage')),
+                ('social_image', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='images.CustomImage')),
+            ],
+            options={
+                'abstract': False,
+            },
+            bases=('wagtailcore.page', models.Model),
+        ),
+    ]
diff --git a/opentech/publicpages/models.py b/opentech/publicpages/models.py
index d8ce467cf..65aaab64e 100644
--- a/opentech/publicpages/models.py
+++ b/opentech/publicpages/models.py
@@ -21,6 +21,8 @@ class FundPage(BasePage):
     introduction = models.TextField(blank=True)
     fund_type = models.ForeignKey(
         'wagtailcore.Page',
+        blank=True,
+        null=True,
         on_delete=models.SET_NULL,
         related_name='+',
     )
@@ -33,14 +35,12 @@ class FundPage(BasePage):
     ]
 
 
-class NewsIndex(BasePage):
+class FundIndex(BasePage):
     subpage_types = ['FundPage']
     parent_page_types = ['home.HomePage']
 
     def get_context(self, request, *args, **kwargs):
-        funds = FundPage.objects.live().public().descendant_of(self).annotate(
-            date=Coalesce('publication_date', 'first_published_at')
-        ).order_by('-date')
+        funds = FundPage.objects.live().public().descendant_of(self)
 
         # Pagination
         page = request.GET.get('page', 1)
diff --git a/opentech/settings/base.py b/opentech/settings/base.py
index 5aaf1a759..63dba99ec 100644
--- a/opentech/settings/base.py
+++ b/opentech/settings/base.py
@@ -13,6 +13,7 @@ BASE_DIR = os.path.dirname(PROJECT_DIR)
 
 INSTALLED_APPS = [
     'opentech.images',
+    'opentech.publicpages',
 
     'opentech.apply.categories',
     'opentech.apply.funds',
-- 
GitLab