Explorar o código

resolve merge conflicts and code cleanup

David Ray %!s(int64=8) %!d(string=hai) anos
pai
achega
4d14f21ed7

+ 10 - 12
bakerydemo/base/blocks.py

@@ -1,14 +1,12 @@
 from wagtail.wagtailimages.blocks import ImageChooserBlock
 from wagtail.wagtailimages.blocks import ImageChooserBlock
 from wagtail.wagtailembeds.blocks import EmbedBlock
 from wagtail.wagtailembeds.blocks import EmbedBlock
 from wagtail.wagtailcore.blocks import (
 from wagtail.wagtailcore.blocks import (
-    StructBlock,
-    TextBlock,
-    StreamBlock,
-    RichTextBlock,
     CharBlock,
     CharBlock,
-    ListBlock,
     ChoiceBlock,
     ChoiceBlock,
-    PageChooserBlock
+    RichTextBlock,
+    StreamBlock,
+    StructBlock,
+    TextBlock,
 )
 )
 
 
 
 
@@ -25,11 +23,11 @@ class ImageBlock(StructBlock):
 class HeadingBlock(StructBlock):
 class HeadingBlock(StructBlock):
     heading_text = CharBlock(classname="title", required=True)
     heading_text = CharBlock(classname="title", required=True)
     size = ChoiceBlock(choices=[
     size = ChoiceBlock(choices=[
-            ('', 'Select a header size'),
-            ('h2', 'H2'),
-            ('h3', 'H3'),
-            ('h4', 'H4')
-        ], blank=True, required=False)
+        ('', 'Select a header size'),
+        ('h2', 'H2'),
+        ('h3', 'H3'),
+        ('h4', 'H4')
+    ], blank=True, required=False)
 
 
     class Meta:
     class Meta:
         icon = "title"
         icon = "title"
@@ -39,7 +37,7 @@ class HeadingBlock(StructBlock):
 class BlockQuote(StructBlock):
 class BlockQuote(StructBlock):
     text = TextBlock(),
     text = TextBlock(),
     attribute_name = CharBlock(
     attribute_name = CharBlock(
-            blank=True, required=False, label='e.g. Guy Picciotto')
+        blank=True, required=False, label='e.g. Guy Picciotto')
 
 
     class Meta:
     class Meta:
         icon = "fa-quote-left"
         icon = "fa-quote-left"

+ 26 - 45
bakerydemo/base/models.py

@@ -1,28 +1,24 @@
 from __future__ import unicode_literals
 from __future__ import unicode_literals
 
 
 from django.db import models
 from django.db import models
-from django.db.utils import OperationalError
 
 
 from modelcluster.fields import ParentalKey
 from modelcluster.fields import ParentalKey
 from modelcluster.models import ClusterableModel
 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
-from wagtail.wagtailcore.fields import StreamField, RichTextField
+
 from wagtail.wagtailadmin.edit_handlers import (
 from wagtail.wagtailadmin.edit_handlers import (
-        FieldPanel,
-        InlinePanel,
-        FieldRowPanel,
-        StreamFieldPanel,
-        MultiFieldPanel,
-        PageChooserPanel
-        )
-from wagtail.wagtailsnippets.models import register_snippet
-from wagtail.wagtailsnippets.edit_handlers import SnippetChooserPanel
-from .blocks import BaseStreamBlock
-from wagtail.wagtailforms.models import AbstractEmailForm, AbstractFormField
+    FieldPanel, FieldRowPanel, InlinePanel, MultiFieldPanel,
+    PageChooserPanel, StreamFieldPanel,
+)
 from wagtail.contrib.modeladmin.options import (
 from wagtail.contrib.modeladmin.options import (
     ModelAdmin, ModelAdminGroup, modeladmin_register)
     ModelAdmin, ModelAdminGroup, modeladmin_register)
+from wagtail.wagtailcore.fields import RichTextField, StreamField
+from wagtail.wagtailcore.models import Collection, Orderable, Page
+from wagtail.wagtailforms.models import AbstractEmailForm, AbstractFormField
+from wagtail.wagtailimages.edit_handlers import ImageChooserPanel
+from wagtail.wagtailsearch import index
+from wagtail.wagtailsnippets.models import register_snippet
+
+from .blocks import BaseStreamBlock
 
 
 
 
 @register_snippet
 @register_snippet
@@ -53,15 +49,15 @@ class People(ClusterableModel):
 
 
     @property
     @property
     def thumb_image(self):
     def thumb_image(self):
