Browse Source

resolve merge from master

David Ray 8 years ago
parent
commit
9d193368b7

+ 0 - 1
app.json

@@ -2,7 +2,6 @@
   "name": "WagtailBakeryDemo",
   "description": "WagtailBakeryDemo",
   "repository": "https://github.com/wagtail/bakerydemo",
-  "logo": "http://wagtail.io/static/wagtailsite/images/navlogo2.png",
   "keywords": ["wagtail", "django"],
   "env": {
     "DJANGO_SETTINGS_MODULE": "bakerydemo.settings.heroku"

+ 7 - 15
bakerydemo/blog/models.py

@@ -111,13 +111,10 @@ class BlogPage(Page):
 
     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
+    # Define what content types can exist as children of BlogPage.
+    # Empty list means that no child content types are allowed.
     subpage_types = []
 
-    # api_fields = ['image', 'body']
-
 
 class BlogIndexPage(RoutablePageMixin, Page):
     """
@@ -125,8 +122,9 @@ class BlogIndexPage(RoutablePageMixin, Page):
     We need to alter the page model's context to return the child page objects - the
     BlogPage - so that it works as an index page
 
-    The RoutablePageMixin is used to allow for a custom sub-URL
+    RoutablePageMixin is used to allow for a custom sub-URL for tag views.
     """
+
     image = models.ForeignKey(
         'wagtailimages.Image',
         null=True,
@@ -145,12 +143,7 @@ class BlogIndexPage(RoutablePageMixin, Page):
         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
+    # What pages types can live under this page type?
     subpage_types = ['BlogPage']
 
     def get_context(self, request):
@@ -168,6 +161,7 @@ class BlogIndexPage(RoutablePageMixin, Page):
         return all related BlogPages for a given Tag or redirect back to
         the BlogIndexPage
         """
+
         try:
             tag = Tag.objects.get(slug=tag)
         except Tag.DoesNotExist:
@@ -179,9 +173,7 @@ class BlogIndexPage(RoutablePageMixin, Page):
         blogs = BlogPage.objects.filter(tags=tag).live().descendant_of(self)
 
         context = {
-            'title': 'Posts tagged with: {}'.format(tag.name),
+            'tag': tag,
             'blogs': blogs
         }
         return render(request, 'blog/blog_index_page.html', context)
-
-    # api_fields = ['introduction']

+ 21 - 0
bakerydemo/locations/migrations/0003_auto_20170215_0723.py

@@ -0,0 +1,21 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.10.5 on 2017-02-15 07:23
+from __future__ import unicode_literals
+
+import django.core.validators
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('locations', '0002_auto_20170211_2229'),
+    ]
+
+    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 select '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+)?)$')]),
+        ),
+    ]

+ 1 - 1
bakerydemo/locations/models.py

@@ -73,7 +73,7 @@ class LocationsIndexPage(Page):
         context = super(LocationsIndexPage, self).get_context(request)
         context['locations'] = LocationPage.objects.descendant_of(
             self).live().order_by(
-            '-first_published_at')
+            'title')
         return context
 
 

+ 1 - 1
bakerydemo/settings/heroku.py

@@ -6,7 +6,7 @@ from .base import *
 # Accept all hostnames, since we don't know in advance which hostname will be used for any given Heroku instance.
 # IMPORTANT: Set this to a real hostname when using this in production!
 # See https://docs.djangoproject.com/en/1.10/ref/settings/#allowed-hosts
-ALLOWED_HOSTS = ['*', 'wagtailbakerydemo.herokuapp.com']
+ALLOWED_HOSTS = ['*', ]
 
 EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
 

+ 9 - 1
bakerydemo/static/css/main.css

@@ -75,6 +75,15 @@ a.btn:hover {
   color: white;
 }
 
+a.btn-sm {
+    padding: 6px 8px;
+    font-size: 10px;
+    line-height: normal;
+    -webkit-border-radius: 4px;
+       -moz-border-radius: 4px;
+            border-radius: 4px;
+    }
+
 input {
   border-radius: 3px;
   border: none;
@@ -495,4 +504,3 @@ li.has-submenu a.allow-toggle {
 .navbar-toggle .icon-bar {
   background-color: #fff;
 }
-

+ 2 - 2
bakerydemo/templates/404.html

@@ -4,8 +4,8 @@
 
 {% block body_class %}template-404{% endblock %}
 
-{% block content %}
+{% block content-header %}
     <h1>Page not found</h1>
 
     <h2>Sorry, this page could not be found.</h2>
-{% endblock %}
+{% endblock content-header %}

+ 4 - 2
bakerydemo/templates/about_page.html

@@ -1,13 +1,15 @@
 {% extends "base.html" %}
 {% load wagtailimages_tags %}
 
-{% block content %}
+{% block content-header %}
     {{ page.title }}
 
     <div class="image">
         {% image page.image width-500 as photo %}
               <img src="{{ photo.url }}" width="{{ photo.width }}" height="{{ photo.height }}" alt="{{ photo.alt }}" />
     </div>
+{% endblock content-header %}
 
+{% block content-body %}
     {{ page.body }}
-{% endblock content %}
+{% endblock content-body %}

+ 14 - 15
bakerydemo/templates/blog/blog_index_page.html

@@ -5,27 +5,26 @@
 <div class="container">
     <div class="row">
         <div class="col-md-7 col-md-offset-2">
-            {{ page.title }}
+            <h2>{{ page.title }}</h2>
         </div>
     </div>
 </div>
 {% endblock content-header %}
 
 {% block content-body %}
-<div class="container">
-    <div class="row">
-        <div class="col-md-7 col-md-offset-2">
-            {% for blog in blogs %}
-                <div>
-                    <h2><a href="{{ blog.url }}">{{ blog.title }}</a></h2>
-                    {{ blog.body|truncatewords_html:10 }}
-
-                    {% for tag in blog.get_tags  %}
-                        <a href="{{ tag.url }}">{{ tag }}</a>
-                    {% endfor %}
-                </div>
-            {% endfor %}
+    <div class="container">
+        <div class="row">
+            <div class="col-md-7 col-md-offset-2">
+                {% if tag %}
+                    <h3>Posts tagged with "{{ tag }}":</h3>
+                {% endif %}
+                {% for blog in blogs %}
+                    <div>
+                        <h2><a href="{{ blog.url }}">{{ blog.title }}</a></h2>
+                        {{ blog.body|truncatewords_html:10 }}
+                    </div>
+                {% endfor %}
+            </div>
         </div>
     </div>
-</div>
 {% endblock content-body %}

+ 6 - 3
bakerydemo/templates/blog/blog_page.html

@@ -26,9 +26,12 @@
 
             {{ page.body }}
 
-            {% for tag in page.get_tags  %}
-                <a href="{{ tag.url }}">{{ tag }}</a>
-            {% endfor %}
+            {% if page.get_tags %}
+                Tagged with:<br />
+                {% for tag in page.get_tags  %}
+                    <a href="{{ tag.url }}" class="btn btn-sm">{{ tag }}</a>
+                {% endfor %}
+            {% endif %}
         </div>
     </div>
 </div>

+ 6 - 1
bakerydemo/templates/locations/locations_index_page.html

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

+ 23 - 5
readme.md

@@ -1,5 +1,3 @@
-[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy?template=https://github.com/wagtail/bakerydemo)
-
 Wagtail demo project
 =======================
 
@@ -55,8 +53,8 @@ With PIP installed run the following commands:
     cd wagtaildemo
     pip install -r requirements.txt
 
-Next, we'll set up our local environment variables. We use django-dotenv to help with this. It reads environment
-variables located in a file name .env in the top level directory of the project. The only variable we need to start is
+Next, we'll set up our local environment variables. We use [django-dotenv](https://github.com/jpadilla/django-dotenv)
+to help with this. It reads environment variables located in a file name .env in the top level directory of the project. The only variable we need to start is
 DJANGO_SETTINGS_MODULE:
 
     $ cp bakerydemo/settings/local.example.py bakerydemo/settings/local.py
@@ -76,4 +74,24 @@ Because we can't (easily) use ElasticSearch for this demo, we use wagtail's nati
 However, native DB search can't search specific fields in our models on a generalized `Page` query.
 So for demo purposes ONLY, we hard-code the model names we want to search into `search.views`, which is
 not ideal. In production, use ElasticSearch and a simplified search query, per
-http://docs.wagtail.io/en/v1.8.1/topics/search/searching.html
+[http://docs.wagtail.io/en/v1.8.1/topics/search/searching.html](http://docs.wagtail.io/en/v1.8.1/topics/search/searching.html).
+
+### Heroku deployment:
+
+If you need to deploy your demo site to a publicly accessible server [Heroku](https://heroku.com)
+provides a one-click deployment solution:
+
+[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy?template=https://github.com/wagtail/bakerydemo)
+
+If you do not have a Heroku account, clicking the above button will walk you through the steps
+to generate one.  After which, you will be presented with a screen to configure your app. For our purposes,
+we will accept all of the defaults and click `Deploy`.  The status of the deployment will dynamically
+update in the browser. Once finished, click `View` to see the public site.
+
+Log into the admin with the credentials ``admin / changeme``.
+
+To learn more about Heroku, read [Deploying Python and Django Apps on Heroku](https://devcenter.heroku.com/articles/deploying-python).
+
+
+
+

+ 1 - 12
requirements.txt

@@ -1,12 +1 @@
-Django
-django-dotenv
-elasticsearch
-wagtail
-wagtailfontawesome
-Pillow
-
-# Dependencies for Heroku deployment
-dj-database-url==0.4.1
-whitenoise==3.2.2
-gunicorn==19.6.0
-psycopg2==2.6.2
+-r requirements/heroku.txt

+ 5 - 0
requirements/base.txt

@@ -0,0 +1,5 @@
+Django
+elasticsearch
+wagtail
+wagtailfontawesome
+Pillow

+ 6 - 0
requirements/heroku.txt

@@ -0,0 +1,6 @@
+-r base.txt
+# Additional dependencies for Heroku deployment
+dj-database-url
+gunicorn
+psycopg2
+whitenoise

+ 1 - 1
vagrant/provision.sh

@@ -21,7 +21,7 @@ su - vagrant -c "echo $PROJECT_DIR > $VIRTUALENV_DIR/.project"
 su - vagrant -c "$PIP install --upgrade pip"
 
 # Install PIP requirements
-su - vagrant -c "$PIP install -r $PROJECT_DIR/requirements.txt"
+su - vagrant -c "$PIP install -r $PROJECT_DIR/requirements/base.txt"
 
 
 # Set execute permissions on manage.py as they get lost if we build from a zip file