浏览代码

Merge branch 'master' into 62-blog-index-styling

Edd Baldry 8 年之前
父节点
当前提交
cdb3585b26

+ 1 - 1
.gitignore

@@ -3,6 +3,7 @@
 *.log
 *.log
 *.swp
 *.swp
 *.retry
 *.retry
+.env
 *~
 *~
 /logs
 /logs
 /data
 /data
@@ -16,4 +17,3 @@ __pycache__
 /.vagrant/
 /.vagrant/
 /Vagrantfile.local
 /Vagrantfile.local
 !.gitignore
 !.gitignore
-

+ 20 - 0
bakerydemo/base/migrations/0012_auto_20170222_0756.py

@@ -0,0 +1,20 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.10.5 on 2017-02-22 07:56
+from __future__ import unicode_literals
+
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('base', '0011_auto_20170220_0111'),
+    ]
+
+    operations = [
+        migrations.RenameField(
+            model_name='gallerypage',
+            old_name='choices',
+            new_name='collection',
+        ),
+    ]

+ 3 - 31
bakerydemo/base/models.py

@@ -5,8 +5,6 @@ from django.db import models
 from modelcluster.fields import ParentalKey
 from modelcluster.fields import ParentalKey
 from modelcluster.models import ClusterableModel
 from modelcluster.models import ClusterableModel
 
 
-from wagtail.contrib.modeladmin.options import (
-    ModelAdmin, ModelAdminGroup, modeladmin_register)
 from wagtail.wagtailadmin.edit_handlers import (
 from wagtail.wagtailadmin.edit_handlers import (
     FieldPanel, FieldRowPanel, InlinePanel, MultiFieldPanel,
     FieldPanel, FieldRowPanel, InlinePanel, MultiFieldPanel,
     PageChooserPanel, StreamFieldPanel,
     PageChooserPanel, StreamFieldPanel,
@@ -201,7 +199,7 @@ class GalleryPage(BasePageFieldsMixin, Page):
     """
     """
     This is a page to list locations from the selected Collection
     This is a page to list locations from the selected Collection
     """
     """
-    choices = models.ForeignKey(
+    collection = models.ForeignKey(
         Collection,
         Collection,
         limit_choices_to=~models.Q(name__in=['Root']),
         limit_choices_to=~models.Q(name__in=['Root']),
         null=True,
         null=True,
@@ -211,19 +209,12 @@ class GalleryPage(BasePageFieldsMixin, Page):
     )
     )
 
 
     content_panels = BasePageFieldsMixin.content_panels + [
     content_panels = BasePageFieldsMixin.content_panels + [
-        FieldPanel('choices'),
+        FieldPanel('collection'),
     ]
     ]
 
 
-    # parent_page_types = [
-    #     'home.HomePage'
-    # ]
-
     # Defining what content type can sit under the parent. Since it's a blank
     # Defining what content type can sit under the parent. Since it's a blank
     # array no subpage can be added
     # array no subpage can be added
-    subpage_types = [
+    subpage_types = []
-    ]
-
-    # api_fields = ['introduction']
 
 
 
 
 class FormField(AbstractFormField):
 class FormField(AbstractFormField):
@@ -253,22 +244,3 @@ class FormPage(AbstractEmailForm):
             FieldPanel('subject'),
             FieldPanel('subject'),
         ], "Email"),
         ], "Email"),
     ]
     ]
-
-
-class PeopleModelAdmin(ModelAdmin):
-    model = People
-    menu_label = 'People'  # ditch this to use verbose_name_plural from model
-    menu_icon = 'fa-people'  # change as required
-    list_display = ('first_name', 'last_name', 'job_title', 'thumb_image')
-
-
-class MyModelAdminGroup(ModelAdminGroup):
-    menu_label = 'WagtailBakery'
-    menu_icon = 'folder-open-inverse'  # change as required
-    menu_order = 200  # will put in 3rd place (000 being 1st, 100 2nd)
-    items = (PeopleModelAdmin,)
-
-
-# When using a ModelAdminGroup class to group several ModelAdmin classes together,
-# you only need to register the ModelAdminGroup class with Wagtail:
-modeladmin_register(MyModelAdminGroup)

