1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
from django.db import models
from django.utils.translation import ugettext_lazy as _
from wagtail.admin.edit_handlers import FieldPanel
from wagtail.core.models import Page
from wagtail.core.fields import RichTextField
from wagtail.images.edit_handlers import ImageChooserPanel
class BasePage(Page):
image = models.ForeignKey(
'wagtailimages.Image', on_delete=models.SET_NULL, related_name='+',
help_text=_(
"For top page: full width image. For child page: vignette."
), blank=True, null=True
)
body = RichTextField(blank=True)
content_panels = Page.content_panels + [
ImageChooserPanel('image'),
FieldPanel('body', classname="full"),
]
class Meta:
abstract = True
def get_context(self, request):
context = super().get_context(request)
context['menu_items'] = self.get_children().filter(
show_in_menus=True).live().order_by('pk')
return context
class HomePage(BasePage):
organization = models.CharField(max_length=200, blank=True, null=True)
logo = models.ForeignKey(
'wagtailimages.Image', on_delete=models.SET_NULL, related_name='+',
blank=True, null=True
)
jumbotron = RichTextField(blank=True)
footer = RichTextField(blank=True)
content_panels = \
[BasePage.content_panels[0]] + [
FieldPanel('organization'),
ImageChooserPanel('logo'),
FieldPanel('jumbotron'),
] + BasePage.content_panels[1:] + [
FieldPanel('footer'),
]
|