Edd Baldry 8 년 전
부모
커밋
573b6bbb65

+ 20 - 0
bakerydemo/base/migrations/0003_auto_20170209_1651.py

@@ -0,0 +1,20 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.10.5 on 2017-02-09 16:51
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('base', '0002_gallerypage_choices'),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name='gallerypage',
+            name='choices',
+            field=models.CharField(choices=[(2, 'Something')], max_length=255),
+        ),
+    ]

+ 2 - 1
bakerydemo/base/models.py

@@ -3,6 +3,7 @@ from __future__ import unicode_literals
 from django.db import models
 
 from modelcluster.fields import ParentalKey
+from modelcluster.models import ClusterableModel
 from wagtail.wagtailcore.models import Page, Orderable, Collection
 from wagtail.wagtailsearch import index
 from wagtail.wagtailimages.edit_handlers import ImageChooserPanel
@@ -21,7 +22,7 @@ from wagtail.wagtailforms.models import AbstractEmailForm, AbstractFormField
 
 
 @register_snippet
-class People(models.Model):
+class People(ClusterableModel):
     first_name = models.CharField("First name", max_length=254)
     last_name = models.CharField("Last name", max_length=254)
     job_title = models.CharField("Job title", max_length=254)

+ 81 - 0
bakerydemo/blog/migrations/0001_initial.py

@@ -0,0 +1,81 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.10.5 on 2017-02-09 16:51
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+import django.db.models.deletion
+import modelcluster.contrib.taggit
+import modelcluster.fields
+import wagtail.wagtailcore.blocks
+import wagtail.wagtailcore.fields
+import wagtail.wagtailembeds.blocks
+import wagtail.wagtailimages.blocks
+
+
+class Migration(migrations.Migration):
+
+    initial = True
+
+    dependencies = [
+        ('wagtailcore', '0032_add_bulk_delete_page_permission'),
+        ('wagtailimages', '0017_reduce_focal_point_key_max_length'),
+        ('taggit', '0002_auto_20150616_2121'),
+        ('base', '0003_auto_20170209_1651'),
+    ]
+
+    operations = [
+        migrations.CreateModel(
+            name='BlogIndexPage',
+            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')),
+                ('introduction', models.TextField(blank=True, help_text='Text to describe the index page')),
+                ('image', models.ForeignKey(blank=True, help_text='Location listing image', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='wagtailimages.Image')),
+            ],
+            options={
+                'abstract': False,
+            },
+            bases=('wagtailcore.page',),
+        ),
+        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')),
+                ('date_published', models.DateField(blank=True, null=True, verbose_name='Date article published')),
+                ('body', wagtail.wagtailcore.fields.StreamField((('heading_block', wagtail.wagtailcore.blocks.StructBlock((('heading_text', wagtail.wagtailcore.blocks.CharBlock(classname='title', required=True)), ('size', wagtail.wagtailcore.blocks.ChoiceBlock(blank=True, choices=[('', 'Select a header size'), ('h2', 'H2'), ('h3', 'H3'), ('h4', 'H4')], required=False))))), ('paragraph_block', wagtail.wagtailcore.blocks.RichTextBlock(icon='fa-paragraph', template='blocks/paragraph_block.html')), ('image_block', wagtail.wagtailcore.blocks.StructBlock((('image', wagtail.wagtailimages.blocks.ImageChooserBlock(required=True)), ('caption', wagtail.wagtailcore.blocks.CharBlock(required=False)), ('attribution', wagtail.wagtailcore.blocks.CharBlock(required=False))))), ('block_quote', wagtail.wagtailcore.blocks.StructBlock((('attribute_name', wagtail.wagtailcore.blocks.CharBlock(blank=True, label='e.g. Guy Picciotto', required=False)),))), ('embed_block', wagtail.wagtailembeds.blocks.EmbedBlock(help_text='Insert an embed URL e.g https://www.youtube.com/embed/SGJFWirQ3ks', icon='fa-s15', template='blocks/embed_block.html'))), blank=True, verbose_name='About page detail')),
+                ('image', models.ForeignKey(blank=True, help_text='Location image', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='wagtailimages.Image')),
+            ],
+            options={
+                'abstract': False,
+            },
+            bases=('wagtailcore.page',),
+        ),
+        migrations.CreateModel(
+            name='BlogPageTag',
+            fields=[
+                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+                ('content_object', modelcluster.fields.ParentalKey(on_delete=django.db.models.deletion.CASCADE, related_name='tagged_items', to='blog.BlogPage')),
+                ('tag', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='blog_blogpagetag_items', to='taggit.Tag')),
+            ],
+            options={
+                'abstract': False,
+            },
+        ),
+        migrations.CreateModel(
+            name='BlogPeopleRelationship',
+            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)),
+                ('blogpage', modelcluster.fields.ParentalKey(on_delete=django.db.models.deletion.CASCADE, related_name='blog_person_relationship', to='blog.BlogPage')),
+                ('people', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='person_blog_relationship', to='base.People')),
+            ],
+            options={
+                'abstract': False,
+                'ordering': ['sort_order'],
+            },
+        ),
+        migrations.AddField(
+            model_name='blogpage',
+            name='tags',
+            field=modelcluster.contrib.taggit.ClusterTaggableManager(blank=True, help_text='A comma-separated list of tags.', through='blog.BlogPageTag', to='taggit.Tag', verbose_name='Tags'),
+        ),
+    ]

