0
0
mirror of https://github.com/wagtail/wagtail.git synced 2024-12-01 11:41:20 +01:00

Added home app

This commit is contained in:
Karl Hobley 2015-05-20 07:57:17 +01:00
parent dc36328407
commit effa01919f
7 changed files with 91 additions and 0 deletions

View File

@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('wagtailcore', '__latest__'),
]
operations = [
migrations.CreateModel(
name='HomePage',
fields=[
('page_ptr', models.OneToOneField(parent_link=True, auto_created=True, primary_key=True, serialize=False, to='wagtailcore.Page')),
],
options={
'abstract': False,
},
bases=('wagtailcore.page',),
),
]

View File

@ -0,0 +1,45 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations
def create_homepage(apps, schema_editor):
# Get models
ContentType = apps.get_model('contenttypes.ContentType')
Page = apps.get_model('wagtailcore.Page')
Site = apps.get_model('wagtailcore.Site')
HomePage = apps.get_model('home.HomePage')
# Delete the default homepage
Page.objects.get(id=2).delete()
# Create content type for homepage model
homepage_content_type, created = ContentType.objects.get_or_create(
model='homepage', app_label='home')
# Create a new homepage
homepage = HomePage.objects.create(
title="Homepage",
slug='home',
content_type=homepage_content_type,
path='00010001',
depth=2,
numchild=0,
url_path='/home/',
)
# Create a site with the new homepage set as the root
Site.objects.create(
hostname='localhost', root_page=homepage, is_default_site=True)
class Migration(migrations.Migration):
dependencies = [
('home', '0001_initial'),
]
operations = [
migrations.RunPython(create_homepage),
]

View File

@ -0,0 +1,9 @@
from __future__ import unicode_literals
from django.db import models
from wagtail.wagtailcore.models import Page
class HomePage(Page):
pass

View File

@ -0,0 +1,11 @@
{% templatetag openblock %} extends "base.html" {% templatetag closeblock %}
{% templatetag openblock %} block body_class {% templatetag closeblock %}template-{% templatetag openvariable %} self.get_verbose_name|slugify {% templatetag closevariable %}{% templatetag openblock %} endblock {% templatetag closeblock %}
{% templatetag openblock %} block content {% templatetag closeblock %}
<h1>Welcome to your new Wagtail site!</h1>
<p>You can access the admin interface <a href="{% templatetag openblock %} url 'wagtailadmin_home' {% templatetag closeblock %}">here</a> (make sure you have run "./manage.py createsuperuser" in the console first).
<p>If you haven't already given the documentation a read, head over to <a href="http://wagtail.readthedocs.org/">http://wagtail.readthedocs.org</a> to start building on Wagtail</p>
{% templatetag openblock %} endblock {% templatetag closeblock %}

View File

@ -46,6 +46,8 @@ INSTALLED_APPS = (
'wagtail.wagtailembeds',
'wagtail.wagtailredirects',
'wagtail.wagtailforms',
'{{ project_name }}.home',
)
MIDDLEWARE_CLASSES = (