diff --git a/cof/locale/en/formats.py b/cof/locale/en/formats.py index 88686dda..abd616db 100644 --- a/cof/locale/en/formats.py +++ b/cof/locale/en/formats.py @@ -6,6 +6,6 @@ English formatting. from __future__ import unicode_literals -DATETIME_FORMAT = r'l N j, Y \a\t P' -DATE_FORMAT = r'l N j, Y' -TIME_FORMAT = r'P' +DATETIME_FORMAT = r"l N j, Y \a\t P" +DATE_FORMAT = r"l N j, Y" +TIME_FORMAT = r"P" diff --git a/cof/locale/fr/formats.py b/cof/locale/fr/formats.py index dba4b4ba..6fd5b5ba 100644 --- a/cof/locale/fr/formats.py +++ b/cof/locale/fr/formats.py @@ -2,6 +2,6 @@ Formats français. """ -DATETIME_FORMAT = r'l j F Y \à H\hi' -DATE_FORMAT = r'l j F Y' -TIME_FORMAT = r'H\hi' +DATETIME_FORMAT = r"l j F Y \à H\hi" +DATE_FORMAT = r"l j F Y" +TIME_FORMAT = r"H\hi" diff --git a/cof/settings/common.py b/cof/settings/common.py index 9b481aa5..22bb5afa 100644 --- a/cof/settings/common.py +++ b/cof/settings/common.py @@ -57,64 +57,64 @@ INSTALLED_APPS = [ "gestioncof", # Must be before 'django.contrib.admin'. # https://django-autocomplete-light.readthedocs.io/en/master/install.html - 'dal', - 'dal_select2', - 'django.contrib.auth', - 'django.contrib.contenttypes', - 'django.contrib.sessions', - 'django.contrib.sites', - 'django.contrib.messages', - 'django.contrib.staticfiles', - 'django.contrib.admin', - 'django.contrib.admindocs', - 'bda', - 'captcha', - 'django_cas_ng', - 'bootstrapform', - 'kfet', - 'kfet.open', - 'channels', - 'widget_tweaks', - 'custommail', - 'djconfig', - 'wagtail.wagtailforms', - 'wagtail.wagtailredirects', - 'wagtail.wagtailembeds', - 'wagtail.wagtailsites', - 'wagtail.wagtailusers', - 'wagtail.wagtailsnippets', - 'wagtail.wagtaildocs', - 'wagtail.wagtailimages', - 'wagtail.wagtailsearch', - 'wagtail.wagtailadmin', - 'wagtail.wagtailcore', - 'wagtail.contrib.modeladmin', - 'wagtail.contrib.wagtailroutablepage', - 'wagtailmenus', - 'wagtail_modeltranslation', - 'modelcluster', - 'taggit', - 'kfet.auth', - 'kfet.cms', - 'gestioncof.cms', + "dal", + "dal_select2", + "django.contrib.auth", + "django.contrib.contenttypes", + "django.contrib.sessions", + "django.contrib.sites", + "django.contrib.messages", + "django.contrib.staticfiles", + "django.contrib.admin", + "django.contrib.admindocs", + "bda", + "captcha", + "django_cas_ng", + "bootstrapform", + "kfet", + "kfet.open", + "channels", + "widget_tweaks", + "custommail", + "djconfig", + "wagtail.wagtailforms", + "wagtail.wagtailredirects", + "wagtail.wagtailembeds", + "wagtail.wagtailsites", + "wagtail.wagtailusers", + "wagtail.wagtailsnippets", + "wagtail.wagtaildocs", + "wagtail.wagtailimages", + "wagtail.wagtailsearch", + "wagtail.wagtailadmin", + "wagtail.wagtailcore", + "wagtail.contrib.modeladmin", + "wagtail.contrib.wagtailroutablepage", + "wagtailmenus", + "wagtail_modeltranslation", + "modelcluster", + "taggit", + "kfet.auth", + "kfet.cms", + "gestioncof.cms", ] MIDDLEWARE = [ "corsheaders.middleware.CorsMiddleware", - 'django.contrib.sessions.middleware.SessionMiddleware', - 'django.middleware.common.CommonMiddleware', - 'django.middleware.csrf.CsrfViewMiddleware', - 'django.contrib.auth.middleware.AuthenticationMiddleware', - 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', - 'kfet.auth.middleware.TemporaryAuthMiddleware', - 'django.contrib.messages.middleware.MessageMiddleware', - 'django.middleware.clickjacking.XFrameOptionsMiddleware', - 'django.middleware.security.SecurityMiddleware', - 'djconfig.middleware.DjConfigMiddleware', - 'wagtail.wagtailcore.middleware.SiteMiddleware', - 'wagtail.wagtailredirects.middleware.RedirectMiddleware', - 'django.middleware.locale.LocaleMiddleware', + "django.contrib.sessions.middleware.SessionMiddleware", + "django.middleware.common.CommonMiddleware", + "django.middleware.csrf.CsrfViewMiddleware", + "django.contrib.auth.middleware.AuthenticationMiddleware", + "django.contrib.auth.middleware.SessionAuthenticationMiddleware", + "kfet.auth.middleware.TemporaryAuthMiddleware", + "django.contrib.messages.middleware.MessageMiddleware", + "django.middleware.clickjacking.XFrameOptionsMiddleware", + "django.middleware.security.SecurityMiddleware", + "djconfig.middleware.DjConfigMiddleware", + "wagtail.wagtailcore.middleware.SiteMiddleware", + "wagtail.wagtailredirects.middleware.RedirectMiddleware", + "django.middleware.locale.LocaleMiddleware", ] ROOT_URLCONF = "cof.urls" @@ -167,10 +167,7 @@ USE_L10N = True USE_TZ = True -LANGUAGES = ( - ('fr', 'Français'), - ('en', 'English'), -) +LANGUAGES = (("fr", "Français"), ("en", "English")) # Various additional settings SITE_ID = 1 diff --git a/cof/urls.py b/cof/urls.py index fa9a1590..4038466f 100644 --- a/cof/urls.py +++ b/cof/urls.py @@ -134,6 +134,5 @@ if settings.DEBUG: # Wagtail for uncatched urlpatterns += i18n_patterns( - url(r'', include(wagtail_urls)), - prefix_default_language=False + url(r"", include(wagtail_urls)), prefix_default_language=False ) diff --git a/gestioncof/cms/__init__.py b/gestioncof/cms/__init__.py index 9892db53..043b644d 100644 --- a/gestioncof/cms/__init__.py +++ b/gestioncof/cms/__init__.py @@ -1 +1 @@ -default_app_config = 'gestioncof.cms.apps.COFCMSAppConfig' +default_app_config = "gestioncof.cms.apps.COFCMSAppConfig" diff --git a/gestioncof/cms/apps.py b/gestioncof/cms/apps.py index cbc58688..3cd041cc 100644 --- a/gestioncof/cms/apps.py +++ b/gestioncof/cms/apps.py @@ -2,6 +2,6 @@ from django.apps import AppConfig class COFCMSAppConfig(AppConfig): - name = 'gestioncof.cms' - label = 'cofcms' - verbose_name = 'CMS COF' + name = "gestioncof.cms" + label = "cofcms" + verbose_name = "CMS COF" diff --git a/gestioncof/cms/migrations/0001_initial.py b/gestioncof/cms/migrations/0001_initial.py index 77b6d4a5..27fe51ff 100644 --- a/gestioncof/cms/migrations/0001_initial.py +++ b/gestioncof/cms/migrations/0001_initial.py @@ -2,12 +2,13 @@ # Generated by Django 1.11.9 on 2018-01-20 19:10 from __future__ import unicode_literals -from django.db import migrations, models import django.db.models.deletion -import gestioncof.cms.models import wagtail.wagtailcore.blocks import wagtail.wagtailcore.fields import wagtail.wagtailimages.blocks +from django.db import migrations, models + +import gestioncof.cms.models class Migration(migrations.Migration): @@ -15,162 +16,925 @@ class Migration(migrations.Migration): initial = True dependencies = [ - ('wagtailcore', '0033_remove_golive_expiry_help_text'), - ('wagtailimages', '0019_delete_filter'), + ("wagtailcore", "0033_remove_golive_expiry_help_text"), + ("wagtailimages", "0019_delete_filter"), ] operations = [ migrations.CreateModel( - name='COFActuIndexPage', + name="COFActuIndexPage", fields=[ - ('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='wagtailcore.Page')), - ('title_fr', models.CharField(help_text="The page title as you'd like it to be seen by the public", max_length=255, null=True, verbose_name='title')), - ('title_en', models.CharField(help_text="The page title as you'd like it to be seen by the public", max_length=255, null=True, verbose_name='title')), - ('slug_fr', models.SlugField(allow_unicode=True, help_text='The name of the page as it will appear in URLs e.g http://domain.com/blog/[my-slug]/', max_length=255, null=True, verbose_name='slug')), - ('slug_en', models.SlugField(allow_unicode=True, help_text='The name of the page as it will appear in URLs e.g http://domain.com/blog/[my-slug]/', max_length=255, null=True, verbose_name='slug')), - ('url_path_fr', models.TextField(blank=True, editable=False, null=True, verbose_name='URL path')), - ('url_path_en', models.TextField(blank=True, editable=False, null=True, verbose_name='URL path')), - ('seo_title_fr', models.CharField(blank=True, help_text="Optional. 'Search Engine Friendly' title. This will appear at the top of the browser window.", max_length=255, null=True, verbose_name='page title')), - ('seo_title_en', models.CharField(blank=True, help_text="Optional. 'Search Engine Friendly' title. This will appear at the top of the browser window.", max_length=255, null=True, verbose_name='page title')), - ('search_description_fr', models.TextField(blank=True, null=True, verbose_name='search description')), - ('search_description_en', models.TextField(blank=True, null=True, verbose_name='search description')), + ( + "page_ptr", + models.OneToOneField( + auto_created=True, + on_delete=django.db.models.deletion.CASCADE, + parent_link=True, + primary_key=True, + serialize=False, + to="wagtailcore.Page", + ), + ), + ( + "title_fr", + models.CharField( + help_text="The page title as you'd like it to be seen by the public", + max_length=255, + null=True, + verbose_name="title", + ), + ), + ( + "title_en", + models.CharField( + help_text="The page title as you'd like it to be seen by the public", + max_length=255, + null=True, + verbose_name="title", + ), + ), + ( + "slug_fr", + models.SlugField( + allow_unicode=True, + help_text="The name of the page as it will appear in URLs e.g http://domain.com/blog/[my-slug]/", + max_length=255, + null=True, + verbose_name="slug", + ), + ), + ( + "slug_en", + models.SlugField( + allow_unicode=True, + help_text="The name of the page as it will appear in URLs e.g http://domain.com/blog/[my-slug]/", + max_length=255, + null=True, + verbose_name="slug", + ), + ), + ( + "url_path_fr", + models.TextField( + blank=True, editable=False, null=True, verbose_name="URL path" + ), + ), + ( + "url_path_en", + models.TextField( + blank=True, editable=False, null=True, verbose_name="URL path" + ), + ), + ( + "seo_title_fr", + models.CharField( + blank=True, + help_text="Optional. 'Search Engine Friendly' title. This will appear at the top of the browser window.", + max_length=255, + null=True, + verbose_name="page title", + ), + ), + ( + "seo_title_en", + models.CharField( + blank=True, + help_text="Optional. 'Search Engine Friendly' title. This will appear at the top of the browser window.", + max_length=255, + null=True, + verbose_name="page title", + ), + ), + ( + "search_description_fr", + models.TextField( + blank=True, null=True, verbose_name="search description" + ), + ), + ( + "search_description_en", + models.TextField( + blank=True, null=True, verbose_name="search description" + ), + ), ], options={ - 'verbose_name': 'Index des actualités', - 'verbose_name_plural': 'Indexs des actualités', + "verbose_name": "Index des actualités", + "verbose_name_plural": "Indexs des actualités", }, - bases=('wagtailcore.page', gestioncof.cms.models.COFActuIndexMixin), + bases=("wagtailcore.page", gestioncof.cms.models.COFActuIndexMixin), ), migrations.CreateModel( - name='COFActuPage', + name="COFActuPage", fields=[ - ('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='wagtailcore.Page')), - ('title_fr', models.CharField(help_text="The page title as you'd like it to be seen by the public", max_length=255, null=True, verbose_name='title')), - ('title_en', models.CharField(help_text="The page title as you'd like it to be seen by the public", max_length=255, null=True, verbose_name='title')), - ('slug_fr', models.SlugField(allow_unicode=True, help_text='The name of the page as it will appear in URLs e.g http://domain.com/blog/[my-slug]/', max_length=255, null=True, verbose_name='slug')), - ('slug_en', models.SlugField(allow_unicode=True, help_text='The name of the page as it will appear in URLs e.g http://domain.com/blog/[my-slug]/', max_length=255, null=True, verbose_name='slug')), - ('url_path_fr', models.TextField(blank=True, editable=False, null=True, verbose_name='URL path')), - ('url_path_en', models.TextField(blank=True, editable=False, null=True, verbose_name='URL path')), - ('seo_title_fr', models.CharField(blank=True, help_text="Optional. 'Search Engine Friendly' title. This will appear at the top of the browser window.", max_length=255, null=True, verbose_name='page title')), - ('seo_title_en', models.CharField(blank=True, help_text="Optional. 'Search Engine Friendly' title. This will appear at the top of the browser window.", max_length=255, null=True, verbose_name='page title')), - ('search_description_fr', models.TextField(blank=True, null=True, verbose_name='search description')), - ('search_description_en', models.TextField(blank=True, null=True, verbose_name='search description')), - ('chapo', models.TextField(blank=True, verbose_name='Description rapide')), - ('chapo_fr', models.TextField(blank=True, null=True, verbose_name='Description rapide')), - ('chapo_en', models.TextField(blank=True, null=True, verbose_name='Description rapide')), - ('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')), - ('is_event', models.BooleanField(default=True, verbose_name='Évènement')), - ('date_start', models.DateTimeField(verbose_name='Date et heure de début')), - ('date_end', models.DateTimeField(blank=True, default=None, null=True, verbose_name='Date et heure de fin')), - ('all_day', models.BooleanField(default=False, verbose_name='Toute la journée')), - ('image', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='wagtailimages.Image', verbose_name='Image à la Une')), + ( + "page_ptr", + models.OneToOneField( + auto_created=True, + on_delete=django.db.models.deletion.CASCADE, + parent_link=True, + primary_key=True, + serialize=False, + to="wagtailcore.Page", + ), + ), + ( + "title_fr", + models.CharField( + help_text="The page title as you'd like it to be seen by the public", + max_length=255, + null=True, + verbose_name="title", + ), + ), + ( + "title_en", + models.CharField( + help_text="The page title as you'd like it to be seen by the public", + max_length=255, + null=True, + verbose_name="title", + ), + ), + ( + "slug_fr", + models.SlugField( + allow_unicode=True, + help_text="The name of the page as it will appear in URLs e.g http://domain.com/blog/[my-slug]/", + max_length=255, + null=True, + verbose_name="slug", + ), + ), + ( + "slug_en", + models.SlugField( + allow_unicode=True, + help_text="The name of the page as it will appear in URLs e.g http://domain.com/blog/[my-slug]/", + max_length=255, + null=True, + verbose_name="slug", + ), + ), + ( + "url_path_fr", + models.TextField( + blank=True, editable=False, null=True, verbose_name="URL path" + ), + ), + ( + "url_path_en", + models.TextField( + blank=True, editable=False, null=True, verbose_name="URL path" + ), + ), + ( + "seo_title_fr", + models.CharField( + blank=True, + help_text="Optional. 'Search Engine Friendly' title. This will appear at the top of the browser window.", + max_length=255, + null=True, + verbose_name="page title", + ), + ), + ( + "seo_title_en", + models.CharField( + blank=True, + help_text="Optional. 'Search Engine Friendly' title. This will appear at the top of the browser window.", + max_length=255, + null=True, + verbose_name="page title", + ), + ), + ( + "search_description_fr", + models.TextField( + blank=True, null=True, verbose_name="search description" + ), + ), + ( + "search_description_en", + models.TextField( + blank=True, null=True, verbose_name="search description" + ), + ), + ( + "chapo", + models.TextField(blank=True, verbose_name="Description rapide"), + ), + ( + "chapo_fr", + models.TextField( + blank=True, null=True, verbose_name="Description rapide" + ), + ), + ( + "chapo_en", + models.TextField( + blank=True, null=True, verbose_name="Description rapide" + ), + ), + ( + "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" + ), + ), + ( + "is_event", + models.BooleanField(default=True, verbose_name="Évènement"), + ), + ( + "date_start", + models.DateTimeField(verbose_name="Date et heure de début"), + ), + ( + "date_end", + models.DateTimeField( + blank=True, + default=None, + null=True, + verbose_name="Date et heure de fin", + ), + ), + ( + "all_day", + models.BooleanField(default=False, verbose_name="Toute la journée"), + ), + ( + "image", + models.ForeignKey( + blank=True, + null=True, + on_delete=django.db.models.deletion.SET_NULL, + related_name="+", + to="wagtailimages.Image", + verbose_name="Image à la Une", + ), + ), ], - options={ - 'verbose_name': 'Actualité', - 'verbose_name_plural': 'Actualités', - }, - bases=('wagtailcore.page',), + options={"verbose_name": "Actualité", "verbose_name_plural": "Actualités"}, + bases=("wagtailcore.page",), ), migrations.CreateModel( - name='COFDirectoryEntryPage', + name="COFDirectoryEntryPage", fields=[ - ('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='wagtailcore.Page')), - ('title_fr', models.CharField(help_text="The page title as you'd like it to be seen by the public", max_length=255, null=True, verbose_name='title')), - ('title_en', models.CharField(help_text="The page title as you'd like it to be seen by the public", max_length=255, null=True, verbose_name='title')), - ('slug_fr', models.SlugField(allow_unicode=True, help_text='The name of the page as it will appear in URLs e.g http://domain.com/blog/[my-slug]/', max_length=255, null=True, verbose_name='slug')), - ('slug_en', models.SlugField(allow_unicode=True, help_text='The name of the page as it will appear in URLs e.g http://domain.com/blog/[my-slug]/', max_length=255, null=True, verbose_name='slug')), - ('url_path_fr', models.TextField(blank=True, editable=False, null=True, verbose_name='URL path')), - ('url_path_en', models.TextField(blank=True, editable=False, null=True, verbose_name='URL path')), - ('seo_title_fr', models.CharField(blank=True, help_text="Optional. 'Search Engine Friendly' title. This will appear at the top of the browser window.", max_length=255, null=True, verbose_name='page title')), - ('seo_title_en', models.CharField(blank=True, help_text="Optional. 'Search Engine Friendly' title. This will appear at the top of the browser window.", max_length=255, null=True, verbose_name='page title')), - ('search_description_fr', models.TextField(blank=True, null=True, verbose_name='search description')), - ('search_description_en', models.TextField(blank=True, null=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(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='wagtailimages.Image', verbose_name='Image')), + ( + "page_ptr", + models.OneToOneField( + auto_created=True, + on_delete=django.db.models.deletion.CASCADE, + parent_link=True, + primary_key=True, + serialize=False, + to="wagtailcore.Page", + ), + ), + ( + "title_fr", + models.CharField( + help_text="The page title as you'd like it to be seen by the public", + max_length=255, + null=True, + verbose_name="title", + ), + ), + ( + "title_en", + models.CharField( + help_text="The page title as you'd like it to be seen by the public", + max_length=255, + null=True, + verbose_name="title", + ), + ), + ( + "slug_fr", + models.SlugField( + allow_unicode=True, + help_text="The name of the page as it will appear in URLs e.g http://domain.com/blog/[my-slug]/", + max_length=255, + null=True, + verbose_name="slug", + ), + ), + ( + "slug_en", + models.SlugField( + allow_unicode=True, + help_text="The name of the page as it will appear in URLs e.g http://domain.com/blog/[my-slug]/", + max_length=255, + null=True, + verbose_name="slug", + ), + ), + ( + "url_path_fr", + models.TextField( + blank=True, editable=False, null=True, verbose_name="URL path" + ), + ), + ( + "url_path_en", + models.TextField( + blank=True, editable=False, null=True, verbose_name="URL path" + ), + ), + ( + "seo_title_fr", + models.CharField( + blank=True, + help_text="Optional. 'Search Engine Friendly' title. This will appear at the top of the browser window.", + max_length=255, + null=True, + verbose_name="page title", + ), + ), + ( + "seo_title_en", + models.CharField( + blank=True, + help_text="Optional. 'Search Engine Friendly' title. This will appear at the top of the browser window.", + max_length=255, + null=True, + verbose_name="page title", + ), + ), + ( + "search_description_fr", + models.TextField( + blank=True, null=True, verbose_name="search description" + ), + ), + ( + "search_description_en", + models.TextField( + blank=True, null=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( + blank=True, + null=True, + on_delete=django.db.models.deletion.SET_NULL, + related_name="+", + to="wagtailimages.Image", + verbose_name="Image", + ), + ), ], options={ - 'verbose_name': "Éntrée d'annuaire", - 'verbose_name_plural': "Éntrées d'annuaire", + "verbose_name": "Éntrée d'annuaire", + "verbose_name_plural": "Éntrées d'annuaire", }, - bases=('wagtailcore.page',), + bases=("wagtailcore.page",), ), migrations.CreateModel( - name='COFDirectoryPage', + name="COFDirectoryPage", fields=[ - ('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='wagtailcore.Page')), - ('title_fr', models.CharField(help_text="The page title as you'd like it to be seen by the public", max_length=255, null=True, verbose_name='title')), - ('title_en', models.CharField(help_text="The page title as you'd like it to be seen by the public", max_length=255, null=True, verbose_name='title')), - ('slug_fr', models.SlugField(allow_unicode=True, help_text='The name of the page as it will appear in URLs e.g http://domain.com/blog/[my-slug]/', max_length=255, null=True, verbose_name='slug')), - ('slug_en', models.SlugField(allow_unicode=True, help_text='The name of the page as it will appear in URLs e.g http://domain.com/blog/[my-slug]/', max_length=255, null=True, verbose_name='slug')), - ('url_path_fr', models.TextField(blank=True, editable=False, null=True, verbose_name='URL path')), - ('url_path_en', models.TextField(blank=True, editable=False, null=True, verbose_name='URL path')), - ('seo_title_fr', models.CharField(blank=True, help_text="Optional. 'Search Engine Friendly' title. This will appear at the top of the browser window.", max_length=255, null=True, verbose_name='page title')), - ('seo_title_en', models.CharField(blank=True, help_text="Optional. 'Search Engine Friendly' title. This will appear at the top of the browser window.", max_length=255, null=True, verbose_name='page title')), - ('search_description_fr', models.TextField(blank=True, null=True, verbose_name='search description')), - ('search_description_en', models.TextField(blank=True, null=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')), + ( + "page_ptr", + models.OneToOneField( + auto_created=True, + on_delete=django.db.models.deletion.CASCADE, + parent_link=True, + primary_key=True, + serialize=False, + to="wagtailcore.Page", + ), + ), + ( + "title_fr", + models.CharField( + help_text="The page title as you'd like it to be seen by the public", + max_length=255, + null=True, + verbose_name="title", + ), + ), + ( + "title_en", + models.CharField( + help_text="The page title as you'd like it to be seen by the public", + max_length=255, + null=True, + verbose_name="title", + ), + ), + ( + "slug_fr", + models.SlugField( + allow_unicode=True, + help_text="The name of the page as it will appear in URLs e.g http://domain.com/blog/[my-slug]/", + max_length=255, + null=True, + verbose_name="slug", + ), + ), + ( + "slug_en", + models.SlugField( + allow_unicode=True, + help_text="The name of the page as it will appear in URLs e.g http://domain.com/blog/[my-slug]/", + max_length=255, + null=True, + verbose_name="slug", + ), + ), + ( + "url_path_fr", + models.TextField( + blank=True, editable=False, null=True, verbose_name="URL path" + ), + ), + ( + "url_path_en", + models.TextField( + blank=True, editable=False, null=True, verbose_name="URL path" + ), + ), + ( + "seo_title_fr", + models.CharField( + blank=True, + help_text="Optional. 'Search Engine Friendly' title. This will appear at the top of the browser window.", + max_length=255, + null=True, + verbose_name="page title", + ), + ), + ( + "seo_title_en", + models.CharField( + blank=True, + help_text="Optional. 'Search Engine Friendly' title. This will appear at the top of the browser window.", + max_length=255, + null=True, + verbose_name="page title", + ), + ), + ( + "search_description_fr", + models.TextField( + blank=True, null=True, verbose_name="search description" + ), + ), + ( + "search_description_en", + models.TextField( + blank=True, null=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={ - 'verbose_name': 'Annuaire (clubs, partenaires, bons plans...)', - 'verbose_name_plural': 'Annuaires', + "verbose_name": "Annuaire (clubs, partenaires, bons plans...)", + "verbose_name_plural": "Annuaires", }, - bases=('wagtailcore.page',), + bases=("wagtailcore.page",), ), migrations.CreateModel( - name='COFPage', + name="COFPage", fields=[ - ('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='wagtailcore.Page')), - ('title_fr', models.CharField(help_text="The page title as you'd like it to be seen by the public", max_length=255, null=True, verbose_name='title')), - ('title_en', models.CharField(help_text="The page title as you'd like it to be seen by the public", max_length=255, null=True, verbose_name='title')), - ('slug_fr', models.SlugField(allow_unicode=True, help_text='The name of the page as it will appear in URLs e.g http://domain.com/blog/[my-slug]/', max_length=255, null=True, verbose_name='slug')), - ('slug_en', models.SlugField(allow_unicode=True, help_text='The name of the page as it will appear in URLs e.g http://domain.com/blog/[my-slug]/', max_length=255, null=True, verbose_name='slug')), - ('url_path_fr', models.TextField(blank=True, editable=False, null=True, verbose_name='URL path')), - ('url_path_en', models.TextField(blank=True, editable=False, null=True, verbose_name='URL path')), - ('seo_title_fr', models.CharField(blank=True, help_text="Optional. 'Search Engine Friendly' title. This will appear at the top of the browser window.", max_length=255, null=True, verbose_name='page title')), - ('seo_title_en', models.CharField(blank=True, help_text="Optional. 'Search Engine Friendly' title. This will appear at the top of the browser window.", max_length=255, null=True, verbose_name='page title')), - ('search_description_fr', models.TextField(blank=True, null=True, verbose_name='search description')), - ('search_description_en', models.TextField(blank=True, null=True, verbose_name='search description')), - ('body', wagtail.wagtailcore.fields.StreamField((('heading', wagtail.wagtailcore.blocks.CharBlock(classname='full title')), ('paragraph', wagtail.wagtailcore.blocks.RichTextBlock()), ('image', wagtail.wagtailimages.blocks.ImageChooserBlock())))), - ('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)), - ('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)), + ( + "page_ptr", + models.OneToOneField( + auto_created=True, + on_delete=django.db.models.deletion.CASCADE, + parent_link=True, + primary_key=True, + serialize=False, + to="wagtailcore.Page", + ), + ), + ( + "title_fr", + models.CharField( + help_text="The page title as you'd like it to be seen by the public", + max_length=255, + null=True, + verbose_name="title", + ), + ), + ( + "title_en", + models.CharField( + help_text="The page title as you'd like it to be seen by the public", + max_length=255, + null=True, + verbose_name="title", + ), + ), + ( + "slug_fr", + models.SlugField( + allow_unicode=True, + help_text="The name of the page as it will appear in URLs e.g http://domain.com/blog/[my-slug]/", + max_length=255, + null=True, + verbose_name="slug", + ), + ), + ( + "slug_en", + models.SlugField( + allow_unicode=True, + help_text="The name of the page as it will appear in URLs e.g http://domain.com/blog/[my-slug]/", + max_length=255, + null=True, + verbose_name="slug", + ), + ), + ( + "url_path_fr", + models.TextField( + blank=True, editable=False, null=True, verbose_name="URL path" + ), + ), + ( + "url_path_en", + models.TextField( + blank=True, editable=False, null=True, verbose_name="URL path" + ), + ), + ( + "seo_title_fr", + models.CharField( + blank=True, + help_text="Optional. 'Search Engine Friendly' title. This will appear at the top of the browser window.", + max_length=255, + null=True, + verbose_name="page title", + ), + ), + ( + "seo_title_en", + models.CharField( + blank=True, + help_text="Optional. 'Search Engine Friendly' title. This will appear at the top of the browser window.", + max_length=255, + null=True, + verbose_name="page title", + ), + ), + ( + "search_description_fr", + models.TextField( + blank=True, null=True, verbose_name="search description" + ), + ), + ( + "search_description_en", + models.TextField( + blank=True, null=True, verbose_name="search description" + ), + ), + ( + "body", + wagtail.wagtailcore.fields.StreamField( + ( + ( + "heading", + wagtail.wagtailcore.blocks.CharBlock( + classname="full title" + ), + ), + ("paragraph", wagtail.wagtailcore.blocks.RichTextBlock()), + ("image", wagtail.wagtailimages.blocks.ImageChooserBlock()), + ) + ), + ), + ( + "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, + ), + ), + ( + "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={ - 'verbose_name': 'Page normale COF', - 'verbose_name_plural': 'Pages normales COF', + "verbose_name": "Page normale COF", + "verbose_name_plural": "Pages normales COF", }, - bases=('wagtailcore.page',), + bases=("wagtailcore.page",), ), migrations.CreateModel( - name='COFRootPage', + name="COFRootPage", fields=[ - ('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='wagtailcore.Page')), - ('title_fr', models.CharField(help_text="The page title as you'd like it to be seen by the public", max_length=255, null=True, verbose_name='title')), - ('title_en', models.CharField(help_text="The page title as you'd like it to be seen by the public", max_length=255, null=True, verbose_name='title')), - ('slug_fr', models.SlugField(allow_unicode=True, help_text='The name of the page as it will appear in URLs e.g http://domain.com/blog/[my-slug]/', max_length=255, null=True, verbose_name='slug')), - ('slug_en', models.SlugField(allow_unicode=True, help_text='The name of the page as it will appear in URLs e.g http://domain.com/blog/[my-slug]/', max_length=255, null=True, verbose_name='slug')), - ('url_path_fr', models.TextField(blank=True, editable=False, null=True, verbose_name='URL path')), - ('url_path_en', models.TextField(blank=True, editable=False, null=True, verbose_name='URL path')), - ('seo_title_fr', models.CharField(blank=True, help_text="Optional. 'Search Engine Friendly' title. This will appear at the top of the browser window.", max_length=255, null=True, verbose_name='page title')), - ('seo_title_en', models.CharField(blank=True, help_text="Optional. 'Search Engine Friendly' title. This will appear at the top of the browser window.", max_length=255, null=True, verbose_name='page title')), - ('search_description_fr', models.TextField(blank=True, null=True, verbose_name='search description')), - ('search_description_en', models.TextField(blank=True, null=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')), + ( + "page_ptr", + models.OneToOneField( + auto_created=True, + on_delete=django.db.models.deletion.CASCADE, + parent_link=True, + primary_key=True, + serialize=False, + to="wagtailcore.Page", + ), + ), + ( + "title_fr", + models.CharField( + help_text="The page title as you'd like it to be seen by the public", + max_length=255, + null=True, + verbose_name="title", + ), + ), + ( + "title_en", + models.CharField( + help_text="The page title as you'd like it to be seen by the public", + max_length=255, + null=True, + verbose_name="title", + ), + ), + ( + "slug_fr", + models.SlugField( + allow_unicode=True, + help_text="The name of the page as it will appear in URLs e.g http://domain.com/blog/[my-slug]/", + max_length=255, + null=True, + verbose_name="slug", + ), + ), + ( + "slug_en", + models.SlugField( + allow_unicode=True, + help_text="The name of the page as it will appear in URLs e.g http://domain.com/blog/[my-slug]/", + max_length=255, + null=True, + verbose_name="slug", + ), + ), + ( + "url_path_fr", + models.TextField( + blank=True, editable=False, null=True, verbose_name="URL path" + ), + ), + ( + "url_path_en", + models.TextField( + blank=True, editable=False, null=True, verbose_name="URL path" + ), + ), + ( + "seo_title_fr", + models.CharField( + blank=True, + help_text="Optional. 'Search Engine Friendly' title. This will appear at the top of the browser window.", + max_length=255, + null=True, + verbose_name="page title", + ), + ), + ( + "seo_title_en", + models.CharField( + blank=True, + help_text="Optional. 'Search Engine Friendly' title. This will appear at the top of the browser window.", + max_length=255, + null=True, + verbose_name="page title", + ), + ), + ( + "search_description_fr", + models.TextField( + blank=True, null=True, verbose_name="search description" + ), + ), + ( + "search_description_en", + models.TextField( + blank=True, null=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={ - 'verbose_name': 'Racine site du COF', - 'verbose_name_plural': 'Racines site du COF', + "verbose_name": "Racine site du COF", + "verbose_name_plural": "Racines site du COF", }, - bases=('wagtailcore.page', gestioncof.cms.models.COFActuIndexMixin), + bases=("wagtailcore.page", gestioncof.cms.models.COFActuIndexMixin), ), ] diff --git a/gestioncof/cms/migrations/0002_utilpage_and_fixes.py b/gestioncof/cms/migrations/0002_utilpage_and_fixes.py index 80929533..e628b81f 100644 --- a/gestioncof/cms/migrations/0002_utilpage_and_fixes.py +++ b/gestioncof/cms/migrations/0002_utilpage_and_fixes.py @@ -2,55 +2,159 @@ # Generated by Django 1.11.9 on 2018-04-28 13:46 from __future__ import unicode_literals -from django.db import migrations, models import django.db.models.deletion import wagtail.contrib.wagtailroutablepage.models import wagtail.wagtailcore.blocks import wagtail.wagtailcore.fields import wagtail.wagtailimages.blocks +from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ - ('wagtailcore', '0039_collectionviewrestriction'), - ('cofcms', '0001_initial'), + ("wagtailcore", "0039_collectionviewrestriction"), + ("cofcms", "0001_initial"), ] operations = [ migrations.CreateModel( - name='COFUtilPage', + name="COFUtilPage", fields=[ - ('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='wagtailcore.Page')), + ( + "page_ptr", + models.OneToOneField( + auto_created=True, + on_delete=django.db.models.deletion.CASCADE, + parent_link=True, + primary_key=True, + serialize=False, + to="wagtailcore.Page", + ), + ) ], options={ - 'verbose_name': 'Page utilitaire', - 'verbose_name_plural': 'Pages utilitaires', + "verbose_name": "Page utilitaire", + "verbose_name_plural": "Pages utilitaires", }, - bases=(wagtail.contrib.wagtailroutablepage.models.RoutablePageMixin, 'wagtailcore.page'), + bases=( + wagtail.contrib.wagtailroutablepage.models.RoutablePageMixin, + "wagtailcore.page", + ), ), migrations.AlterModelOptions( - name='cofdirectoryentrypage', - options={'verbose_name': "Entrée d'annuaire", 'verbose_name_plural': "Entrées d'annuaire"}, + name="cofdirectoryentrypage", + options={ + "verbose_name": "Entrée d'annuaire", + "verbose_name_plural": "Entrées d'annuaire", + }, ), migrations.AddField( - model_name='cofdirectorypage', - name='alphabetique', - field=models.BooleanField(default=True, verbose_name='Tri par ordre alphabétique ?'), + model_name="cofdirectorypage", + name="alphabetique", + field=models.BooleanField( + default=True, verbose_name="Tri par ordre alphabétique ?" + ), ), migrations.AlterField( - model_name='cofpage', - name='body', - field=wagtail.wagtailcore.fields.StreamField((('heading', wagtail.wagtailcore.blocks.CharBlock(classname='full title')), ('paragraph', wagtail.wagtailcore.blocks.RichTextBlock()), ('image', wagtail.wagtailimages.blocks.ImageChooserBlock()), ('iframe', wagtail.wagtailcore.blocks.StructBlock((('url', wagtail.wagtailcore.blocks.URLBlock('Adresse de la page')), ('height', wagtail.wagtailcore.blocks.CharBlock('Hauteur (en pixels)'))))))), + model_name="cofpage", + name="body", + field=wagtail.wagtailcore.fields.StreamField( + ( + ( + "heading", + wagtail.wagtailcore.blocks.CharBlock(classname="full title"), + ), + ("paragraph", wagtail.wagtailcore.blocks.RichTextBlock()), + ("image", wagtail.wagtailimages.blocks.ImageChooserBlock()), + ( + "iframe", + wagtail.wagtailcore.blocks.StructBlock( + ( + ( + "url", + wagtail.wagtailcore.blocks.URLBlock( + "Adresse de la page" + ), + ), + ( + "height", + wagtail.wagtailcore.blocks.CharBlock( + "Hauteur (en pixels)" + ), + ), + ) + ), + ), + ) + ), ), migrations.AlterField( - model_name='cofpage', - name='body_en', - field=wagtail.wagtailcore.fields.StreamField((('heading', wagtail.wagtailcore.blocks.CharBlock(classname='full title')), ('paragraph', wagtail.wagtailcore.blocks.RichTextBlock()), ('image', wagtail.wagtailimages.blocks.ImageChooserBlock()), ('iframe', wagtail.wagtailcore.blocks.StructBlock((('url', wagtail.wagtailcore.blocks.URLBlock('Adresse de la page')), ('height', wagtail.wagtailcore.blocks.CharBlock('Hauteur (en pixels)')))))), null=True), + model_name="cofpage", + name="body_en", + field=wagtail.wagtailcore.fields.StreamField( + ( + ( + "heading", + wagtail.wagtailcore.blocks.CharBlock(classname="full title"), + ), + ("paragraph", wagtail.wagtailcore.blocks.RichTextBlock()), + ("image", wagtail.wagtailimages.blocks.ImageChooserBlock()), + ( + "iframe", + wagtail.wagtailcore.blocks.StructBlock( + ( + ( + "url", + wagtail.wagtailcore.blocks.URLBlock( + "Adresse de la page" + ), + ), + ( + "height", + wagtail.wagtailcore.blocks.CharBlock( + "Hauteur (en pixels)" + ), + ), + ) + ), + ), + ), + null=True, + ), ), migrations.AlterField( - model_name='cofpage', - name='body_fr', - field=wagtail.wagtailcore.fields.StreamField((('heading', wagtail.wagtailcore.blocks.CharBlock(classname='full title')), ('paragraph', wagtail.wagtailcore.blocks.RichTextBlock()), ('image', wagtail.wagtailimages.blocks.ImageChooserBlock()), ('iframe', wagtail.wagtailcore.blocks.StructBlock((('url', wagtail.wagtailcore.blocks.URLBlock('Adresse de la page')), ('height', wagtail.wagtailcore.blocks.CharBlock('Hauteur (en pixels)')))))), null=True), + model_name="cofpage", + name="body_fr", + field=wagtail.wagtailcore.fields.StreamField( + ( + ( + "heading", + wagtail.wagtailcore.blocks.CharBlock(classname="full title"), + ), + ("paragraph", wagtail.wagtailcore.blocks.RichTextBlock()), + ("image", wagtail.wagtailimages.blocks.ImageChooserBlock()), + ( + "iframe", + wagtail.wagtailcore.blocks.StructBlock( + ( + ( + "url", + wagtail.wagtailcore.blocks.URLBlock( + "Adresse de la page" + ), + ), + ( + "height", + wagtail.wagtailcore.blocks.CharBlock( + "Hauteur (en pixels)" + ), + ), + ) + ), + ), + ), + null=True, + ), ), ] diff --git a/gestioncof/cms/models.py b/gestioncof/cms/models.py index c4119ece..10c090fe 100644 --- a/gestioncof/cms/models.py +++ b/gestioncof/cms/models.py @@ -13,7 +13,7 @@ from wagtail.wagtailimages.edit_handlers import ImageChooserPanel class COFActuIndexMixin: @property def actus(self): - actus = COFActuPage.objects.live().order_by('-date_start').descendant_of(self) + actus = COFActuPage.objects.live().order_by("-date_start").descendant_of(self) return actus @@ -22,10 +22,10 @@ class COFRootPage(Page, COFActuIndexMixin): introduction = RichTextField("Introduction") content_panels = Page.content_panels + [ - FieldPanel('introduction', classname="full"), + FieldPanel("introduction", classname="full") ] - subpage_types = ['COFActuIndexPage', 'COFPage', 'COFDirectoryPage', 'COFUtilPage'] + subpage_types = ["COFActuIndexPage", "COFPage", "COFDirectoryPage", "COFUtilPage"] class Meta: verbose_name = "Racine site du COF" @@ -45,19 +45,19 @@ class IFrameBlock(blocks.StructBlock): # Page lambda du site class COFPage(Page): - body = StreamField([ - ('heading', blocks.CharBlock(classname="full title")), - ('paragraph', blocks.RichTextBlock()), - ('image', ImageChooserBlock()), - ('iframe', IFrameBlock()), - ]) + body = StreamField( + [ + ("heading", blocks.CharBlock(classname="full title")), + ("paragraph", blocks.RichTextBlock()), + ("image", ImageChooserBlock()), + ("iframe", IFrameBlock()), + ] + ) - content_panels = Page.content_panels + [ - StreamFieldPanel('body'), - ] + content_panels = Page.content_panels + [StreamFieldPanel("body")] - subpage_types = ['COFDirectoryPage', 'COFPage'] - parent_page_types = ['COFPage', 'COFRootPage'] + subpage_types = ["COFDirectoryPage", "COFPage"] + parent_page_types = ["COFPage", "COFRootPage"] class Meta: verbose_name = "Page normale COF" @@ -66,8 +66,8 @@ class COFPage(Page): # Actualités class COFActuIndexPage(Page, COFActuIndexMixin): - subpage_types = ['COFActuPage'] - parent_page_types = ['COFRootPage'] + subpage_types = ["COFActuPage"] + parent_page_types = ["COFRootPage"] class Meta: verbose_name = "Index des actualités" @@ -75,9 +75,9 @@ class COFActuIndexPage(Page, COFActuIndexMixin): def get_context(self, request): context = super().get_context(request) - actus = COFActuPage.objects.live().descendant_of(self).order_by('-date_end') + actus = COFActuPage.objects.live().descendant_of(self).order_by("-date_end") - page = request.GET.get('page') + page = request.GET.get("page") paginator = Paginator(actus, 5) try: actus = paginator.page(page) @@ -86,7 +86,7 @@ class COFActuIndexPage(Page, COFActuIndexMixin): except EmptyPage: actus = paginator.page(paginator.num_pages) - context['actus'] = actus + context["actus"] = actus return context @@ -94,20 +94,24 @@ class COFActuPage(RoutablePageMixin, Page): chapo = models.TextField("Description rapide", blank=True) body = RichTextField("Contenu") image = models.ForeignKey( - 'wagtailimages.Image', verbose_name="Image à la Une", - null=True, blank=True, - on_delete=models.SET_NULL, related_name='+' + "wagtailimages.Image", + verbose_name="Image à la Une", + null=True, + blank=True, + on_delete=models.SET_NULL, + related_name="+", ) is_event = models.BooleanField("Évènement", default=True, blank=True) date_start = models.DateTimeField("Date et heure de début") - date_end = models.DateTimeField("Date et heure de fin", blank=True, - default=None, null=True) + date_end = models.DateTimeField( + "Date et heure de fin", blank=True, default=None, null=True + ) all_day = models.BooleanField("Toute la journée", default=False, blank=True) content_panels = Page.content_panels + [ - ImageChooserPanel('image'), - FieldPanel('chapo'), - FieldPanel('body', classname="full"), + ImageChooserPanel("image"), + FieldPanel("chapo"), + FieldPanel("body", classname="full"), FieldPanel("is_event"), FieldPanel("date_start"), FieldPanel("date_end"), @@ -115,7 +119,7 @@ class COFActuPage(RoutablePageMixin, Page): ] subpage_types = [] - parent_page_types = ['COFActuIndexPage'] + parent_page_types = ["COFActuIndexPage"] class Meta: verbose_name = "Actualité" @@ -125,21 +129,21 @@ class COFActuPage(RoutablePageMixin, Page): # Annuaires (Clubs, partenaires, bonnes adresses) class COFDirectoryPage(Page): introduction = RichTextField("Introduction") - alphabetique = models.BooleanField("Tri par ordre alphabétique ?", - default=True, blank=True) + alphabetique = models.BooleanField( + "Tri par ordre alphabétique ?", default=True, blank=True + ) content_panels = Page.content_panels + [ - FieldPanel('introduction'), - FieldPanel('alphabetique'), + FieldPanel("introduction"), + FieldPanel("alphabetique"), ] - subpage_types = ['COFActuPage', 'COFDirectoryEntryPage'] - parent_page_types = ['COFRootPage', 'COFPage'] + subpage_types = ["COFActuPage", "COFDirectoryEntryPage"] + parent_page_types = ["COFRootPage", "COFPage"] @property def entries(self): - entries = COFDirectoryEntryPage.objects.live()\ - .descendant_of(self) + entries = COFDirectoryEntryPage.objects.live().descendant_of(self) if self.alphabetique: entries = entries.order_by("title") return entries @@ -151,31 +155,46 @@ class COFDirectoryPage(Page): 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()), - ])), - ]) + 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', verbose_name="Image", - null=True, blank=True, - on_delete=models.SET_NULL, related_name='+' + "wagtailimages.Image", + verbose_name="Image", + null=True, + blank=True, + on_delete=models.SET_NULL, + related_name="+", ) content_panels = Page.content_panels + [ - ImageChooserPanel('image'), - FieldPanel('body', classname="full"), + ImageChooserPanel("image"), + FieldPanel("body", classname="full"), StreamFieldPanel("links"), ] subpage_types = [] - parent_page_types = ['COFDirectoryPage'] + parent_page_types = ["COFDirectoryPage"] class Meta: verbose_name = "Entrée d'annuaire" @@ -186,9 +205,10 @@ class COFDirectoryEntryPage(Page): class COFUtilPage(RoutablePageMixin, Page): # Mini calendrier - @route(r'^calendar/(\d+)/(\d+)/$') + @route(r"^calendar/(\d+)/(\d+)/$") def calendar(self, request, year, month): from .views import raw_calendar_view + return raw_calendar_view(request, int(year), int(month)) """ @@ -203,6 +223,7 @@ class COFUtilPage(RoutablePageMixin, Page): TODO : vérifier si ces problèmes ont été résolus dans les màj de wagtail et modeltranslation """ + def debugged_get_url(self, request): parent = COFRootPage.objects.parent_of(self).live().first() burl = parent.relative_url(request.site) diff --git a/gestioncof/cms/templatetags/cofcms_tags.py b/gestioncof/cms/templatetags/cofcms_tags.py index aaeafa56..686f15f6 100644 --- a/gestioncof/cms/templatetags/cofcms_tags.py +++ b/gestioncof/cms/templatetags/cofcms_tags.py @@ -11,7 +11,7 @@ register = template.Library() @register.filter() def obfuscate_mail(value): - val = value.replace('', '-').replace('@', 'arbre').replace('.', 'pont')[1:] + val = value.replace("", "-").replace("@", "arbre").replace(".", "pont")[1:] return val @@ -27,11 +27,11 @@ def calendar(context, month=None, year=None): prev_month = month_start - timedelta(days=2) month_prestart = month_start - timedelta(days=month_start.weekday()) month_postend = next_month + timedelta(days=(next_month.weekday() + 6) % 7) - events = COFActuPage.objects.live()\ - .filter(date_start__range=[month_prestart, - month_postend], - is_event=True)\ - .order_by('-date_start') + events = ( + COFActuPage.objects.live() + .filter(date_start__range=[month_prestart, month_postend], is_event=True) + .order_by("-date_start") + ) events = list(events) weeks = [] curday = month_prestart @@ -48,14 +48,23 @@ def calendar(context, month=None, year=None): del events[k] else: curevents.append(e) - day = {'day': curday.day, - 'date': curday, - 'class': (('today ' if curday == now.date() else '') - + ('in ' if (curday.month == month_start.month - and curday.year == month_start.year) - else 'out ') - + ('hasevent' if len(curevents) > 0 else '')), - 'events': curevents} + day = { + "day": curday.day, + "date": curday, + "class": ( + ("today " if curday == now.date() else "") + + ( + "in " + if ( + curday.month == month_start.month + and curday.year == month_start.year + ) + else "out " + ) + + ("hasevent" if len(curevents) > 0 else "") + ), + "events": curevents, + } week.append(day) curday += deltaday weeks.append(week) @@ -65,16 +74,23 @@ def calendar(context, month=None, year=None): utilpage = COFUtilPage.objects.live()[0] except COFUtilPage.DoesNotExist: utilpage = None - request = context['request'] + request = context["request"] burl = utilpage.debugged_get_url(request) + "/" - prev_url = burl + utilpage.reverse_subpage("calendar", - args=[str(prev_month.year), - str(prev_month.month)]) - next_url = burl + utilpage.reverse_subpage("calendar", - args=[str(next_month.year), - str(next_month.month)]) - context.push({"events": events, "weeks": weeks, "this_month": month_start, - "prev_month": prev_url, "next_month": next_url}) + prev_url = burl + utilpage.reverse_subpage( + "calendar", args=[str(prev_month.year), str(prev_month.month)] + ) + next_url = burl + utilpage.reverse_subpage( + "calendar", args=[str(next_month.year), str(next_month.month)] + ) + context.push( + { + "events": events, + "weeks": weeks, + "this_month": month_start, + "prev_month": prev_url, + "next_month": next_url, + } + ) return context @@ -87,9 +103,13 @@ def mini_calendar(event): week_start = date_start - timedelta(days=date_start.weekday()) curday = week_start for i in range(7): - days.append({'day': curday.day, - 'hasevent': curday >= date_start and curday <= date_end, - 'today': curday == today}) + days.append( + { + "day": curday.day, + "hasevent": curday >= date_start and curday <= date_end, + "today": curday == today, + } + ) curday += timedelta(days=1) return {"days": days} @@ -98,13 +118,13 @@ def mini_calendar(event): def dates(event): def factorize_suffix(a, b): i = -1 - imin = - min(len(a), len(b)) + imin = -min(len(a), len(b)) while i > imin and a[i] == b[i]: i -= 1 if i == -1: - return (a, b, '') + return (a, b, "") else: - return (a[:i + 1], b[:i + 1], a[i + 1:]) + return (a[: i + 1], b[: i + 1], a[i + 1 :]) datestart_string = formats.date_format(event.date_start) timestart_string = formats.time_format(event.date_start) @@ -113,22 +133,27 @@ def dates(event): if event.all_day: return _("le %s") % datestart_string else: - return _("le %s de %s à %s") % \ - (datestart_string, - timestart_string, - formats.time_format(event.date_end)) + return _("le %s de %s à %s") % ( + datestart_string, + timestart_string, + formats.time_format(event.date_end), + ) else: dateend_string = formats.date_format(event.date_end) - diffstart, diffend, common = factorize_suffix(datestart_string, - dateend_string) + diffstart, diffend, common = factorize_suffix( + datestart_string, dateend_string + ) if event.all_day: - return _("du %s au %s%s") % \ - (diffstart, diffend, common) + return _("du %s au %s%s") % (diffstart, diffend, common) else: - return _("du %s%s à %s au %s à %s") % \ - (diffstart, common, timestart_string, - diffend, formats.time_format(event.date_end)) + return _("du %s%s à %s au %s à %s") % ( + diffstart, + common, + timestart_string, + diffend, + formats.time_format(event.date_end), + ) else: if event.all_day: return _("le %s") % datestart_string diff --git a/gestioncof/cms/translation.py b/gestioncof/cms/translation.py index 5aee1381..0a11520e 100644 --- a/gestioncof/cms/translation.py +++ b/gestioncof/cms/translation.py @@ -13,42 +13,29 @@ from .models import ( @register(COFRootPage) class COFRootPageTr(WagtailTranslationOptions): - fields = ( - 'introduction', - ) + fields = ("introduction",) @register(COFPage) class COFPageTr(WagtailTranslationOptions): - fields = ( - 'body', - ) + fields = ("body",) @register(COFActuIndexPage) class COFActuIndexPageTr(WagtailTranslationOptions): - fields = ( - ) + fields = () @register(COFActuPage) class COFActuPageTr(WagtailTranslationOptions): - fields = ( - 'chapo', - 'body', - ) + fields = ("chapo", "body") @register(COFDirectoryPage) class COFDirectoryPageTr(WagtailTranslationOptions): - fields = ( - 'introduction', - ) + fields = ("introduction",) @register(COFDirectoryEntryPage) class COFDirectoryEntryPageTr(WagtailTranslationOptions): - fields = ( - 'body', - 'links', - ) + fields = ("body", "links") diff --git a/gestioncof/cms/views.py b/gestioncof/cms/views.py index 8b4ac122..1b9ce4e9 100644 --- a/gestioncof/cms/views.py +++ b/gestioncof/cms/views.py @@ -2,5 +2,4 @@ from django.shortcuts import render def raw_calendar_view(request, year, month): - return render(request, "cofcms/calendar_raw.html", - {"month": month, "year": year}) + return render(request, "cofcms/calendar_raw.html", {"month": month, "year": year})