+ 3 - 4
bakerydemo/base/templatetags/gallery_tags.py

@@ -1,17 +1,16 @@
 from django import template
 from django import template
 
 
-from wagtail.wagtailcore.models import Page
 from wagtail.wagtailimages.models import Image
 from wagtail.wagtailimages.models import Image
 
 
-
 register = template.Library()
 register = template.Library()
 
 
+
 # Retrieves a single gallery item and returns a gallery of images
 # Retrieves a single gallery item and returns a gallery of images
 @register.inclusion_tag('tags/gallery.html', takes_context=True)
 @register.inclusion_tag('tags/gallery.html', takes_context=True)
 def gallery(context, gallery):
 def gallery(context, gallery):
     images = Image.objects.filter(collection=gallery)
     images = Image.objects.filter(collection=gallery)
-    
+
     return {
     return {
         'images': images,
         'images': images,
         'request': context['request'],
         'request': context['request'],
-    }
+    }

+ 62 - 0
bakerydemo/base/wagtail_hooks.py

@@ -0,0 +1,62 @@
+from wagtail.contrib.modeladmin.options import (
+    ModelAdmin, ModelAdminGroup, modeladmin_register)
+
+from bakerydemo.breads.models import Country, BreadType
+from bakerydemo.base.models import People, FooterText
+
+'''
+N.B. To see what icons are available for use in Wagtail menus and StreamField block types,
+enable the styleguide in settings:
+
+INSTALLED_APPS = (
+   ...
+   'wagtail.contrib.wagtailstyleguide',
+   ...
+)
+
+or see http://kave.github.io/general/2015/12/06/wagtail-streamfield-icons.html
+
+This demo project includes the full font-awesome set via CDN in base.html, so the entire
+font-awesome icon set is available to you. Options are at http://fontawesome.io/icons/.
+'''
+
+
+class BreadTypeAdmin(ModelAdmin):
+    # These stub classes allow us to put various models into the custom "Wagtail Bakery" menu item
+    # rather than under the default Snippets section.
+    model = BreadType
+
+
+class BreadCountryAdmin(ModelAdmin):
+    model = Country
+
+
+class BreadModelAdminGroup(ModelAdminGroup):
+    menu_label = 'Bread Categories'
+    menu_icon = 'fa-suitcase'  # change as required
+    menu_order = 200  # will put in 3rd place (000 being 1st, 100 2nd)
+    items = (BreadTypeAdmin, BreadCountryAdmin)
+
+
+class PeopleModelAdmin(ModelAdmin):
+    model = People
+    menu_label = 'People'  # ditch this to use verbose_name_plural from model
+    menu_icon = 'fa-users'  # change as required
+    list_display = ('first_name', 'last_name', 'job_title', 'thumb_image')
+
+
+class FooterTextAdmin(ModelAdmin):
+    model = FooterText
+
+
+class BakeryModelAdminGroup(ModelAdminGroup):
+    menu_label = 'Bakery Misc'
+    menu_icon = 'fa-cutlery'  # change as required
+    menu_order = 300  # will put in 4th place (000 being 1st, 100 2nd)
+    items = (PeopleModelAdmin, FooterTextAdmin)
+
+
+# When using a ModelAdminGroup class to group several ModelAdmin classes together,
+# you only need to register the ModelAdminGroup class with Wagtail:
+modeladmin_register(BreadModelAdminGroup)
+modeladmin_register(BakeryModelAdminGroup)

+ 1 - 1
bakerydemo/breads/models.py

@@ -1,5 +1,5 @@
-from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
 from django.db import models
 from django.db import models
+from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
 
 
 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.fields import StreamField

+ 2 - 2
bakerydemo/templates/base/gallery_page.html

@@ -18,8 +18,8 @@
 <div class="container">
 <div class="container">
     <div class="row">
     <div class="row">
         <div class="col-xs-12">
         <div class="col-xs-12">
-            {{ page.introduction }}
+            <h2>{{ page.introduction }}</h2>
-            {% gallery page.choices %}
+            {% gallery page.collection %}
         </div>
         </div>
     </div>
     </div>
 </div>
 </div>

