diff --git a/project/common/models.py b/project/common/models.py new file mode 100644 index 0000000..459b508 --- /dev/null +++ b/project/common/models.py @@ -0,0 +1,33 @@ +from wagtail.core.models import Page +from django.db import models +from wagtail.admin.edit_handlers import FieldPanel, MultiFieldPanel +from wagtail.images.edit_handlers import ImageChooserPanel +from wagtailmetadata.models import MetadataPageMixin + + +class Entity(MetadataPageMixin, Page): + is_home = False + + created = models.DateTimeField(auto_now_add=True) + modified = models.DateTimeField(auto_now=True) + post_date = models.DateTimeField(null=True, blank=True) + + promote_panels = [ + MultiFieldPanel([ + FieldPanel('slug'), + FieldPanel('seo_title'), + FieldPanel('post_date'), + FieldPanel('search_description'), + ImageChooserPanel('search_image'), + ], 'Common page configuration'), + ] + + @property + def image(self): + return self.search_image + + def get_meta_description(self): + return self.search_description or self.short_body + + class Meta: + abstract = True diff --git a/project/home/migrations/0003_auto_20180724_1934.py b/project/home/migrations/0003_auto_20180724_1934.py new file mode 100644 index 0000000..eea7290 --- /dev/null +++ b/project/home/migrations/0003_auto_20180724_1934.py @@ -0,0 +1,44 @@ +# Generated by Django 2.0.7 on 2018-07-24 19:34 + +from django.db import migrations, models +import django.db.models.deletion +import django.utils.timezone +import wagtail.core.fields + + +class Migration(migrations.Migration): + + dependencies = [ + ('wagtailimages', '0020_add-verbose-name'), + ('home', '0002_create_homepage'), + ] + + operations = [ + migrations.AddField( + model_name='homepage', + name='body', + field=wagtail.core.fields.RichTextField(default=''), + preserve_default=False, + ), + migrations.AddField( + model_name='homepage', + name='created', + field=models.DateTimeField(auto_now_add=True, default=django.utils.timezone.now), + preserve_default=False, + ), + migrations.AddField( + model_name='homepage', + name='modified', + field=models.DateTimeField(auto_now=True), + ), + migrations.AddField( + model_name='homepage', + name='post_date', + field=models.DateTimeField(blank=True, null=True), + ), + migrations.AddField( + model_name='homepage', + name='search_image', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='wagtailimages.Image'), + ), + ] diff --git a/project/home/models.py b/project/home/models.py index af7b579..4882ee4 100644 --- a/project/home/models.py +++ b/project/home/models.py @@ -1,7 +1,14 @@ -from django.db import models - from wagtail.core.models import Page +from wagtail.core.fields import RichTextField +from wagtail.admin.edit_handlers import FieldPanel +from project.common.models import Entity -class HomePage(Page): - pass +class HomePage(Entity): + is_home = True + + body = RichTextField() + + content_panels = Entity.content_panels + [ + FieldPanel('body', classname="full") + ] diff --git a/project/home/templates/home/home_page.html b/project/home/templates/home/home_page.html deleted file mode 100644 index 8b7df4e..0000000 --- a/project/home/templates/home/home_page.html +++ /dev/null @@ -1,11 +0,0 @@ -{% extends "base.html" %} - -{% block body_class %}template-homepage{% endblock %} - -{% block content %} -
You can access the admin interface here (make sure you have run "./manage.py createsuperuser" in the console first).
- -If you haven't already given the documentation a read, head over to http://docs.wagtail.io to start building on Wagtail
-{% endblock %} diff --git a/project/settings.py b/project/settings.py index dd1ade2..b11add6 100644 --- a/project/settings.py +++ b/project/settings.py @@ -27,6 +27,7 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) INSTALLED_APPS = [ 'project.home', 'project.search', + 'project.common', 'wagtail.contrib.forms', 'wagtail.contrib.redirects', @@ -43,6 +44,8 @@ INSTALLED_APPS = [ 'modelcluster', 'taggit', + 'wagtailmetadata', + 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', diff --git a/templates/404.html b/templates/404.html index 3a5500e..46b889d 100644 --- a/templates/404.html +++ b/templates/404.html @@ -1,9 +1,3 @@ -{% extends "base.html" %} +