-       # fail silently if there is no profile pic or the rendition file can't
-       # be found. Note @richbrennan worked out how to do this...
-       try:
-           return self.image.get_rendition('fill-50x50').img_tag()
-       except:
-           return ''
+        # fail silently if there is no profile pic or the rendition file can't
+        # be found. Note @richbrennan worked out how to do this...
+        try:
+            return self.image.get_rendition('fill-50x50').img_tag()
+        except:
+            return ''
 
 
     def __str__(self):
     def __str__(self):
-        return self.first_name + " " + self.last_name
+        return '{} {}'.format(self.first_name, self.last_name)
 
 
     class Meta:
     class Meta:
         verbose_name = 'Person'
         verbose_name = 'Person'
@@ -100,7 +96,7 @@ class AboutPage(Page):
 
 
     body = StreamField(
     body = StreamField(
         BaseStreamBlock(), verbose_name="About page detail", blank=True
         BaseStreamBlock(), verbose_name="About page detail", blank=True
-        )
+    )
     # We've defined the StreamBlock() within blocks.py that we've imported on
     # We've defined the StreamBlock() within blocks.py that we've imported on
     # line 12. Defining it in a different file gives us consistency across the
     # line 12. Defining it in a different file gives us consistency across the
     # site, though StreamFields _can_ be created on a per model basis if you
     # site, though StreamFields _can_ be created on a per model basis if you
@@ -110,10 +106,10 @@ class AboutPage(Page):
         ImageChooserPanel('image'),
         ImageChooserPanel('image'),
         StreamFieldPanel('body'),
         StreamFieldPanel('body'),
         InlinePanel(
         InlinePanel(
-           'location_about_relationship',
-           label='Locations',
-           min_num=None
-           ),
+            'location_about_relationship',
+            label='Locations',
+            min_num=None
+        ),
     ]
     ]
 
 
     # parent_page_types = [
     # parent_page_types = [
@@ -128,22 +124,6 @@ class AboutPage(Page):
     # api_fields = ['image', 'body']
     # api_fields = ['image', 'body']
 
 
 
 
-def getImageCollections():
-    # We return all collections to a list that don't have the name root.
-    try:
-        collection_images = [(
-            collection.id, collection.name
-            ) for collection in Collection.objects.all().exclude(
-            name='Root'
-            )]
-        return collection_images
-    except:
-        return [('', '')]
-
-    def __str__(self):
-        return self.title
-
-
 class HomePage(Page):
 class HomePage(Page):
     """
     """
     The Home Page
     The Home Page
