normalise images / metadata and add post date
This commit is contained in:
parent
f9516297cf
commit
6fb084a3c8
13 changed files with 219 additions and 30 deletions
24
project/blog/migrations/0002_auto_20161216_1753.py
Normal file
24
project/blog/migrations/0002_auto_20161216_1753.py
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Generated by Django 1.10.4 on 2016-12-16 17:53
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('blog', '0001_initial'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RenameField(
|
||||||
|
model_name='blogpage',
|
||||||
|
old_name='main_image',
|
||||||
|
new_name='image',
|
||||||
|
),
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='blogpage',
|
||||||
|
name='intro',
|
||||||
|
),
|
||||||
|
]
|
24
project/blog/migrations/0003_auto_20161216_1822.py
Normal file
24
project/blog/migrations/0003_auto_20161216_1822.py
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Generated by Django 1.10.4 on 2016-12-16 18:22
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('blog', '0002_auto_20161216_1753'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='blogpage',
|
||||||
|
name='date',
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='blogpage',
|
||||||
|
name='post_date',
|
||||||
|
field=models.DateTimeField(blank=True, null=True),
|
||||||
|
),
|
||||||
|
]
|
|
@ -2,32 +2,18 @@ from django.db import models
|
||||||
from project.common.blocks import build_stream_field
|
from project.common.blocks import build_stream_field
|
||||||
from wagtail.wagtailcore.models import Page
|
from wagtail.wagtailcore.models import Page
|
||||||
from wagtail.wagtailadmin.edit_handlers import FieldPanel, StreamFieldPanel
|
from wagtail.wagtailadmin.edit_handlers import FieldPanel, StreamFieldPanel
|
||||||
from wagtail.wagtailimages.edit_handlers import ImageChooserPanel
|
|
||||||
from wagtail.wagtailsearch import index
|
from wagtail.wagtailsearch import index
|
||||||
|
|
||||||
from project.common.models import Entity
|
from project.common.models import Entity
|
||||||
|
|
||||||
|
|
||||||
class BlogPage(Entity):
|
class BlogPage(Entity):
|
||||||
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 = build_stream_field()
|
body = build_stream_field()
|
||||||
|
|
||||||
search_fields = Page.search_fields + [
|
search_fields = Page.search_fields + [
|
||||||
index.SearchField('intro'),
|
|
||||||
index.SearchField('body'),
|
index.SearchField('body'),
|
||||||
]
|
]
|
||||||
|
|
||||||
content_panels = Page.content_panels + [
|
content_panels = Page.content_panels + [
|
||||||
FieldPanel('date'),
|
|
||||||
ImageChooserPanel('main_image'),
|
|
||||||
FieldPanel('intro'),
|
|
||||||
StreamFieldPanel('body'),
|
StreamFieldPanel('body'),
|
||||||
]
|
]
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
from wagtail.wagtailcore.models import Page
|
from wagtail.wagtailcore.models import Page
|
||||||
from django.db import models
|
from django.db import models
|
||||||
|
from wagtail.wagtailadmin.edit_handlers import FieldPanel, MultiFieldPanel
|
||||||
|
from wagtail.wagtailimages.edit_handlers import ImageChooserPanel
|
||||||
from wagtailmetadata.models import MetadataPageMixin
|
from wagtailmetadata.models import MetadataPageMixin
|
||||||
|
|
||||||
|
|
||||||
|
@ -8,6 +10,27 @@ class Entity(MetadataPageMixin, Page):
|
||||||
|
|
||||||
created = models.DateTimeField(auto_now_add=True)
|
created = models.DateTimeField(auto_now_add=True)
|
||||||
modified = models.DateTimeField(auto_now=True)
|
modified = models.DateTimeField(auto_now=True)
|
||||||
|
post_date = models.DateTimeField(null=True, blank=True)
|
||||||
|
image = models.ForeignKey(
|
||||||
|
'wagtailimages.Image',
|
||||||
|
null=True,
|
||||||
|
blank=True,
|
||||||
|
related_name='+',
|
||||||
|
on_delete=models.SET_NULL
|
||||||
|
)
|
||||||
|
|
||||||
|
promote_panels = [
|
||||||
|
MultiFieldPanel([
|
||||||
|
FieldPanel('slug'),
|
||||||
|
FieldPanel('seo_title'),
|
||||||
|
FieldPanel('post_date'),
|
||||||
|
FieldPanel('search_description'),
|
||||||
|
ImageChooserPanel('image'),
|
||||||
|
], 'Common page configuration'),
|
||||||
|
]
|
||||||
|
|
||||||
|
def get_meta_image(self):
|
||||||
|
return self.image
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
abstract = True
|
abstract = True
|
||||||
|
|
22
project/home/migrations/0002_homepage_image.py
Normal file
22
project/home/migrations/0002_homepage_image.py
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Generated by Django 1.10.4 on 2016-12-16 17:53
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('wagtailimages', '0015_fill_filter_spec_field'),
|
||||||
|
('home', '0001_initial'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='homepage',
|
||||||
|
name='image',
|
||||||
|
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='wagtailimages.Image'),
|
||||||
|
),
|
||||||
|
]
|
20
project/home/migrations/0003_homepage_post_date.py
Normal file
20
project/home/migrations/0003_homepage_post_date.py
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Generated by Django 1.10.4 on 2016-12-16 18:22
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('home', '0002_homepage_image'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='homepage',
|
||||||
|
name='post_date',
|
||||||
|
field=models.DateTimeField(blank=True, null=True),
|
||||||
|
),
|
||||||
|
]
|
32
project/pages/migrations/0002_auto_20161216_1753.py
Normal file
32
project/pages/migrations/0002_auto_20161216_1753.py
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Generated by Django 1.10.4 on 2016-12-16 17:53
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('wagtailimages', '0015_fill_filter_spec_field'),
|
||||||
|
('pages', '0001_initial'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RenameField(
|
||||||
|
model_name='sectionindexpage',
|
||||||
|
old_name='intro',
|
||||||
|
new_name='body',
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='sectionindexpage',
|
||||||
|
name='image',
|
||||||
|
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='wagtailimages.Image'),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='simplecontentpage',
|
||||||
|
name='image',
|
||||||
|
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='wagtailimages.Image'),
|
||||||
|
),
|
||||||
|
]
|
25
project/pages/migrations/0003_auto_20161216_1822.py
Normal file
25
project/pages/migrations/0003_auto_20161216_1822.py
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Generated by Django 1.10.4 on 2016-12-16 18:22
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('pages', '0002_auto_20161216_1753'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='sectionindexpage',
|
||||||
|
name='post_date',
|
||||||
|
field=models.DateTimeField(blank=True, null=True),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='simplecontentpage',
|
||||||
|
name='post_date',
|
||||||
|
field=models.DateTimeField(blank=True, null=True),
|
||||||
|
),
|
||||||
|
]
|
|
@ -15,10 +15,10 @@ class SimpleContentPage(Entity):
|
||||||
|
|
||||||
|
|
||||||
class SectionIndexPage(Entity):
|
class SectionIndexPage(Entity):
|
||||||
intro = RichTextField(blank=True)
|
body = RichTextField(blank=True)
|
||||||
hide_list = models.BooleanField(default=False)
|
hide_list = models.BooleanField(default=False)
|
||||||
|
|
||||||
content_panels = Page.content_panels + [
|
content_panels = Page.content_panels + [
|
||||||
FieldPanel('intro', classname="full"),
|
FieldPanel('body', classname="full"),
|
||||||
FieldPanel('hide_list')
|
FieldPanel('hide_list')
|
||||||
]
|
]
|
||||||
|
|
24
project/projects/migrations/0002_auto_20161216_1753.py
Normal file
24
project/projects/migrations/0002_auto_20161216_1753.py
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Generated by Django 1.10.4 on 2016-12-16 17:53
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('projects', '0001_initial'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RenameField(
|
||||||
|
model_name='projectpage',
|
||||||
|
old_name='main_image',
|
||||||
|
new_name='image',
|
||||||
|
),
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='projectpage',
|
||||||
|
name='summary',
|
||||||
|
),
|
||||||
|
]
|
20
project/projects/migrations/0003_projectpage_post_date.py
Normal file
20
project/projects/migrations/0003_projectpage_post_date.py
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Generated by Django 1.10.4 on 2016-12-16 18:22
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('projects', '0002_auto_20161216_1753'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='projectpage',
|
||||||
|
name='post_date',
|
||||||
|
field=models.DateTimeField(blank=True, null=True),
|
||||||
|
),
|
||||||
|
]
|
|
@ -4,7 +4,6 @@ from project.common.blocks import build_stream_field
|
||||||
from wagtail.wagtailcore.models import Page
|
from wagtail.wagtailcore.models import Page
|
||||||
from wagtail.wagtaildocs.edit_handlers import DocumentChooserPanel
|
from wagtail.wagtaildocs.edit_handlers import DocumentChooserPanel
|
||||||
from wagtail.wagtailadmin.edit_handlers import FieldPanel, StreamFieldPanel
|
from wagtail.wagtailadmin.edit_handlers import FieldPanel, StreamFieldPanel
|
||||||
from wagtail.wagtailimages.edit_handlers import ImageChooserPanel
|
|
||||||
from wagtail.wagtailsearch import index
|
from wagtail.wagtailsearch import index
|
||||||
from project.common.models import Entity
|
from project.common.models import Entity
|
||||||
|
|
||||||
|
@ -22,14 +21,6 @@ def validate_url(value):
|
||||||
|
|
||||||
|
|
||||||
class ProjectPage(Entity):
|
class ProjectPage(Entity):
|
||||||
main_image = models.ForeignKey(
|
|
||||||
'wagtailimages.Image',
|
|
||||||
null=True,
|
|
||||||
blank=True,
|
|
||||||
on_delete=models.SET_NULL,
|
|
||||||
related_name='+'
|
|
||||||
)
|
|
||||||
summary = models.CharField(max_length=500)
|
|
||||||
body = build_stream_field()
|
body = build_stream_field()
|
||||||
project_url = models.URLField(validators=[validate_url], blank=True)
|
project_url = models.URLField(validators=[validate_url], blank=True)
|
||||||
download_url = models.URLField(validators=[validate_url], blank=True)
|
download_url = models.URLField(validators=[validate_url], blank=True)
|
||||||
|
@ -49,8 +40,6 @@ class ProjectPage(Entity):
|
||||||
]
|
]
|
||||||
|
|
||||||
content_panels = Page.content_panels + [
|
content_panels = Page.content_panels + [
|
||||||
ImageChooserPanel('main_image'),
|
|
||||||
FieldPanel('summary'),
|
|
||||||
StreamFieldPanel('body'),
|
StreamFieldPanel('body'),
|
||||||
FieldPanel('download_url'),
|
FieldPanel('download_url'),
|
||||||
FieldPanel('project_url'),
|
FieldPanel('project_url'),
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
{% load wagtailimages_tags %}
|
{% load wagtailimages_tags %}
|
||||||
|
|
||||||
{% image page.main_image original as main_image %}
|
{% image page.image original as header_image %}
|
||||||
|
|
||||||
<section id="header" class="bg-primary image" data-image="{{ main_image.url }}">
|
<section id="header" class="bg-primary image" data-image="{{ header_image.url }}">
|
||||||
<div class="container text-center text-uppercase">
|
<div class="container text-center text-uppercase">
|
||||||
<h1 class="section-heading">{{ page.title }}</h1>
|
<h1 class="section-heading">{{ page.title }}</h1>
|
||||||
<hr class="light">
|
<hr class="light" />
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
Reference in a new issue