+ 20 - 0
bakerydemo/blog/migrations/0002_auto_20170209_1659.py

@@ -0,0 +1,20 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.10.5 on 2017-02-09 16:59
+from __future__ import unicode_literals
+
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('blog', '0001_initial'),
+    ]
+
+    operations = [
+        migrations.RenameField(
+            model_name='blogpeoplerelationship',
+            old_name='blogpage',
+            new_name='page',
+        ),
+    ]

+ 126 - 0
bakerydemo/blog/models.py

@@ -0,0 +1,126 @@
+from __future__ import unicode_literals
+
+from django.db import models
+
+from modelcluster.fields import ParentalKey
+from modelcluster.contrib.taggit import ClusterTaggableManager
+from taggit.models import TaggedItemBase
+from wagtail.wagtailcore.models import Page, Orderable, Collection
+from wagtail.wagtailsearch import index
+from wagtail.wagtailimages.edit_handlers import ImageChooserPanel
+from wagtail.wagtailcore.fields import StreamField, RichTextField
+from wagtail.wagtailadmin.edit_handlers import (
+        FieldPanel,
+        InlinePanel,
+        FieldRowPanel,
+        StreamFieldPanel,
+        MultiFieldPanel
+        )
+from wagtail.wagtailsnippets.edit_handlers import SnippetChooserPanel
+from bakerydemo.base.blocks import BaseStreamBlock
+
+
+class BlogPeopleRelationship(Orderable, models.Model):
+    """
+    This defines the relationship between the `LocationPage` within the `locations`
+    app and the About page below allowing us to add locations to the about
+    section.
+    """
+    page = ParentalKey(
+        'BlogPage', related_name='blog_person_relationship'
+    )
+    people = models.ForeignKey(
+        'base.People', related_name='person_blog_relationship'
+    )
+    panels = [
+        SnippetChooserPanel('people')
+    ]
+
+
+class BlogPageTag(TaggedItemBase):
+    content_object = ParentalKey('BlogPage', related_name='tagged_items')
+
+
+class BlogPage(Page):
+    """
+    The About Page
+    """
+    image = models.ForeignKey(
+        'wagtailimages.Image',
+        null=True,
+        blank=True,
+        on_delete=models.SET_NULL,
+        related_name='+',
+        help_text='Location image'
+    )
+
+    tags = ClusterTaggableManager(through=BlogPageTag, blank=True)
+
+    date_published = models.DateField("Date article published", blank=True, null=True)
+
+    body = StreamField(
+        BaseStreamBlock(), verbose_name="About page detail", blank=True
+        )
+
+    content_panels = Page.content_panels + [
+        ImageChooserPanel('image'),
+        StreamFieldPanel('body'),
+        FieldPanel('date_published'),
+        InlinePanel(
+            'blog_person_relationship', label="Author(s)",
+            panels=None, min_num=1),
+        FieldPanel('tags'),
+    ]
+
+    # def people(self):
+    #     people = [
+    #          n.people for n in self.person_blog_relationship.all()
+    #     ]
+
+    #     return people
+
+    parent_page_types = [
+       'BlogIndexPage'
+    ]
+
+    # Defining what content type can sit under the parent
+    # The empty array means that no children can be placed under the
+    # LocationPage page model
+    subpage_types = []
+
+    # api_fields = ['image', 'body']
+
+
+class BlogIndexPage(Page):
+    """
+    """
+
+    image = models.ForeignKey(
+        'wagtailimages.Image',
+        null=True,
+        blank=True,
+        on_delete=models.SET_NULL,
+        related_name='+',
+        help_text='Location listing image'
+    )
+
+    introduction = models.TextField(
+        help_text='Text to describe the index page',
+        blank=True)
+
+    content_panels = Page.content_panels + [
+        ImageChooserPanel('image'),
+        FieldPanel('introduction')
+    ]
+
+    # parent_page_types = [
+    #     'home.HomePage'
+    # ]
+
+    # Defining what content type can sit under the parent. Since it's a blank
+    # array no subpage can be added
+    subpage_types = [
+        'BlogPage'
+    ]
+
+    # api_fields = ['introduction']

+ 20 - 0
bakerydemo/locations/migrations/0002_auto_20170209_1651.py

@@ -0,0 +1,20 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.10.5 on 2017-02-09 16:51
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('locations', '0001_initial'),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name='locationpage',
+            name='lat_long',
+            field=models.CharField(help_text="Comma separated lat/long. (Ex. 64.144367, -21.939182)                    Right click Google Maps and click 'What's Here'", max_length=36),
+        ),
+    ]