+ 1 - 1
bakerydemo/templates/tags/gallery.html

@@ -3,7 +3,7 @@
 {% for img in images %}
 {% for img in images %}
 {% image img fill-285x200-c100 as img_obj %}
 {% image img fill-285x200-c100 as img_obj %}
 <div class="col-sm-6">
 <div class="col-sm-6">
-	<a href="">
+	<a href="{{img_obj.image.get_usage.first.specific.url}}">
 		<figure class="gallery-figure">
 		<figure class="gallery-figure">
 			<img src="{{img_obj.url}}" class="img-responsive" />
 			<img src="{{img_obj.url}}" class="img-responsive" />
 			<figcaption>{{ img.title }}</figcaption>
 			<figcaption>{{ img.title }}</figcaption>

+ 17 - 10
readme.md

@@ -6,11 +6,17 @@ This is a demonstration project for [Wagtail CMS](http://wagtail.io).
 *We do __not__ recommend using this project to start your own site*. This project is only to provide some examples of
 *We do __not__ recommend using this project to start your own site*. This project is only to provide some examples of
 implementing common features, it is not an exemplar of Django or Wagtail best practice.
 implementing common features, it is not an exemplar of Django or Wagtail best practice.
 
 
-If you're reasonably new to Python/Django, we suggest you run this project on a Virtual Machine using Vagrant, which
+This project can be installed in one of three ways:
-helps  resolve common software dependency issues. However for more experienced developers, instructions to start this
-project without Vagrant follow below.
 
 
-Once you're familiar with the examples in this project and you want to start a real site, we strongly recommend running
+- Vagrant
+- Docker
+- Traditional/manual Django setup
+
+If you're new to Python/Django, we suggest you run this project on a Virtual Machine using Vagrant or
+via Docker, both of which help resolve common software dependency issues. Developers more familiar with
+virtualenv and traditional Django app setup instructions should use the Local Setup instructions below.
+
+Once you're familiar with the examples in this project and you want to start a real site, run
 the ``wagtail start`` command in a fresh virtual environment, explained in the
 the ``wagtail start`` command in a fresh virtual environment, explained in the
 [Wagtail CMS Documentation](http://wagtail.readthedocs.org/en/latest/getting_started/).
 [Wagtail CMS Documentation](http://wagtail.readthedocs.org/en/latest/getting_started/).
 
 
@@ -70,15 +76,16 @@ docker-compose logs -f
 
 
 Local Setup
 Local Setup
 -----------
 -----------
-Don't want to set up a whole VM nor use Docker to try out Wagtail? No problem.
+Don't want to set up a whole Vagrant VM or use Docker to try out Wagtail? No problem. You'll probably want to start
-
+with a fresh virtualenv.
-### Dependencies
-* [PIP](https://github.com/pypa/pip)
 
 
 ### Installation
 ### Installation
 
 
-With PIP installed run the following commands:
+With [PIP](https://github.com/pypa/pip) and [virtualenvwrapper](https://virtualenvwrapper.readthedocs.io/en/latest/)
+installed, run:
 
 
+    mkvirtualenv wagtailbakerydemo
+    cd ~/dev [or your preferred dev directory]
     git clone git@github.com:wagtail/bakerydemo.git
     git clone git@github.com:wagtail/bakerydemo.git
     cd wagtaildemo
     cd wagtaildemo
     pip install -r requirements.txt
     pip install -r requirements.txt
@@ -89,7 +96,7 @@ to help with this. It reads environment variables located in a file name .env in
     $ cp bakerydemo/settings/local.py.example bakerydemo/settings/local.py
     $ cp bakerydemo/settings/local.py.example bakerydemo/settings/local.py
     $ echo "DJANGO_SETTINGS_MODULE=bakerydemo.settings.local" > .env
     $ echo "DJANGO_SETTINGS_MODULE=bakerydemo.settings.local" > .env
 
 
-Execute the following commands:
+To set up your database and load initial data, run the following commands:
 
 
     ./manage.py migrate
     ./manage.py migrate
     ./manage.py load_initial_data
     ./manage.py load_initial_data