Skip to content
This repository has been archived by the owner on Nov 7, 2019. It is now read-only.

Commit

Permalink
apps/cms: moved translated fields to separate tabs in wagtail admin
Browse files Browse the repository at this point in the history
  • Loading branch information
Magdalena Noffke authored and rmader committed Jul 2, 2019
1 parent 6771e5a commit 528534e
Showing 1 changed file with 40 additions and 7 deletions.
47 changes: 40 additions & 7 deletions apps/cms/pages/models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from django.db import models
from wagtail.admin.edit_handlers import FieldPanel
from wagtail.admin.edit_handlers import ObjectList
from wagtail.admin.edit_handlers import TabbedInterface
from wagtail.core.fields import RichTextField
from wagtail.core.models import Page
from wagtail.images.edit_handlers import ImageChooserPanel
Expand All @@ -23,11 +25,9 @@ class HomePage(Page):
subtitle_en = models.CharField(
max_length=500, blank=True, verbose_name="Subtitle")

subpage_types = ['a4_candy_cms_pages.EmptyPage']
body_de = RichTextField(blank=True)
body_en = RichTextField(blank=True)

content_panels = [
body = TranslatedField(
'body_de',
'body_en'
Expand All @@ -37,13 +37,30 @@ class HomePage(Page):
'subtitle_de',
'subtitle_en'
)

en_content_panels = [
FieldPanel('subtitle_en'),
FieldPanel('body_en')
]

de_content_panels = [
FieldPanel('subtitle_de'),
FieldPanel('body_de')
]

common_panels = [
FieldPanel('title'),
FieldPanel('slug'),
ImageChooserPanel('image'),
FieldPanel('subtitle'),
FieldPanel('body')
]

promote_panels = Page.promote_panels
edit_handler = TabbedInterface([
ObjectList(common_panels, heading='Common'),
ObjectList(en_content_panels, heading='English'),
ObjectList(de_content_panels, heading='German')
])

subpage_types = ['a4_candy_cms_pages.EmptyPage']


class EmptyPage(Page):
Expand All @@ -54,12 +71,28 @@ class SimplePage(Page):
body_de = RichTextField()
body_en = RichTextField(blank=True)

content_panels = Page.content_panels + [
FieldPanel('body', classname='full'),
body = TranslatedField(
'body_de',
'body_en'
)

en_content_panels = [
FieldPanel('body_en')
]

de_content_panels = [
FieldPanel('body_de')
]

common_panels = [
FieldPanel('title'),
FieldPanel('slug')
]

edit_handler = TabbedInterface([
ObjectList(common_panels, heading='Common'),
ObjectList(en_content_panels, heading='English'),
ObjectList(de_content_panels, heading='German')
])

subpage_types = ['a4_candy_cms_pages.SimplePage']

0 comments on commit 528534e

Please sign in to comment.