On home page option

This commit is contained in:
Oleg Lavrovsky 2017-04-11 01:01:41 +02:00
parent ee7eb96954
commit 0ec04d2ce4
2 changed files with 63 additions and 0 deletions

View file

@ -0,0 +1,58 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.6 on 2017-04-10 21:07
from __future__ import unicode_literals
from django.db import migrations, models
import wagtail.wagtailcore.blocks
import wagtail.wagtailcore.fields
import wagtail.wagtailimages.blocks
class Migration(migrations.Migration):
dependencies = [
('home', '0009_contact_contactform_contactformfield'),
]
operations = [
migrations.AddField(
model_name='articlepage',
name='on_homepage',
field=models.BooleanField(default=False, verbose_name='Auf der Frontpage anzeigen'),
),
migrations.AlterField(
model_name='contactform',
name='intro_de',
field=wagtail.wagtailcore.fields.RichTextField(blank=True, default=''),
),
migrations.AlterField(
model_name='contactform',
name='intro_fr',
field=wagtail.wagtailcore.fields.RichTextField(blank=True, default=''),
),
migrations.AlterField(
model_name='contactform',
name='thanks_de',
field=wagtail.wagtailcore.fields.RichTextField(blank=True, default=''),
),
migrations.AlterField(
model_name='contactform',
name='thanks_fr',
field=wagtail.wagtailcore.fields.RichTextField(blank=True, default=''),
),
migrations.AlterField(
model_name='contactform',
name='title_fr',
field=models.CharField(default='', max_length=255),
),
migrations.AlterField(
model_name='homepage',
name='infos_de',
field=wagtail.wagtailcore.fields.StreamField((('info', wagtail.wagtailcore.blocks.StructBlock((('title', wagtail.wagtailcore.blocks.CharBlock(required=True)), ('photo', wagtail.wagtailimages.blocks.ImageChooserBlock()), ('summary', wagtail.wagtailcore.blocks.RichTextBlock(required=True)), ('action', wagtail.wagtailcore.blocks.CharBlock()), ('url', wagtail.wagtailcore.blocks.URLBlock())))),), blank=True, null=True),
),
migrations.AlterField(
model_name='homepage',
name='infos_fr',
field=wagtail.wagtailcore.fields.StreamField((('info', wagtail.wagtailcore.blocks.StructBlock((('title', wagtail.wagtailcore.blocks.CharBlock(required=True)), ('photo', wagtail.wagtailimages.blocks.ImageChooserBlock()), ('summary', wagtail.wagtailcore.blocks.RichTextBlock(required=True)), ('action', wagtail.wagtailcore.blocks.CharBlock()), ('url', wagtail.wagtailcore.blocks.URLBlock())))),), blank=True, null=True),
),
]

View file

@ -77,6 +77,9 @@ class ArticlePage(Page):
)
date = models.DateField("Date", null=True, blank=True)
on_homepage = models.BooleanField(default=False, verbose_name="Auf der Frontpage anzeigen")
feed_image = models.ForeignKey(
'wagtailimages.Image',
null=True,
@ -108,6 +111,7 @@ class ArticlePage(Page):
]
promote_panels = [
FieldPanel('date'),
FieldPanel('on_homepage'),
InlinePanel('related_links', label="Links"),
MultiFieldPanel(Page.promote_panels, "Common page configuration"),
]
@ -175,6 +179,7 @@ class HomePage(Page):
def featured(self):
# Get list of live pages that are descendants of this page
articles = ArticlePage.objects.live() #.descendant_of(self)
articles = articles.filter(on_homepage=True)
# Order by most recent date first
#articles = articles.order_by('-date')
return articles[:4]