English language fields
This commit is contained in:
parent
e02256acc3
commit
0c681b615d
4 changed files with 19 additions and 1 deletions
|
@ -219,16 +219,20 @@ class ArticleRelatedLink(Orderable):
|
||||||
class HomePage(Page):
|
class HomePage(Page):
|
||||||
intro_de = RichTextField(default='')
|
intro_de = RichTextField(default='')
|
||||||
intro_fr = RichTextField(default='')
|
intro_fr = RichTextField(default='')
|
||||||
|
intro_en = RichTextField(default='')
|
||||||
trans_intro = TranslatedField(
|
trans_intro = TranslatedField(
|
||||||
'intro_de',
|
'intro_de',
|
||||||
'intro_fr',
|
'intro_fr',
|
||||||
|
'intro_en',
|
||||||
)
|
)
|
||||||
|
|
||||||
body_de = RichTextField(default='', blank=True)
|
body_de = RichTextField(default='', blank=True)
|
||||||
body_fr = RichTextField(default='', blank=True)
|
body_fr = RichTextField(default='', blank=True)
|
||||||
|
body_en = RichTextField(default='', blank=True)
|
||||||
trans_body = TranslatedField(
|
trans_body = TranslatedField(
|
||||||
'body_de',
|
'body_de',
|
||||||
'body_fr',
|
'body_fr',
|
||||||
|
'body_en',
|
||||||
)
|
)
|
||||||
|
|
||||||
infos_de = StreamField([
|
infos_de = StreamField([
|
||||||
|
@ -237,9 +241,13 @@ class HomePage(Page):
|
||||||
infos_fr = StreamField([
|
infos_fr = StreamField([
|
||||||
('info', InfoBlock())
|
('info', InfoBlock())
|
||||||
], null=True, blank=True)
|
], null=True, blank=True)
|
||||||
|
infos_en = StreamField([
|
||||||
|
('info', InfoBlock())
|
||||||
|
], null=True, blank=True)
|
||||||
trans_infos = TranslatedField(
|
trans_infos = TranslatedField(
|
||||||
'infos_de',
|
'infos_de',
|
||||||
'infos_fr',
|
'infos_fr',
|
||||||
|
'infos_en',
|
||||||
)
|
)
|
||||||
|
|
||||||
content_panels = Page.content_panels + [
|
content_panels = Page.content_panels + [
|
||||||
|
@ -253,6 +261,11 @@ class HomePage(Page):
|
||||||
FieldPanel('body_fr', classname="full"),
|
FieldPanel('body_fr', classname="full"),
|
||||||
StreamFieldPanel('infos_fr'),
|
StreamFieldPanel('infos_fr'),
|
||||||
], heading="Français"),
|
], heading="Français"),
|
||||||
|
MultiFieldPanel([
|
||||||
|
FieldPanel('intro_en', classname="full"),
|
||||||
|
FieldPanel('body_en', classname="full"),
|
||||||
|
StreamFieldPanel('infos_en'),
|
||||||
|
], heading="English"),
|
||||||
]
|
]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|
|
@ -52,9 +52,11 @@ class Contact(models.Model):
|
||||||
"""
|
"""
|
||||||
title = models.CharField(max_length=255, default="")
|
title = models.CharField(max_length=255, default="")
|
||||||
title_fr = models.CharField(max_length=255, default="")
|
title_fr = models.CharField(max_length=255, default="")
|
||||||
|
title_en = models.CharField(max_length=255, default="")
|
||||||
trans_title = TranslatedField(
|
trans_title = TranslatedField(
|
||||||
'title',
|
'title',
|
||||||
'title_fr',
|
'title_fr',
|
||||||
|
'title_en',
|
||||||
)
|
)
|
||||||
address = models.TextField(default="", blank=True)
|
address = models.TextField(default="", blank=True)
|
||||||
phone = models.CharField(max_length=40, default="")
|
phone = models.CharField(max_length=40, default="")
|
||||||
|
@ -75,6 +77,7 @@ class Contact(models.Model):
|
||||||
|
|
||||||
panels = Page.content_panels + [
|
panels = Page.content_panels + [
|
||||||
FieldPanel('title_fr'),
|
FieldPanel('title_fr'),
|
||||||
|
FieldPanel('title_en'),
|
||||||
FieldPanel('address'),
|
FieldPanel('address'),
|
||||||
FieldPanel('phone'),
|
FieldPanel('phone'),
|
||||||
FieldPanel('email'),
|
FieldPanel('email'),
|
||||||
|
|
|
@ -13,6 +13,8 @@ def language_switcher(context):
|
||||||
if len(url) > 2 and len(url[1]) >= 2:
|
if len(url) > 2 and len(url[1]) >= 2:
|
||||||
url[1] = '$lang$'
|
url[1] = '$lang$'
|
||||||
url = '/'.join(url)
|
url = '/'.join(url)
|
||||||
|
else:
|
||||||
|
url = context['page'].url
|
||||||
return {
|
return {
|
||||||
'languages': [
|
'languages': [
|
||||||
{ 'code': 'de', 'title': 'De', 'url': url.replace('$lang$','de') },
|
{ 'code': 'de', 'title': 'De', 'url': url.replace('$lang$','de') },
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
from django.utils import translation
|
from django.utils import translation
|
||||||
|
|
||||||
class TranslatedField(object):
|
class TranslatedField(object):
|
||||||
def __init__(self, de_field, fr_field, en_field=None):
|
def __init__(self, de_field, fr_field, en_field):
|
||||||
self.de_field = de_field
|
self.de_field = de_field
|
||||||
self.fr_field = fr_field
|
self.fr_field = fr_field
|
||||||
self.en_field = en_field
|
self.en_field = en_field
|
||||||
|
|
Loading…
Reference in a new issue