Models des pages et traductions

This commit is contained in:
Evarin 2017-08-09 00:07:56 +02:00
parent 65d7a66eb8
commit 6023211ab0
5 changed files with 296 additions and 18 deletions

View file

@ -0,0 +1 @@
default_app_config = 'gestioncof.cms.apps.COFCMSAppConfig'

7
gestioncof/cms/apps.py Normal file
View file

@ -0,0 +1,7 @@
from django.apps import AppConfig
class COFCMSAppConfig(AppConfig):
name = 'gestioncof.cms'
label = 'cofcms'
verbose_name = 'CMS COF'

View file

@ -2,33 +2,170 @@
from __future__ import unicode_literals from __future__ import unicode_literals
from django.db import migrations, models from django.db import migrations, models
import django.db.models.deletion
import wagtail.wagtailimages.blocks
import wagtail.wagtailcore.blocks
import wagtail.wagtailcore.fields import wagtail.wagtailcore.fields
class Migration(migrations.Migration): class Migration(migrations.Migration):
dependencies = [ dependencies = [
('wagtailimages', '0019_delete_filter'),
('wagtailcore', '0033_remove_golive_expiry_help_text'), ('wagtailcore', '0033_remove_golive_expiry_help_text'),
] ]
operations = [ operations = [
migrations.CreateModel(
name='COFActuIndexPage',
fields=[
('page_ptr', models.OneToOneField(primary_key=True, parent_link=True, serialize=False, auto_created=True, to='wagtailcore.Page')),
('title_fr', models.CharField(null=True, verbose_name='title', help_text="The page title as you'd like it to be seen by the public", max_length=255)),
('title_en', models.CharField(null=True, verbose_name='title', help_text="The page title as you'd like it to be seen by the public", max_length=255)),
('slug_fr', models.SlugField(null=True, verbose_name='slug', help_text='The name of the page as it will appear in URLs e.g http://domain.com/blog/[my-slug]/', max_length=255)),
('slug_en', models.SlugField(null=True, verbose_name='slug', help_text='The name of the page as it will appear in URLs e.g http://domain.com/blog/[my-slug]/', max_length=255)),
('url_path_fr', models.TextField(null=True, blank=True, verbose_name='URL path', editable=False)),
('url_path_en', models.TextField(null=True, blank=True, verbose_name='URL path', editable=False)),
('seo_title_fr', models.CharField(null=True, blank=True, verbose_name='page title', help_text="Optional. 'Search Engine Friendly' title. This will appear at the top of the browser window.", max_length=255)),
('seo_title_en', models.CharField(null=True, blank=True, verbose_name='page title', help_text="Optional. 'Search Engine Friendly' title. This will appear at the top of the browser window.", max_length=255)),
('search_description_fr', models.TextField(null=True, blank=True, verbose_name='search description')),
('search_description_en', models.TextField(null=True, blank=True, verbose_name='search description')),
],
options={
'abstract': False,
},
bases=('wagtailcore.page',),
),
migrations.CreateModel(
name='COFActuPage',
fields=[
('page_ptr', models.OneToOneField(primary_key=True, parent_link=True, serialize=False, auto_created=True, to='wagtailcore.Page')),
('title_fr', models.CharField(null=True, verbose_name='title', help_text="The page title as you'd like it to be seen by the public", max_length=255)),
('title_en', models.CharField(null=True, verbose_name='title', help_text="The page title as you'd like it to be seen by the public", max_length=255)),
('slug_fr', models.SlugField(null=True, verbose_name='slug', help_text='The name of the page as it will appear in URLs e.g http://domain.com/blog/[my-slug]/', max_length=255)),
('slug_en', models.SlugField(null=True, verbose_name='slug', help_text='The name of the page as it will appear in URLs e.g http://domain.com/blog/[my-slug]/', max_length=255)),
('url_path_fr', models.TextField(null=True, blank=True, verbose_name='URL path', editable=False)),
('url_path_en', models.TextField(null=True, blank=True, verbose_name='URL path', editable=False)),
('seo_title_fr', models.CharField(null=True, blank=True, verbose_name='page title', help_text="Optional. 'Search Engine Friendly' title. This will appear at the top of the browser window.", max_length=255)),
('seo_title_en', models.CharField(null=True, blank=True, verbose_name='page title', help_text="Optional. 'Search Engine Friendly' title. This will appear at the top of the browser window.", max_length=255)),
('search_description_fr', models.TextField(null=True, blank=True, verbose_name='search description')),
('search_description_en', models.TextField(null=True, blank=True, verbose_name='search description')),
('body', wagtail.wagtailcore.fields.RichTextField(verbose_name='Contenu')),
('body_fr', wagtail.wagtailcore.fields.RichTextField(null=True, verbose_name='Contenu')),
('body_en', wagtail.wagtailcore.fields.RichTextField(null=True, verbose_name='Contenu')),
('date', models.DateField(verbose_name='Date du post')),
('Image à la Une', models.ForeignKey(null=True, to='wagtailimages.Image', on_delete=django.db.models.deletion.SET_NULL, blank=True, related_name='+')),
],
options={
'abstract': False,
},
bases=('wagtailcore.page',),
),
migrations.CreateModel(
name='COFDirectoryEntryPage',
fields=[
('page_ptr', models.OneToOneField(primary_key=True, parent_link=True, serialize=False, auto_created=True, to='wagtailcore.Page')),
('title_fr', models.CharField(null=True, verbose_name='title', help_text="The page title as you'd like it to be seen by the public", max_length=255)),
('title_en', models.CharField(null=True, verbose_name='title', help_text="The page title as you'd like it to be seen by the public", max_length=255)),
('slug_fr', models.SlugField(null=True, verbose_name='slug', help_text='The name of the page as it will appear in URLs e.g http://domain.com/blog/[my-slug]/', max_length=255)),
('slug_en', models.SlugField(null=True, verbose_name='slug', help_text='The name of the page as it will appear in URLs e.g http://domain.com/blog/[my-slug]/', max_length=255)),
('url_path_fr', models.TextField(null=True, blank=True, verbose_name='URL path', editable=False)),
('url_path_en', models.TextField(null=True, blank=True, verbose_name='URL path', editable=False)),
('seo_title_fr', models.CharField(null=True, blank=True, verbose_name='page title', help_text="Optional. 'Search Engine Friendly' title. This will appear at the top of the browser window.", max_length=255)),
('seo_title_en', models.CharField(null=True, blank=True, verbose_name='page title', help_text="Optional. 'Search Engine Friendly' title. This will appear at the top of the browser window.", max_length=255)),
('search_description_fr', models.TextField(null=True, blank=True, verbose_name='search description')),
('search_description_en', models.TextField(null=True, blank=True, verbose_name='search description')),
('body', wagtail.wagtailcore.fields.RichTextField(verbose_name='Description')),
('body_fr', wagtail.wagtailcore.fields.RichTextField(null=True, verbose_name='Description')),
('body_en', wagtail.wagtailcore.fields.RichTextField(null=True, verbose_name='Description')),
('links', wagtail.wagtailcore.fields.StreamField((('lien', wagtail.wagtailcore.blocks.StructBlock((('url', wagtail.wagtailcore.blocks.URLBlock(required=True)), ('texte', wagtail.wagtailcore.blocks.CharBlock())))), ('contact', wagtail.wagtailcore.blocks.StructBlock((('email', wagtail.wagtailcore.blocks.EmailBlock(required=True)), ('texte', wagtail.wagtailcore.blocks.CharBlock()))))))),
('links_fr', wagtail.wagtailcore.fields.StreamField((('lien', wagtail.wagtailcore.blocks.StructBlock((('url', wagtail.wagtailcore.blocks.URLBlock(required=True)), ('texte', wagtail.wagtailcore.blocks.CharBlock())))), ('contact', wagtail.wagtailcore.blocks.StructBlock((('email', wagtail.wagtailcore.blocks.EmailBlock(required=True)), ('texte', wagtail.wagtailcore.blocks.CharBlock()))))), null=True)),
('links_en', wagtail.wagtailcore.fields.StreamField((('lien', wagtail.wagtailcore.blocks.StructBlock((('url', wagtail.wagtailcore.blocks.URLBlock(required=True)), ('texte', wagtail.wagtailcore.blocks.CharBlock())))), ('contact', wagtail.wagtailcore.blocks.StructBlock((('email', wagtail.wagtailcore.blocks.EmailBlock(required=True)), ('texte', wagtail.wagtailcore.blocks.CharBlock()))))), null=True)),
('Image', models.ForeignKey(null=True, to='wagtailimages.Image', on_delete=django.db.models.deletion.SET_NULL, blank=True, related_name='+')),
],
options={
'abstract': False,
},
bases=('wagtailcore.page',),
),
migrations.CreateModel(
name='COFDirectoryPage',
fields=[
('page_ptr', models.OneToOneField(primary_key=True, parent_link=True, serialize=False, auto_created=True, to='wagtailcore.Page')),
('title_fr', models.CharField(null=True, verbose_name='title', help_text="The page title as you'd like it to be seen by the public", max_length=255)),
('title_en', models.CharField(null=True, verbose_name='title', help_text="The page title as you'd like it to be seen by the public", max_length=255)),
('slug_fr', models.SlugField(null=True, verbose_name='slug', help_text='The name of the page as it will appear in URLs e.g http://domain.com/blog/[my-slug]/', max_length=255)),
('slug_en', models.SlugField(null=True, verbose_name='slug', help_text='The name of the page as it will appear in URLs e.g http://domain.com/blog/[my-slug]/', max_length=255)),
('url_path_fr', models.TextField(null=True, blank=True, verbose_name='URL path', editable=False)),
('url_path_en', models.TextField(null=True, blank=True, verbose_name='URL path', editable=False)),
('seo_title_fr', models.CharField(null=True, blank=True, verbose_name='page title', help_text="Optional. 'Search Engine Friendly' title. This will appear at the top of the browser window.", max_length=255)),
('seo_title_en', models.CharField(null=True, blank=True, verbose_name='page title', help_text="Optional. 'Search Engine Friendly' title. This will appear at the top of the browser window.", max_length=255)),
('search_description_fr', models.TextField(null=True, blank=True, verbose_name='search description')),
('search_description_en', models.TextField(null=True, blank=True, verbose_name='search description')),
('introduction', wagtail.wagtailcore.fields.RichTextField(verbose_name='Introduction')),
('introduction_fr', wagtail.wagtailcore.fields.RichTextField(null=True, verbose_name='Introduction')),
('introduction_en', wagtail.wagtailcore.fields.RichTextField(null=True, verbose_name='Introduction')),
],
options={
'abstract': False,
},
bases=('wagtailcore.page',),
),
migrations.CreateModel(
name='COFEvent',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('title', models.TextField(verbose_name='Titre')),
('title_fr', models.TextField(null=True, verbose_name='Titre')),
('title_en', models.TextField(null=True, verbose_name='Titre')),
('description', wagtail.wagtailcore.fields.RichTextField(verbose_name='Description (concise)')),
('description_fr', wagtail.wagtailcore.fields.RichTextField(null=True, verbose_name='Description (concise)')),
('description_en', wagtail.wagtailcore.fields.RichTextField(null=True, verbose_name='Description (concise)')),
('date_start', models.DateTimeField(verbose_name='Date et heure de début')),
('date_end', models.DateTimeField(null=True, verbose_name='Date et heure de fin')),
('all_day', models.BooleanField(verbose_name='Toute la journée', default=False)),
],
),
migrations.CreateModel( migrations.CreateModel(
name='COFPage', name='COFPage',
fields=[ fields=[
('page_ptr', models.OneToOneField(primary_key=True, to='wagtailcore.Page', parent_link=True, auto_created=True, serialize=False)), ('page_ptr', models.OneToOneField(primary_key=True, parent_link=True, serialize=False, auto_created=True, to='wagtailcore.Page')),
('title_fr', models.CharField(help_text="The page title as you'd like it to be seen by the public", null=True, max_length=255, verbose_name='title')), ('title_fr', models.CharField(null=True, verbose_name='title', help_text="The page title as you'd like it to be seen by the public", max_length=255)),
('title_en', models.CharField(help_text="The page title as you'd like it to be seen by the public", null=True, max_length=255, verbose_name='title')), ('title_en', models.CharField(null=True, verbose_name='title', help_text="The page title as you'd like it to be seen by the public", max_length=255)),
('slug_fr', models.SlugField(help_text='The name of the page as it will appear in URLs e.g http://domain.com/blog/[my-slug]/', null=True, max_length=255, verbose_name='slug')), ('slug_fr', models.SlugField(null=True, verbose_name='slug', help_text='The name of the page as it will appear in URLs e.g http://domain.com/blog/[my-slug]/', max_length=255)),
('slug_en', models.SlugField(help_text='The name of the page as it will appear in URLs e.g http://domain.com/blog/[my-slug]/', null=True, max_length=255, verbose_name='slug')), ('slug_en', models.SlugField(null=True, verbose_name='slug', help_text='The name of the page as it will appear in URLs e.g http://domain.com/blog/[my-slug]/', max_length=255)),
('url_path_fr', models.TextField(blank=True, null=True, editable=False, verbose_name='URL path')), ('url_path_fr', models.TextField(null=True, blank=True, verbose_name='URL path', editable=False)),
('url_path_en', models.TextField(blank=True, null=True, editable=False, verbose_name='URL path')), ('url_path_en', models.TextField(null=True, blank=True, verbose_name='URL path', editable=False)),
('seo_title_fr', models.CharField(help_text="Optional. 'Search Engine Friendly' title. This will appear at the top of the browser window.", null=True, blank=True, max_length=255, verbose_name='page title')), ('seo_title_fr', models.CharField(null=True, blank=True, verbose_name='page title', help_text="Optional. 'Search Engine Friendly' title. This will appear at the top of the browser window.", max_length=255)),
('seo_title_en', models.CharField(help_text="Optional. 'Search Engine Friendly' title. This will appear at the top of the browser window.", null=True, blank=True, max_length=255, verbose_name='page title')), ('seo_title_en', models.CharField(null=True, blank=True, verbose_name='page title', help_text="Optional. 'Search Engine Friendly' title. This will appear at the top of the browser window.", max_length=255)),
('search_description_fr', models.TextField(blank=True, null=True, verbose_name='search description')), ('search_description_fr', models.TextField(null=True, blank=True, verbose_name='search description')),
('search_description_en', models.TextField(blank=True, null=True, verbose_name='search description')), ('search_description_en', models.TextField(null=True, blank=True, verbose_name='search description')),
('corps', wagtail.wagtailcore.fields.RichTextField()), ('body', wagtail.wagtailcore.fields.StreamField((('heading', wagtail.wagtailcore.blocks.CharBlock(classname='full title')), ('paragraph', wagtail.wagtailcore.blocks.RichTextBlock()), ('image', wagtail.wagtailimages.blocks.ImageChooserBlock())))),
('corps_fr', wagtail.wagtailcore.fields.RichTextField(null=True)), ('body_fr', wagtail.wagtailcore.fields.StreamField((('heading', wagtail.wagtailcore.blocks.CharBlock(classname='full title')), ('paragraph', wagtail.wagtailcore.blocks.RichTextBlock()), ('image', wagtail.wagtailimages.blocks.ImageChooserBlock())), null=True)),
('corps_en', wagtail.wagtailcore.fields.RichTextField(null=True)), ('body_en', wagtail.wagtailcore.fields.StreamField((('heading', wagtail.wagtailcore.blocks.CharBlock(classname='full title')), ('paragraph', wagtail.wagtailcore.blocks.RichTextBlock()), ('image', wagtail.wagtailimages.blocks.ImageChooserBlock())), null=True)),
],
options={
'abstract': False,
},
bases=('wagtailcore.page',),
),
migrations.CreateModel(
name='COFRootPage',
fields=[
('page_ptr', models.OneToOneField(primary_key=True, parent_link=True, serialize=False, auto_created=True, to='wagtailcore.Page')),
('title_fr', models.CharField(null=True, verbose_name='title', help_text="The page title as you'd like it to be seen by the public", max_length=255)),
('title_en', models.CharField(null=True, verbose_name='title', help_text="The page title as you'd like it to be seen by the public", max_length=255)),
('slug_fr', models.SlugField(null=True, verbose_name='slug', help_text='The name of the page as it will appear in URLs e.g http://domain.com/blog/[my-slug]/', max_length=255)),
('slug_en', models.SlugField(null=True, verbose_name='slug', help_text='The name of the page as it will appear in URLs e.g http://domain.com/blog/[my-slug]/', max_length=255)),
('url_path_fr', models.TextField(null=True, blank=True, verbose_name='URL path', editable=False)),
('url_path_en', models.TextField(null=True, blank=True, verbose_name='URL path', editable=False)),
('seo_title_fr', models.CharField(null=True, blank=True, verbose_name='page title', help_text="Optional. 'Search Engine Friendly' title. This will appear at the top of the browser window.", max_length=255)),
('seo_title_en', models.CharField(null=True, blank=True, verbose_name='page title', help_text="Optional. 'Search Engine Friendly' title. This will appear at the top of the browser window.", max_length=255)),
('search_description_fr', models.TextField(null=True, blank=True, verbose_name='search description')),
('search_description_en', models.TextField(null=True, blank=True, verbose_name='search description')),
('introduction', wagtail.wagtailcore.fields.RichTextField(verbose_name='Introduction')),
('introduction_fr', wagtail.wagtailcore.fields.RichTextField(null=True, verbose_name='Introduction')),
('introduction_en', wagtail.wagtailcore.fields.RichTextField(null=True, verbose_name='Introduction')),
], ],
options={ options={
'abstract': False, 'abstract': False,

View file

@ -1,11 +1,108 @@
from django.db import models from django.db import models
# Create your models here.
from wagtail.wagtailcore.models import Page, Orderable from wagtail.wagtailcore.models import Page, Orderable
from wagtail.wagtailcore.fields import RichTextField, StreamField from wagtail.wagtailcore.fields import RichTextField, StreamField
from wagtail.wagtailcore import blocks from wagtail.wagtailcore import blocks
from wagtail.wagtailimages.edit_handlers import ImageChooserPanel
from wagtail.wagtailimages.blocks import ImageChooserBlock
from wagtail.wagtailadmin.edit_handlers import FieldPanel, StreamFieldPanel
from wagtail.wagtailsnippets.models import register_snippet
# Racine du site du COF
class COFRootPage(Page):
introduction = RichTextField("Introduction")
content_panels = Page.content_panels + [
FieldPanel('introduction', classname="full"),
]
subpage_types = ['COFActuIndexPage', 'COFPage', 'COFDirectoryPage']
# Page lambda du site
class COFPage(Page): class COFPage(Page):
corps = RichTextField() body = StreamField([
('heading', blocks.CharBlock(classname="full title")),
('paragraph', blocks.RichTextBlock()),
('image', ImageChooserBlock()),
])
content_panels = Page.content_panels + [
StreamFieldPanel('body'),
]
subpages_types = ['COFDirectoryPage', 'COFPage']
parent_page_types = ['COFPage', 'COFRootPage']
# Évènements
@register_snippet
class COFEvent(models.Model):
title = models.TextField("Titre")
description = RichTextField("Description (concise)")
date_start = models.DateTimeField("Date et heure de début")
date_end = models.DateTimeField("Date et heure de fin", null=True)
all_day = models.BooleanField("Toute la journée", default=False, blank=True)
panels = [
FieldPanel("title"),
FieldPanel("description"),
FieldPanel("date_start"),
FieldPanel("date_end"),
FieldPanel("all_day"),
]
# Actualités
class COFActuIndexPage(Page):
subpages_types = ['COFActuPage']
parent_page_types = ['COFRootPage']
class COFActuPage(Page):
body = RichTextField("Contenu")
date = models.DateField("Date du post")
image = models.ForeignKey(
'wagtailimages.Image', name="Image à la Une",
null=True, blank=True,
on_delete=models.SET_NULL, related_name='+'
)
content_panels = Page.content_panels + [
FieldPanel('date'),
# ImageChooserPanel('image'),
FieldPanel('body', classname="full"),
]
subpages_types = []
parent_page_types = ['COFActuIndexPage']
# Annuaires (Clubs, partenaires, bonnes adresses)
class COFDirectoryPage(Page):
introduction = RichTextField("Introduction")
subpages_types = ['COFActuPage', 'COFDirectoryEntryPage']
parent_page_types = ['COFRootPage', 'COFPage']
class COFDirectoryEntryPage(Page):
body = RichTextField("Description")
links = StreamField([
('lien', blocks.StructBlock([
('url', blocks.URLBlock(required=True)),
('texte', blocks.CharBlock()),
])),
('contact', blocks.StructBlock([
('email', blocks.EmailBlock(required=True)),
('texte', blocks.CharBlock()),
])),
])
image = models.ForeignKey(
'wagtailimages.Image', name="Image",
null=True, blank=True,
on_delete=models.SET_NULL, related_name='+'
)
subpages_types = []
parent_page_types = ['COFDirectoryPage']

View file

@ -1,11 +1,47 @@
from .models import COFPage from .models import COFRootPage, COFPage, COFEvent, COFActuIndexPage, COFActuPage, COFDirectoryPage, COFDirectoryEntryPage
from wagtail_modeltranslation.translator import WagtailTranslationOptions from wagtail_modeltranslation.translator import WagtailTranslationOptions
from modeltranslation.decorators import register from modeltranslation.decorators import register
@register(COFRootPage)
class COFPageTr(WagtailTranslationOptions):
fields = (
'introduction',
)
@register(COFPage) @register(COFPage)
class COFPageTr(WagtailTranslationOptions): class COFPageTr(WagtailTranslationOptions):
fields = ( fields = (
'corps', 'body',
)
@register(COFEvent)
class COFEventTr(WagtailTranslationOptions):
fields = (
'title',
'description',
)
@register(COFActuIndexPage)
class COFActuIndexPageTr(WagtailTranslationOptions):
fields = (
)
@register(COFActuPage)
class COFActuPageTr(WagtailTranslationOptions):
fields = (
'body',
)
@register(COFDirectoryPage)
class COFDirectoryPageTr(WagtailTranslationOptions):
fields = (
'introduction',
) )
@register(COFDirectoryEntryPage)
class COFDirectoryEntryPageTr(WagtailTranslationOptions):
fields = (
'body',
'links',
)