Переглянути джерело

add missing form landing page, tweak the getter for Gallery image collections

David Ray 8 роки тому
батько
коміт
b68225c2b8

+ 21 - 0
bakerydemo/base/migrations/0005_auto_20170209_1721.py

@@ -0,0 +1,21 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.10.5 on 2017-02-09 17:21
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+import django.db.models.deletion
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('base', '0004_aboutlocationrelationship'),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name='gallerypage',
+            name='choices',
+            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='wagtailcore.Collection'),
+        ),
+    ]

+ 8 - 24
bakerydemo/base/models.py

@@ -1,6 +1,7 @@
 from __future__ import unicode_literals
 
 from django.db import models
+from django.db.utils import OperationalError
 
 from modelcluster.fields import ParentalKey
 from modelcluster.models import ClusterableModel
@@ -111,34 +112,17 @@ class AboutPage(Page):
     # 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 [('', '')]
-
-
 class GalleryPage(Page):
     """
     This is a page to list all the locations on the site
     """
-    # try:
-    CHOICES_LIST = getImageCollections()
-    # except:
-    #     CHOICES_LIST = [("", "")]
-    # To return our collection choices for the editor to access we need to
-    # make the choices list a variable rather than a function
-
-    choices = models.CharField(
-        max_length=255, choices=CHOICES_LIST
-        )
-
+    choices = models.ForeignKey(
+        Collection,
+        limit_choices_to=~models.Q(name__in=['Root']),
+        null=True,
+        blank=True,
+        on_delete=models.SET_NULL,
+    )
     image = models.ForeignKey(
         'wagtailimages.Image',
         null=True,

+ 9 - 0
bakerydemo/templates/base/form_page_landing.html

@@ -0,0 +1,9 @@
+<html>
+    <head>
+        <title>{{ page.title }}</title>
+    </head>
+    <body>
+        <h1>{{ page.title }}</h1>
+        <h2>Thanks for your submission!</h2>
+    </body>
+</html>