1
Fork 0

add blog model stuff

This commit is contained in:
Jake Howard 2016-11-24 21:44:08 +00:00
parent 84b77d2d6a
commit 004195e843
11 changed files with 137 additions and 2 deletions

0
project/blog/__init__.py Normal file
View file

View file

@ -0,0 +1,34 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.3 on 2016-11-24 20:51
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
import wagtail.wagtailcore.fields
class Migration(migrations.Migration):
initial = True
dependencies = [
('wagtailcore', '0030_index_on_pagerevision_created_at'),
('wagtailimages', '0015_fill_filter_spec_field'),
]
operations = [
migrations.CreateModel(
name='BlogPage',
fields=[
('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='wagtailcore.Page')),
('date', models.DateField(verbose_name='Post date')),
('intro', models.CharField(max_length=250)),
('body', wagtail.wagtailcore.fields.RichTextField(blank=True)),
('main_image', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='wagtailimages.Image')),
],
options={
'abstract': False,
},
bases=('wagtailcore.page',),
),
]

View file

32
project/blog/models.py Normal file
View file

@ -0,0 +1,32 @@
from django.db import models
from wagtail.wagtailcore.models import Page
from wagtail.wagtailcore.fields import RichTextField
from wagtail.wagtailadmin.edit_handlers import FieldPanel
from wagtail.wagtailimages.edit_handlers import ImageChooserPanel
from wagtail.wagtailsearch import index
class BlogPage(Page):
main_image = models.ForeignKey(
'wagtailimages.Image',
null=True,
blank=True,
on_delete=models.SET_NULL,
related_name='+'
)
date = models.DateField("Post date")
intro = models.CharField(max_length=250)
body = RichTextField(blank=True)
search_fields = Page.search_fields + [
index.SearchField('intro'),
index.SearchField('body'),
]
content_panels = Page.content_panels + [
FieldPanel('date'),
ImageChooserPanel('main_image'),
FieldPanel('intro'),
FieldPanel('body'),
]

View file

@ -0,0 +1,30 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.3 on 2016-11-24 21:20
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
import wagtail.wagtailcore.fields
class Migration(migrations.Migration):
initial = True
dependencies = [
('wagtailcore', '0030_index_on_pagerevision_created_at'),
]
operations = [
migrations.CreateModel(
name='SectionIndexPage',
fields=[
('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='wagtailcore.Page')),
('intro', wagtail.wagtailcore.fields.RichTextField(blank=True)),
],
options={
'abstract': False,
},
bases=('wagtailcore.page',),
),
]

View file

11
project/common/models.py Normal file
View file

@ -0,0 +1,11 @@
from wagtail.wagtailcore.models import Page
from wagtail.wagtailcore.fields import RichTextField
from wagtail.wagtailadmin.edit_handlers import FieldPanel
class SectionIndexPage(Page):
intro = RichTextField(blank=True)
content_panels = Page.content_panels + [
FieldPanel('intro', classname="full")
]

View file

@ -1,5 +1,3 @@
from __future__ import unicode_literals
from wagtail.wagtailcore.models import Page from wagtail.wagtailcore.models import Page
from wagtail.wagtailcore.fields import RichTextField from wagtail.wagtailcore.fields import RichTextField
from wagtail.wagtailadmin.edit_handlers import FieldPanel from wagtail.wagtailadmin.edit_handlers import FieldPanel

View file

@ -45,6 +45,7 @@ INSTALLED_APPS = [
'django.contrib.messages', 'django.contrib.messages',
'django.contrib.staticfiles', 'django.contrib.staticfiles',
'project.blog',
'project.common', 'project.common',
'project.home', 'project.home',
'project.search', 'project.search',

View file

@ -0,0 +1,18 @@
{% extends "base.html" %}
{% load wagtailcore_tags wagtailimages_tags %}
{% block body_class %}template-blogpage{% endblock %}
{% block content %}
<h1>{{ page.title }}</h1>
<p class="meta">{{ page.date }}</p>
{% if page.main_image %}
{% image page.main_image width-400 %}
{% endif %}
<div class="intro">{{ page.intro }}</div>
{{ page.body|richtext }}
{% endblock %}

View file

@ -0,0 +1,11 @@
{% extends "base.html" %}
{% load wagtailcore_tags %}
{% block body_class %}template-indexpage{% endblock %}
{% block content %}
<h1>{{ page.title }}</h1>
<div class="intro">{{ page.intro|richtext }}</div>
{% endblock %}