Forráskód Böngészése

Merge branch 'master' of github.com:wagtail/bakerydemo

Edd Baldry 8 éve
szülő
commit
1251d82fa6

+ 34 - 0
bakerydemo/base/migrations/0008_auto_20170211_2232.py

@@ -0,0 +1,34 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.10.5 on 2017-02-11 22:32
+from __future__ import unicode_literals
+
+from django.db import migrations
+import wagtail.wagtailcore.blocks
+import wagtail.wagtailcore.fields
+import wagtail.wagtailembeds.blocks
+import wagtail.wagtailimages.blocks
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('base', '0007_merge_20170210_1627'),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name='aboutpage',
+            name='body',
+            field=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((('text', wagtail.wagtailcore.blocks.TextBlock()), ('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'),
+        ),
+        migrations.AlterField(
+            model_name='formpage',
+            name='body',
+            field=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((('text', wagtail.wagtailcore.blocks.TextBlock()), ('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')))),
+        ),
+        migrations.AlterField(
+            model_name='homepage',
+            name='body',
+            field=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((('text', wagtail.wagtailcore.blocks.TextBlock()), ('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='Home page detail'),
+        ),
+    ]

+ 21 - 0
bakerydemo/locations/migrations/0002_auto_20170211_2229.py

@@ -0,0 +1,21 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.10.5 on 2017-02-11 22:29
+from __future__ import unicode_literals
+
+import django.core.validators
+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, validators=[django.core.validators.RegexValidator(code='invalid_lat_long', message='Lat Long must be a comma separated numeric lat and long', regex='^(\\-?\\d+(\\.\\d+)?),\\s*(\\-?\\d+(\\.\\d+)?)$')]),
+        ),
+    ]

+ 10 - 2
bakerydemo/locations/models.py

@@ -1,3 +1,4 @@
+from django.core.validators import RegexValidator
 from django.db import models
 
 from modelcluster.fields import ParentalKey
@@ -78,7 +79,7 @@ class LocationsIndexPage(Page):
 
 class LocationPage(Page):
     """
-    Detail for a specific location
+    Detail for a specific bakery location.
     """
 
     address = models.TextField()
@@ -92,7 +93,14 @@ class LocationPage(Page):
     lat_long = models.CharField(
         max_length=36,
         help_text="Comma separated lat/long. (Ex. 64.144367, -21.939182) \
-                   Right click Google Maps and click 'What\'s Here'"
+                   Right click Google Maps and select 'What\'s Here'",
+        validators=[
+            RegexValidator(
+                regex='^(\-?\d+(\.\d+)?),\s*(\-?\d+(\.\d+)?)$',
+                message='Lat Long must be a comma-separated numeric lat and long',
+                code='invalid_lat_long'
+            ),
+        ]
     )
 
     # Search index configuration

+ 1 - 1
bakerydemo/search/views.py

@@ -11,7 +11,7 @@ from bakerydemo.locations.models import LocationPage
 
 def search(request):
     # Search
-    search_query = request.GET.get('query', None)
+    search_query = request.GET.get('q', None)
     if search_query:
         """
         Because we can't use ElasticSearch for the demo, we use the native db search.

+ 4 - 1
bakerydemo/templates/base.html

@@ -12,11 +12,14 @@
     {# Header contains the main_navigation block #}
 {% endblock header %}
 
+{% block head-extra %}
+{% endblock head-extra %}
+
 {% block messages %}
     {% include "includes/messages.html" %}
 {% endblock messages %}
 
-    <content> 
+    <content>
         {% block content-header %}
         {% endblock content-header %}
 

+ 1 - 1
bakerydemo/templates/base/form_page.html

@@ -6,7 +6,7 @@
     {{ page.intro|richtext }}
 {% endblock content-header %}
 
-{% endblock content-body %}
+{% block content-body %}
     <form action="{% pageurl page %}" method="POST">
         {% csrf_token %}
         {{ form.as_p }}

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

@@ -6,10 +6,10 @@
 
     <div class="image">
         {% image page.image width-500 as photo %}
-              <img src="{{ photo.url }}" width="{{ photo.width }}" height="{{ photo.height }}" alt="{{ photo.alt }}" />
+        <img src="{{ photo.url }}" width="{{ photo.width }}" height="{{ photo.height }}" alt="{{ photo.alt }}" />
     </div>
 {% endblock content-header %}
 
-{% endblock content-body %}
+{% block content-body %}
     {{ page.body }}
 {% endblock content-body %}

+ 2 - 2
bakerydemo/templates/breads/bread_page.html

@@ -8,8 +8,8 @@
     </figure>
 {% endblock content-header %}
 
-{% endblock content %}
+{% block content-body %}
     <p>{{ page.origin }}</p>
     <p>{{ page.bread_type }}</p>
     {{ page.description }}
-{% endblock content %}
+{% endblock content-body %}

+ 6 - 6
bakerydemo/templates/locations/location_page.html

@@ -26,10 +26,13 @@
 {% endblock content-header %}
 
 {% block content-body %}
-    <p>{{ page.address }}</p>
-    <p>{{ page.lat_long }}</p>
-
+    <p>{{ page.address|linebreaks }}</p>
     <div id="map" class="maps embed-container"></div>
+
+    {% for hours in page.opening_hours %}
+        <li>{{ hours }}</li>
+    {% endfor %}
+
     <script>
       var map;
       function initMap() {
@@ -52,7 +55,4 @@
     </script>
     <script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyD31CT9P9KxvNUJOwDq2kcFEIG8ADgaFgw&callback=initMap" async defer></script>
 
-    {% for hours in page.opening_hours %}
-        <li>{{ hours }}</li>
-    {% endfor %}
 {% endblock content-body %}

+ 3 - 3
bakerydemo/templates/locations/locations_index_page.html

@@ -1,5 +1,5 @@
 {% extends "base.html" %}
-{% load wagtailimages_tags %}
+{% load wagtailcore_tags %}
 
 {% block content-header %}
     {{ page.title }}
@@ -7,6 +7,6 @@
 
 {% block content-body %}
     {% for location in locations %}
-        <div><a href="{{ location.slug }}">{{ location.title }}</a></div>
+        <div><a href="{% pageurl location %}">{{ location.title }}</a></div>
     {% endfor %}
-{% endblock content-body %}
+{% endblock content-body %}