From 32d93b31cea99d50aeea855298baac8a7f33dafe Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Thu, 26 Jul 2018 08:44:14 +0100 Subject: [PATCH] Add blog model --- project/blog/__init__.py | 0 project/blog/migrations/0001_initial.py | 39 +++++++++++++++++++++++++ project/blog/migrations/__init__.py | 0 project/blog/models.py | 16 ++++++++++ project/settings.py | 1 + 5 files changed, 56 insertions(+) create mode 100644 project/blog/__init__.py create mode 100644 project/blog/migrations/0001_initial.py create mode 100644 project/blog/migrations/__init__.py create mode 100644 project/blog/models.py diff --git a/project/blog/__init__.py b/project/blog/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/project/blog/migrations/0001_initial.py b/project/blog/migrations/0001_initial.py new file mode 100644 index 0000000..4adc3e4 --- /dev/null +++ b/project/blog/migrations/0001_initial.py @@ -0,0 +1,39 @@ +# Generated by Django 2.0.7 on 2018-07-26 07:38 + +from django.db import migrations, models +import django.db.models.deletion +import wagtail.core.blocks +import wagtail.core.fields +import wagtail.documents.blocks +import wagtail.embeds.blocks +import wagtail.images.blocks +import wagtailmarkdown.blocks +import wagtailmetadata.models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ('wagtailcore', '0040_page_draft_title'), + ('wagtailimages', '0020_add-verbose-name'), + ] + + operations = [ + migrations.CreateModel( + name='BlogPage', + 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')), + ('created', models.DateTimeField(auto_now_add=True)), + ('modified', models.DateTimeField(auto_now=True)), + ('post_date', models.DateTimeField(blank=True, null=True)), + ('body', wagtail.core.fields.StreamField([('document', wagtail.documents.blocks.DocumentChooserBlock()), ('heading', wagtail.core.blocks.StructBlock([('size', wagtail.core.blocks.ChoiceBlock(choices=[('h1', 'H1'), ('h2', 'H2'), ('h3', 'H3'), ('h4', 'H4'), ('h5', 'H5')])), ('value', wagtail.core.blocks.CharBlock())])), ('image', wagtail.images.blocks.ImageChooserBlock()), ('markdown', wagtailmarkdown.blocks.MarkdownBlock()), ('ol', wagtail.core.blocks.ListBlock(wagtail.core.blocks.CharBlock(label='List Item'), icon='list-ol', label='Ordered List', template='blocks/ordered-list.html')), ('paragraph', wagtail.core.blocks.RichTextBlock()), ('raw_html', wagtail.core.blocks.RawHTMLBlock(label='Raw HTML')), ('ul', wagtail.core.blocks.ListBlock(wagtail.core.blocks.CharBlock(label='List Item'), icon='list-ul', label='Unordered List')), ('video', wagtail.core.blocks.StructBlock([('video', wagtail.embeds.blocks.EmbedBlock()), ('caption', wagtail.core.blocks.CharBlock())]))])), + ('search_image', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='wagtailimages.Image')), + ], + options={ + 'abstract': False, + }, + bases=(wagtailmetadata.models.MetadataMixin, 'wagtailcore.page', models.Model), + ), + ] diff --git a/project/blog/migrations/__init__.py b/project/blog/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/project/blog/models.py b/project/blog/models.py new file mode 100644 index 0000000..da37c85 --- /dev/null +++ b/project/blog/models.py @@ -0,0 +1,16 @@ +from project.common.blocks import build_stream_field +from wagtail.admin.edit_handlers import StreamFieldPanel +from wagtail.search import index +from project.common.models import Entity + + +class BlogPage(Entity): + body = build_stream_field() + + search_fields = Entity.search_fields + [ + index.SearchField('body'), + ] + + content_panels = Entity.content_panels + [ + StreamFieldPanel('body'), +] diff --git a/project/settings.py b/project/settings.py index f746b3b..b5f58e5 100644 --- a/project/settings.py +++ b/project/settings.py @@ -45,6 +45,7 @@ INSTALLED_APPS = [ 'project.search', 'project.common', 'project.pages', + 'project.blog', 'wagtail.contrib.forms', 'wagtail.contrib.redirects',