@@ -159,7 +139,7 @@ class HomePage(Page):
 
 
     body = StreamField(
     body = StreamField(
         BaseStreamBlock(), verbose_name="Home page detail", blank=True
         BaseStreamBlock(), verbose_name="Home page detail", blank=True
-        )
+    )
 
 
     content_panels = Page.content_panels + [
     content_panels = Page.content_panels + [
         ImageChooserPanel('image'),
         ImageChooserPanel('image'),
@@ -254,6 +234,7 @@ class MyModelAdminGroup(ModelAdminGroup):
     menu_order = 200  # will put in 3rd place (000 being 1st, 100 2nd)
     menu_order = 200  # will put in 3rd place (000 being 1st, 100 2nd)
     items = (PeopleModelAdmin,)
     items = (PeopleModelAdmin,)
 
 
+
 # When using a ModelAdminGroup class to group several ModelAdmin classes together,
 # When using a ModelAdminGroup class to group several ModelAdmin classes together,
 # you only need to register the ModelAdminGroup class with Wagtail:
 # you only need to register the ModelAdminGroup class with Wagtail:
 modeladmin_register(MyModelAdminGroup)
 modeladmin_register(MyModelAdminGroup)

+ 1 - 2
bakerydemo/base/templatetags/navigation_tags.py

@@ -1,6 +1,5 @@
 from django import template
 from django import template
-from django.template import Template
-from django.utils.http import urlencode
+
 from wagtail.wagtailcore.models import Page
 from wagtail.wagtailcore.models import Page
 
 
 register = template.Library()
 register = template.Library()

+ 3 - 3
bakerydemo/blog/models.py

@@ -4,8 +4,8 @@ from django.contrib import messages
 from django.db import models
 from django.db import models
 from django.shortcuts import redirect, render
 from django.shortcuts import redirect, render
 
 
-from modelcluster.fields import ParentalKey
 from modelcluster.contrib.taggit import ClusterTaggableManager
 from modelcluster.contrib.taggit import ClusterTaggableManager
+from modelcluster.fields import ParentalKey
 
 
 from taggit.models import Tag, TaggedItemBase
 from taggit.models import Tag, TaggedItemBase
 
 
@@ -15,11 +15,11 @@ from wagtail.wagtailadmin.edit_handlers import (
     InlinePanel,
     InlinePanel,
     StreamFieldPanel,
     StreamFieldPanel,
 )
 )
-from wagtail.wagtailimages.edit_handlers import ImageChooserPanel
 from wagtail.wagtailcore.fields import StreamField
 from wagtail.wagtailcore.fields import StreamField
 from wagtail.wagtailcore.models import Page, Orderable
 from wagtail.wagtailcore.models import Page, Orderable
-from wagtail.wagtailsnippets.edit_handlers import SnippetChooserPanel
+from wagtail.wagtailimages.edit_handlers import ImageChooserPanel
 from wagtail.wagtailsearch import index
 from wagtail.wagtailsearch import index
+from wagtail.wagtailsnippets.edit_handlers import SnippetChooserPanel
 
 
 from bakerydemo.base.blocks import BaseStreamBlock
 from bakerydemo.base.blocks import BaseStreamBlock
 
 

+ 5 - 7
bakerydemo/breads/models.py

@@ -1,12 +1,12 @@
 from django.db import models
 from django.db import models
 
 
-from wagtail.wagtailcore.models import Page
-from wagtail.wagtailcore.fields import StreamField
 from wagtail.wagtailadmin.edit_handlers import FieldPanel, StreamFieldPanel
 from wagtail.wagtailadmin.edit_handlers import FieldPanel, StreamFieldPanel
+from wagtail.wagtailcore.fields import StreamField
+from wagtail.wagtailcore.models import Page
 
 
+from wagtail.wagtailcore import blocks
 from wagtail.wagtailimages.edit_handlers import ImageChooserPanel
 from wagtail.wagtailimages.edit_handlers import ImageChooserPanel
 from wagtail.wagtailsearch import index
 from wagtail.wagtailsearch import index
-from wagtail.wagtailcore import blocks
 from wagtail.wagtailsnippets.models import register_snippet
 from wagtail.wagtailsnippets.models import register_snippet
 
 
 
 
@@ -55,7 +55,7 @@ class BreadPage(Page):
         on_delete=models.SET_NULL,
         on_delete=models.SET_NULL,
         null=True,
         null=True,
         blank=True,
         blank=True,
-        )
+    )
     description = StreamField([
     description = StreamField([
         ('heading', blocks.CharBlock(classname="full title")),
         ('heading', blocks.CharBlock(classname="full title")),
         ('paragraph', blocks.RichTextBlock()),
         ('paragraph', blocks.RichTextBlock()),
@@ -89,9 +89,7 @@ class BreadPage(Page):
         index.SearchField('description'),
         index.SearchField('description'),
     ]
     ]
 
 
-    parent_page_types = [
-       'BreadsIndexPage'
-    ]
+    parent_page_types = ['BreadsIndexPage']
 
 
 
 
 class BreadsIndexPage(Page):
 class BreadsIndexPage(Page):

+ 1 - 3
bakerydemo/locations/models.py

@@ -121,6 +121,4 @@ class LocationPage(Page):
         context['long'] = self.lat_long.split(",")[1]
         context['long'] = self.lat_long.split(",")[1]
         return context
         return context
 
 
-    parent_page_types = [
-       'LocationsIndexPage'
-    ]
+    parent_page_types = ['LocationsIndexPage']

+ 1 - 2
bakerydemo/search/views.py

@@ -1,5 +1,5 @@
-from django.shortcuts import render
 from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
 from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
+from django.shortcuts import render
 
 
 from wagtail.wagtailcore.models import Page
 from wagtail.wagtailcore.models import Page
 from wagtail.wagtailsearch.models import Query
 from wagtail.wagtailsearch.models import Query
@@ -7,7 +7,6 @@ from wagtail.wagtailsearch.models import Query
 from bakerydemo.blog.models import BlogPage
 from bakerydemo.blog.models import BlogPage
 from bakerydemo.breads.models import BreadPage
 from bakerydemo.breads.models import BreadPage
 from bakerydemo.locations.models import LocationPage
 from bakerydemo.locations.models import LocationPage
-from bakerydemo.base.models import People
 
 
 
 
 def search(request):
 def search(request):