forked from DGNum/gestioCOF
style -- black + isort
This commit is contained in:
parent
376cc96343
commit
39eaf4b109
12 changed files with 1224 additions and 328 deletions
|
@ -6,6 +6,6 @@ English formatting.
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
DATETIME_FORMAT = r'l N j, Y \a\t P'
|
DATETIME_FORMAT = r"l N j, Y \a\t P"
|
||||||
DATE_FORMAT = r'l N j, Y'
|
DATE_FORMAT = r"l N j, Y"
|
||||||
TIME_FORMAT = r'P'
|
TIME_FORMAT = r"P"
|
||||||
|
|
|
@ -2,6 +2,6 @@
|
||||||
Formats français.
|
Formats français.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
DATETIME_FORMAT = r'l j F Y \à H\hi'
|
DATETIME_FORMAT = r"l j F Y \à H\hi"
|
||||||
DATE_FORMAT = r'l j F Y'
|
DATE_FORMAT = r"l j F Y"
|
||||||
TIME_FORMAT = r'H\hi'
|
TIME_FORMAT = r"H\hi"
|
||||||
|
|
|
@ -57,64 +57,64 @@ INSTALLED_APPS = [
|
||||||
"gestioncof",
|
"gestioncof",
|
||||||
# Must be before 'django.contrib.admin'.
|
# Must be before 'django.contrib.admin'.
|
||||||
# https://django-autocomplete-light.readthedocs.io/en/master/install.html
|
# https://django-autocomplete-light.readthedocs.io/en/master/install.html
|
||||||
'dal',
|
"dal",
|
||||||
'dal_select2',
|
"dal_select2",
|
||||||
'django.contrib.auth',
|
"django.contrib.auth",
|
||||||
'django.contrib.contenttypes',
|
"django.contrib.contenttypes",
|
||||||
'django.contrib.sessions',
|
"django.contrib.sessions",
|
||||||
'django.contrib.sites',
|
"django.contrib.sites",
|
||||||
'django.contrib.messages',
|
"django.contrib.messages",
|
||||||
'django.contrib.staticfiles',
|
"django.contrib.staticfiles",
|
||||||
'django.contrib.admin',
|
"django.contrib.admin",
|
||||||
'django.contrib.admindocs',
|
"django.contrib.admindocs",
|
||||||
'bda',
|
"bda",
|
||||||
'captcha',
|
"captcha",
|
||||||
'django_cas_ng',
|
"django_cas_ng",
|
||||||
'bootstrapform',
|
"bootstrapform",
|
||||||
'kfet',
|
"kfet",
|
||||||
'kfet.open',
|
"kfet.open",
|
||||||
'channels',
|
"channels",
|
||||||
'widget_tweaks',
|
"widget_tweaks",
|
||||||
'custommail',
|
"custommail",
|
||||||
'djconfig',
|
"djconfig",
|
||||||
'wagtail.wagtailforms',
|
"wagtail.wagtailforms",
|
||||||
'wagtail.wagtailredirects',
|
"wagtail.wagtailredirects",
|
||||||
'wagtail.wagtailembeds',
|
"wagtail.wagtailembeds",
|
||||||
'wagtail.wagtailsites',
|
"wagtail.wagtailsites",
|
||||||
'wagtail.wagtailusers',
|
"wagtail.wagtailusers",
|
||||||
'wagtail.wagtailsnippets',
|
"wagtail.wagtailsnippets",
|
||||||
'wagtail.wagtaildocs',
|
"wagtail.wagtaildocs",
|
||||||
'wagtail.wagtailimages',
|
"wagtail.wagtailimages",
|
||||||
'wagtail.wagtailsearch',
|
"wagtail.wagtailsearch",
|
||||||
'wagtail.wagtailadmin',
|
"wagtail.wagtailadmin",
|
||||||
'wagtail.wagtailcore',
|
"wagtail.wagtailcore",
|
||||||
'wagtail.contrib.modeladmin',
|
"wagtail.contrib.modeladmin",
|
||||||
'wagtail.contrib.wagtailroutablepage',
|
"wagtail.contrib.wagtailroutablepage",
|
||||||
'wagtailmenus',
|
"wagtailmenus",
|
||||||
'wagtail_modeltranslation',
|
"wagtail_modeltranslation",
|
||||||
'modelcluster',
|
"modelcluster",
|
||||||
'taggit',
|
"taggit",
|
||||||
'kfet.auth',
|
"kfet.auth",
|
||||||
'kfet.cms',
|
"kfet.cms",
|
||||||
'gestioncof.cms',
|
"gestioncof.cms",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
MIDDLEWARE = [
|
MIDDLEWARE = [
|
||||||
"corsheaders.middleware.CorsMiddleware",
|
"corsheaders.middleware.CorsMiddleware",
|
||||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
"django.contrib.sessions.middleware.SessionMiddleware",
|
||||||
'django.middleware.common.CommonMiddleware',
|
"django.middleware.common.CommonMiddleware",
|
||||||
'django.middleware.csrf.CsrfViewMiddleware',
|
"django.middleware.csrf.CsrfViewMiddleware",
|
||||||
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
"django.contrib.auth.middleware.AuthenticationMiddleware",
|
||||||
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
|
"django.contrib.auth.middleware.SessionAuthenticationMiddleware",
|
||||||
'kfet.auth.middleware.TemporaryAuthMiddleware',
|
"kfet.auth.middleware.TemporaryAuthMiddleware",
|
||||||
'django.contrib.messages.middleware.MessageMiddleware',
|
"django.contrib.messages.middleware.MessageMiddleware",
|
||||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
"django.middleware.clickjacking.XFrameOptionsMiddleware",
|
||||||
'django.middleware.security.SecurityMiddleware',
|
"django.middleware.security.SecurityMiddleware",
|
||||||
'djconfig.middleware.DjConfigMiddleware',
|
"djconfig.middleware.DjConfigMiddleware",
|
||||||
'wagtail.wagtailcore.middleware.SiteMiddleware',
|
"wagtail.wagtailcore.middleware.SiteMiddleware",
|
||||||
'wagtail.wagtailredirects.middleware.RedirectMiddleware',
|
"wagtail.wagtailredirects.middleware.RedirectMiddleware",
|
||||||
'django.middleware.locale.LocaleMiddleware',
|
"django.middleware.locale.LocaleMiddleware",
|
||||||
]
|
]
|
||||||
|
|
||||||
ROOT_URLCONF = "cof.urls"
|
ROOT_URLCONF = "cof.urls"
|
||||||
|
@ -167,10 +167,7 @@ USE_L10N = True
|
||||||
|
|
||||||
USE_TZ = True
|
USE_TZ = True
|
||||||
|
|
||||||
LANGUAGES = (
|
LANGUAGES = (("fr", "Français"), ("en", "English"))
|
||||||
('fr', 'Français'),
|
|
||||||
('en', 'English'),
|
|
||||||
)
|
|
||||||
|
|
||||||
# Various additional settings
|
# Various additional settings
|
||||||
SITE_ID = 1
|
SITE_ID = 1
|
||||||
|
|
|
@ -134,6 +134,5 @@ if settings.DEBUG:
|
||||||
|
|
||||||
# Wagtail for uncatched
|
# Wagtail for uncatched
|
||||||
urlpatterns += i18n_patterns(
|
urlpatterns += i18n_patterns(
|
||||||
url(r'', include(wagtail_urls)),
|
url(r"", include(wagtail_urls)), prefix_default_language=False
|
||||||
prefix_default_language=False
|
|
||||||
)
|
)
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
default_app_config = 'gestioncof.cms.apps.COFCMSAppConfig'
|
default_app_config = "gestioncof.cms.apps.COFCMSAppConfig"
|
||||||
|
|
|
@ -2,6 +2,6 @@ from django.apps import AppConfig
|
||||||
|
|
||||||
|
|
||||||
class COFCMSAppConfig(AppConfig):
|
class COFCMSAppConfig(AppConfig):
|
||||||
name = 'gestioncof.cms'
|
name = "gestioncof.cms"
|
||||||
label = 'cofcms'
|
label = "cofcms"
|
||||||
verbose_name = 'CMS COF'
|
verbose_name = "CMS COF"
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -2,55 +2,159 @@
|
||||||
# Generated by Django 1.11.9 on 2018-04-28 13:46
|
# Generated by Django 1.11.9 on 2018-04-28 13:46
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from django.db import migrations, models
|
|
||||||
import django.db.models.deletion
|
import django.db.models.deletion
|
||||||
import wagtail.contrib.wagtailroutablepage.models
|
import wagtail.contrib.wagtailroutablepage.models
|
||||||
import wagtail.wagtailcore.blocks
|
import wagtail.wagtailcore.blocks
|
||||||
import wagtail.wagtailcore.fields
|
import wagtail.wagtailcore.fields
|
||||||
import wagtail.wagtailimages.blocks
|
import wagtail.wagtailimages.blocks
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
('wagtailcore', '0039_collectionviewrestriction'),
|
("wagtailcore", "0039_collectionviewrestriction"),
|
||||||
('cofcms', '0001_initial'),
|
("cofcms", "0001_initial"),
|
||||||
]
|
]
|
||||||
|
|
||||||
operations = [
|
operations = [
|
||||||
migrations.CreateModel(
|
migrations.CreateModel(
|
||||||
name='COFUtilPage',
|
name="COFUtilPage",
|
||||||
fields=[
|
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={
|
options={
|
||||||
'verbose_name': 'Page utilitaire',
|
"verbose_name": "Page utilitaire",
|
||||||
'verbose_name_plural': 'Pages utilitaires',
|
"verbose_name_plural": "Pages utilitaires",
|
||||||
},
|
},
|
||||||
bases=(wagtail.contrib.wagtailroutablepage.models.RoutablePageMixin, 'wagtailcore.page'),
|
bases=(
|
||||||
|
wagtail.contrib.wagtailroutablepage.models.RoutablePageMixin,
|
||||||
|
"wagtailcore.page",
|
||||||
|
),
|
||||||
),
|
),
|
||||||
migrations.AlterModelOptions(
|
migrations.AlterModelOptions(
|
||||||
name='cofdirectoryentrypage',
|
name="cofdirectoryentrypage",
|
||||||
options={'verbose_name': "Entrée d'annuaire", 'verbose_name_plural': "Entrées d'annuaire"},
|
options={
|
||||||
|
"verbose_name": "Entrée d'annuaire",
|
||||||
|
"verbose_name_plural": "Entrées d'annuaire",
|
||||||
|
},
|
||||||
),
|
),
|
||||||
migrations.AddField(
|
migrations.AddField(
|
||||||
model_name='cofdirectorypage',
|
model_name="cofdirectorypage",
|
||||||
name='alphabetique',
|
name="alphabetique",
|
||||||
field=models.BooleanField(default=True, verbose_name='Tri par ordre alphabétique ?'),
|
field=models.BooleanField(
|
||||||
|
default=True, verbose_name="Tri par ordre alphabétique ?"
|
||||||
|
),
|
||||||
),
|
),
|
||||||
migrations.AlterField(
|
migrations.AlterField(
|
||||||
model_name='cofpage',
|
model_name="cofpage",
|
||||||
name='body',
|
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)'))))))),
|
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(
|
migrations.AlterField(
|
||||||
model_name='cofpage',
|
model_name="cofpage",
|
||||||
name='body_en',
|
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),
|
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(
|
migrations.AlterField(
|
||||||
model_name='cofpage',
|
model_name="cofpage",
|
||||||
name='body_fr',
|
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),
|
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,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|
|
@ -13,7 +13,7 @@ from wagtail.wagtailimages.edit_handlers import ImageChooserPanel
|
||||||
class COFActuIndexMixin:
|
class COFActuIndexMixin:
|
||||||
@property
|
@property
|
||||||
def actus(self):
|
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
|
return actus
|
||||||
|
|
||||||
|
|
||||||
|
@ -22,10 +22,10 @@ class COFRootPage(Page, COFActuIndexMixin):
|
||||||
introduction = RichTextField("Introduction")
|
introduction = RichTextField("Introduction")
|
||||||
|
|
||||||
content_panels = Page.content_panels + [
|
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:
|
class Meta:
|
||||||
verbose_name = "Racine site du COF"
|
verbose_name = "Racine site du COF"
|
||||||
|
@ -45,19 +45,19 @@ class IFrameBlock(blocks.StructBlock):
|
||||||
|
|
||||||
# Page lambda du site
|
# Page lambda du site
|
||||||
class COFPage(Page):
|
class COFPage(Page):
|
||||||
body = StreamField([
|
body = StreamField(
|
||||||
('heading', blocks.CharBlock(classname="full title")),
|
[
|
||||||
('paragraph', blocks.RichTextBlock()),
|
("heading", blocks.CharBlock(classname="full title")),
|
||||||
('image', ImageChooserBlock()),
|
("paragraph", blocks.RichTextBlock()),
|
||||||
('iframe', IFrameBlock()),
|
("image", ImageChooserBlock()),
|
||||||
])
|
("iframe", IFrameBlock()),
|
||||||
|
|
||||||
content_panels = Page.content_panels + [
|
|
||||||
StreamFieldPanel('body'),
|
|
||||||
]
|
]
|
||||||
|
)
|
||||||
|
|
||||||
subpage_types = ['COFDirectoryPage', 'COFPage']
|
content_panels = Page.content_panels + [StreamFieldPanel("body")]
|
||||||
parent_page_types = ['COFPage', 'COFRootPage']
|
|
||||||
|
subpage_types = ["COFDirectoryPage", "COFPage"]
|
||||||
|
parent_page_types = ["COFPage", "COFRootPage"]
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
verbose_name = "Page normale COF"
|
verbose_name = "Page normale COF"
|
||||||
|
@ -66,8 +66,8 @@ class COFPage(Page):
|
||||||
|
|
||||||
# Actualités
|
# Actualités
|
||||||
class COFActuIndexPage(Page, COFActuIndexMixin):
|
class COFActuIndexPage(Page, COFActuIndexMixin):
|
||||||
subpage_types = ['COFActuPage']
|
subpage_types = ["COFActuPage"]
|
||||||
parent_page_types = ['COFRootPage']
|
parent_page_types = ["COFRootPage"]
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
verbose_name = "Index des actualités"
|
verbose_name = "Index des actualités"
|
||||||
|
@ -75,9 +75,9 @@ class COFActuIndexPage(Page, COFActuIndexMixin):
|
||||||
|
|
||||||
def get_context(self, request):
|
def get_context(self, request):
|
||||||
context = super().get_context(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)
|
paginator = Paginator(actus, 5)
|
||||||
try:
|
try:
|
||||||
actus = paginator.page(page)
|
actus = paginator.page(page)
|
||||||
|
@ -86,7 +86,7 @@ class COFActuIndexPage(Page, COFActuIndexMixin):
|
||||||
except EmptyPage:
|
except EmptyPage:
|
||||||
actus = paginator.page(paginator.num_pages)
|
actus = paginator.page(paginator.num_pages)
|
||||||
|
|
||||||
context['actus'] = actus
|
context["actus"] = actus
|
||||||
return context
|
return context
|
||||||
|
|
||||||
|
|
||||||
|
@ -94,20 +94,24 @@ class COFActuPage(RoutablePageMixin, Page):
|
||||||
chapo = models.TextField("Description rapide", blank=True)
|
chapo = models.TextField("Description rapide", blank=True)
|
||||||
body = RichTextField("Contenu")
|
body = RichTextField("Contenu")
|
||||||
image = models.ForeignKey(
|
image = models.ForeignKey(
|
||||||
'wagtailimages.Image', verbose_name="Image à la Une",
|
"wagtailimages.Image",
|
||||||
null=True, blank=True,
|
verbose_name="Image à la Une",
|
||||||
on_delete=models.SET_NULL, related_name='+'
|
null=True,
|
||||||
|
blank=True,
|
||||||
|
on_delete=models.SET_NULL,
|
||||||
|
related_name="+",
|
||||||
)
|
)
|
||||||
is_event = models.BooleanField("Évènement", default=True, blank=True)
|
is_event = models.BooleanField("Évènement", default=True, blank=True)
|
||||||
date_start = models.DateTimeField("Date et heure de début")
|
date_start = models.DateTimeField("Date et heure de début")
|
||||||
date_end = models.DateTimeField("Date et heure de fin", blank=True,
|
date_end = models.DateTimeField(
|
||||||
default=None, null=True)
|
"Date et heure de fin", blank=True, default=None, null=True
|
||||||
|
)
|
||||||
all_day = models.BooleanField("Toute la journée", default=False, blank=True)
|
all_day = models.BooleanField("Toute la journée", default=False, blank=True)
|
||||||
|
|
||||||
content_panels = Page.content_panels + [
|
content_panels = Page.content_panels + [
|
||||||
ImageChooserPanel('image'),
|
ImageChooserPanel("image"),
|
||||||
FieldPanel('chapo'),
|
FieldPanel("chapo"),
|
||||||
FieldPanel('body', classname="full"),
|
FieldPanel("body", classname="full"),
|
||||||
FieldPanel("is_event"),
|
FieldPanel("is_event"),
|
||||||
FieldPanel("date_start"),
|
FieldPanel("date_start"),
|
||||||
FieldPanel("date_end"),
|
FieldPanel("date_end"),
|
||||||
|
@ -115,7 +119,7 @@ class COFActuPage(RoutablePageMixin, Page):
|
||||||
]
|
]
|
||||||
|
|
||||||
subpage_types = []
|
subpage_types = []
|
||||||
parent_page_types = ['COFActuIndexPage']
|
parent_page_types = ["COFActuIndexPage"]
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
verbose_name = "Actualité"
|
verbose_name = "Actualité"
|
||||||
|
@ -125,21 +129,21 @@ class COFActuPage(RoutablePageMixin, Page):
|
||||||
# Annuaires (Clubs, partenaires, bonnes adresses)
|
# Annuaires (Clubs, partenaires, bonnes adresses)
|
||||||
class COFDirectoryPage(Page):
|
class COFDirectoryPage(Page):
|
||||||
introduction = RichTextField("Introduction")
|
introduction = RichTextField("Introduction")
|
||||||
alphabetique = models.BooleanField("Tri par ordre alphabétique ?",
|
alphabetique = models.BooleanField(
|
||||||
default=True, blank=True)
|
"Tri par ordre alphabétique ?", default=True, blank=True
|
||||||
|
)
|
||||||
|
|
||||||
content_panels = Page.content_panels + [
|
content_panels = Page.content_panels + [
|
||||||
FieldPanel('introduction'),
|
FieldPanel("introduction"),
|
||||||
FieldPanel('alphabetique'),
|
FieldPanel("alphabetique"),
|
||||||
]
|
]
|
||||||
|
|
||||||
subpage_types = ['COFActuPage', 'COFDirectoryEntryPage']
|
subpage_types = ["COFActuPage", "COFDirectoryEntryPage"]
|
||||||
parent_page_types = ['COFRootPage', 'COFPage']
|
parent_page_types = ["COFRootPage", "COFPage"]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def entries(self):
|
def entries(self):
|
||||||
entries = COFDirectoryEntryPage.objects.live()\
|
entries = COFDirectoryEntryPage.objects.live().descendant_of(self)
|
||||||
.descendant_of(self)
|
|
||||||
if self.alphabetique:
|
if self.alphabetique:
|
||||||
entries = entries.order_by("title")
|
entries = entries.order_by("title")
|
||||||
return entries
|
return entries
|
||||||
|
@ -151,31 +155,46 @@ class COFDirectoryPage(Page):
|
||||||
|
|
||||||
class COFDirectoryEntryPage(Page):
|
class COFDirectoryEntryPage(Page):
|
||||||
body = RichTextField("Description")
|
body = RichTextField("Description")
|
||||||
links = StreamField([
|
links = StreamField(
|
||||||
('lien', blocks.StructBlock([
|
[
|
||||||
('url', blocks.URLBlock(required=True)),
|
(
|
||||||
('texte', blocks.CharBlock()),
|
"lien",
|
||||||
])),
|
blocks.StructBlock(
|
||||||
('contact', blocks.StructBlock([
|
[
|
||||||
('email', blocks.EmailBlock(required=True)),
|
("url", blocks.URLBlock(required=True)),
|
||||||
('texte', blocks.CharBlock()),
|
("texte", blocks.CharBlock()),
|
||||||
])),
|
]
|
||||||
])
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"contact",
|
||||||
|
blocks.StructBlock(
|
||||||
|
[
|
||||||
|
("email", blocks.EmailBlock(required=True)),
|
||||||
|
("texte", blocks.CharBlock()),
|
||||||
|
]
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
image = models.ForeignKey(
|
image = models.ForeignKey(
|
||||||
'wagtailimages.Image', verbose_name="Image",
|
"wagtailimages.Image",
|
||||||
null=True, blank=True,
|
verbose_name="Image",
|
||||||
on_delete=models.SET_NULL, related_name='+'
|
null=True,
|
||||||
|
blank=True,
|
||||||
|
on_delete=models.SET_NULL,
|
||||||
|
related_name="+",
|
||||||
)
|
)
|
||||||
|
|
||||||
content_panels = Page.content_panels + [
|
content_panels = Page.content_panels + [
|
||||||
ImageChooserPanel('image'),
|
ImageChooserPanel("image"),
|
||||||
FieldPanel('body', classname="full"),
|
FieldPanel("body", classname="full"),
|
||||||
StreamFieldPanel("links"),
|
StreamFieldPanel("links"),
|
||||||
]
|
]
|
||||||
|
|
||||||
subpage_types = []
|
subpage_types = []
|
||||||
parent_page_types = ['COFDirectoryPage']
|
parent_page_types = ["COFDirectoryPage"]
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
verbose_name = "Entrée d'annuaire"
|
verbose_name = "Entrée d'annuaire"
|
||||||
|
@ -186,9 +205,10 @@ class COFDirectoryEntryPage(Page):
|
||||||
class COFUtilPage(RoutablePageMixin, Page):
|
class COFUtilPage(RoutablePageMixin, Page):
|
||||||
|
|
||||||
# Mini calendrier
|
# Mini calendrier
|
||||||
@route(r'^calendar/(\d+)/(\d+)/$')
|
@route(r"^calendar/(\d+)/(\d+)/$")
|
||||||
def calendar(self, request, year, month):
|
def calendar(self, request, year, month):
|
||||||
from .views import raw_calendar_view
|
from .views import raw_calendar_view
|
||||||
|
|
||||||
return raw_calendar_view(request, int(year), int(month))
|
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
|
TODO : vérifier si ces problèmes ont été résolus dans les màj de wagtail
|
||||||
et modeltranslation
|
et modeltranslation
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def debugged_get_url(self, request):
|
def debugged_get_url(self, request):
|
||||||
parent = COFRootPage.objects.parent_of(self).live().first()
|
parent = COFRootPage.objects.parent_of(self).live().first()
|
||||||
burl = parent.relative_url(request.site)
|
burl = parent.relative_url(request.site)
|
||||||
|
|
|
@ -11,7 +11,7 @@ register = template.Library()
|
||||||
|
|
||||||
@register.filter()
|
@register.filter()
|
||||||
def obfuscate_mail(value):
|
def obfuscate_mail(value):
|
||||||
val = value.replace('', '-').replace('@', 'arbre').replace('.', 'pont')[1:]
|
val = value.replace("", "-").replace("@", "arbre").replace(".", "pont")[1:]
|
||||||
return val
|
return val
|
||||||
|
|
||||||
|
|
||||||
|
@ -27,11 +27,11 @@ def calendar(context, month=None, year=None):
|
||||||
prev_month = month_start - timedelta(days=2)
|
prev_month = month_start - timedelta(days=2)
|
||||||
month_prestart = month_start - timedelta(days=month_start.weekday())
|
month_prestart = month_start - timedelta(days=month_start.weekday())
|
||||||
month_postend = next_month + timedelta(days=(next_month.weekday() + 6) % 7)
|
month_postend = next_month + timedelta(days=(next_month.weekday() + 6) % 7)
|
||||||
events = COFActuPage.objects.live()\
|
events = (
|
||||||
.filter(date_start__range=[month_prestart,
|
COFActuPage.objects.live()
|
||||||
month_postend],
|
.filter(date_start__range=[month_prestart, month_postend], is_event=True)
|
||||||
is_event=True)\
|
.order_by("-date_start")
|
||||||
.order_by('-date_start')
|
)
|
||||||
events = list(events)
|
events = list(events)
|
||||||
weeks = []
|
weeks = []
|
||||||
curday = month_prestart
|
curday = month_prestart
|
||||||
|
@ -48,14 +48,23 @@ def calendar(context, month=None, year=None):
|
||||||
del events[k]
|
del events[k]
|
||||||
else:
|
else:
|
||||||
curevents.append(e)
|
curevents.append(e)
|
||||||
day = {'day': curday.day,
|
day = {
|
||||||
'date': curday,
|
"day": curday.day,
|
||||||
'class': (('today ' if curday == now.date() else '')
|
"date": curday,
|
||||||
+ ('in ' if (curday.month == month_start.month
|
"class": (
|
||||||
and curday.year == month_start.year)
|
("today " if curday == now.date() else "")
|
||||||
else 'out ')
|
+ (
|
||||||
+ ('hasevent' if len(curevents) > 0 else '')),
|
"in "
|
||||||
'events': curevents}
|
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)
|
week.append(day)
|
||||||
curday += deltaday
|
curday += deltaday
|
||||||
weeks.append(week)
|
weeks.append(week)
|
||||||
|
@ -65,16 +74,23 @@ def calendar(context, month=None, year=None):
|
||||||
utilpage = COFUtilPage.objects.live()[0]
|
utilpage = COFUtilPage.objects.live()[0]
|
||||||
except COFUtilPage.DoesNotExist:
|
except COFUtilPage.DoesNotExist:
|
||||||
utilpage = None
|
utilpage = None
|
||||||
request = context['request']
|
request = context["request"]
|
||||||
burl = utilpage.debugged_get_url(request) + "/"
|
burl = utilpage.debugged_get_url(request) + "/"
|
||||||
prev_url = burl + utilpage.reverse_subpage("calendar",
|
prev_url = burl + utilpage.reverse_subpage(
|
||||||
args=[str(prev_month.year),
|
"calendar", args=[str(prev_month.year), str(prev_month.month)]
|
||||||
str(prev_month.month)])
|
)
|
||||||
next_url = burl + utilpage.reverse_subpage("calendar",
|
next_url = burl + utilpage.reverse_subpage(
|
||||||
args=[str(next_month.year),
|
"calendar", args=[str(next_month.year), str(next_month.month)]
|
||||||
str(next_month.month)])
|
)
|
||||||
context.push({"events": events, "weeks": weeks, "this_month": month_start,
|
context.push(
|
||||||
"prev_month": prev_url, "next_month": next_url})
|
{
|
||||||
|
"events": events,
|
||||||
|
"weeks": weeks,
|
||||||
|
"this_month": month_start,
|
||||||
|
"prev_month": prev_url,
|
||||||
|
"next_month": next_url,
|
||||||
|
}
|
||||||
|
)
|
||||||
return context
|
return context
|
||||||
|
|
||||||
|
|
||||||
|
@ -87,9 +103,13 @@ def mini_calendar(event):
|
||||||
week_start = date_start - timedelta(days=date_start.weekday())
|
week_start = date_start - timedelta(days=date_start.weekday())
|
||||||
curday = week_start
|
curday = week_start
|
||||||
for i in range(7):
|
for i in range(7):
|
||||||
days.append({'day': curday.day,
|
days.append(
|
||||||
'hasevent': curday >= date_start and curday <= date_end,
|
{
|
||||||
'today': curday == today})
|
"day": curday.day,
|
||||||
|
"hasevent": curday >= date_start and curday <= date_end,
|
||||||
|
"today": curday == today,
|
||||||
|
}
|
||||||
|
)
|
||||||
curday += timedelta(days=1)
|
curday += timedelta(days=1)
|
||||||
return {"days": days}
|
return {"days": days}
|
||||||
|
|
||||||
|
@ -102,7 +122,7 @@ def dates(event):
|
||||||
while i > imin and a[i] == b[i]:
|
while i > imin and a[i] == b[i]:
|
||||||
i -= 1
|
i -= 1
|
||||||
if i == -1:
|
if i == -1:
|
||||||
return (a, b, '')
|
return (a, b, "")
|
||||||
else:
|
else:
|
||||||
return (a[: i + 1], b[: i + 1], a[i + 1 :])
|
return (a[: i + 1], b[: i + 1], a[i + 1 :])
|
||||||
|
|
||||||
|
@ -113,22 +133,27 @@ def dates(event):
|
||||||
if event.all_day:
|
if event.all_day:
|
||||||
return _("le %s") % datestart_string
|
return _("le %s") % datestart_string
|
||||||
else:
|
else:
|
||||||
return _("le %s de %s à %s") % \
|
return _("le %s de %s à %s") % (
|
||||||
(datestart_string,
|
datestart_string,
|
||||||
timestart_string,
|
timestart_string,
|
||||||
formats.time_format(event.date_end))
|
formats.time_format(event.date_end),
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
dateend_string = formats.date_format(event.date_end)
|
dateend_string = formats.date_format(event.date_end)
|
||||||
diffstart, diffend, common = factorize_suffix(datestart_string,
|
diffstart, diffend, common = factorize_suffix(
|
||||||
dateend_string)
|
datestart_string, dateend_string
|
||||||
|
)
|
||||||
if event.all_day:
|
if event.all_day:
|
||||||
return _("du %s au %s%s") % \
|
return _("du %s au %s%s") % (diffstart, diffend, common)
|
||||||
(diffstart, diffend, common)
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
return _("du %s%s à %s au %s à %s") % \
|
return _("du %s%s à %s au %s à %s") % (
|
||||||
(diffstart, common, timestart_string,
|
diffstart,
|
||||||
diffend, formats.time_format(event.date_end))
|
common,
|
||||||
|
timestart_string,
|
||||||
|
diffend,
|
||||||
|
formats.time_format(event.date_end),
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
if event.all_day:
|
if event.all_day:
|
||||||
return _("le %s") % datestart_string
|
return _("le %s") % datestart_string
|
||||||
|
|
|
@ -13,42 +13,29 @@ from .models import (
|
||||||
|
|
||||||
@register(COFRootPage)
|
@register(COFRootPage)
|
||||||
class COFRootPageTr(WagtailTranslationOptions):
|
class COFRootPageTr(WagtailTranslationOptions):
|
||||||
fields = (
|
fields = ("introduction",)
|
||||||
'introduction',
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@register(COFPage)
|
@register(COFPage)
|
||||||
class COFPageTr(WagtailTranslationOptions):
|
class COFPageTr(WagtailTranslationOptions):
|
||||||
fields = (
|
fields = ("body",)
|
||||||
'body',
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@register(COFActuIndexPage)
|
@register(COFActuIndexPage)
|
||||||
class COFActuIndexPageTr(WagtailTranslationOptions):
|
class COFActuIndexPageTr(WagtailTranslationOptions):
|
||||||
fields = (
|
fields = ()
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@register(COFActuPage)
|
@register(COFActuPage)
|
||||||
class COFActuPageTr(WagtailTranslationOptions):
|
class COFActuPageTr(WagtailTranslationOptions):
|
||||||
fields = (
|
fields = ("chapo", "body")
|
||||||
'chapo',
|
|
||||||
'body',
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@register(COFDirectoryPage)
|
@register(COFDirectoryPage)
|
||||||
class COFDirectoryPageTr(WagtailTranslationOptions):
|
class COFDirectoryPageTr(WagtailTranslationOptions):
|
||||||
fields = (
|
fields = ("introduction",)
|
||||||
'introduction',
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@register(COFDirectoryEntryPage)
|
@register(COFDirectoryEntryPage)
|
||||||
class COFDirectoryEntryPageTr(WagtailTranslationOptions):
|
class COFDirectoryEntryPageTr(WagtailTranslationOptions):
|
||||||
fields = (
|
fields = ("body", "links")
|
||||||
'body',
|
|
||||||
'links',
|
|
||||||
)
|
|
||||||
|
|
|
@ -2,5 +2,4 @@ from django.shortcuts import render
|
||||||
|
|
||||||
|
|
||||||
def raw_calendar_view(request, year, month):
|
def raw_calendar_view(request, year, month):
|
||||||
return render(request, "cofcms/calendar_raw.html",
|
return render(request, "cofcms/calendar_raw.html", {"month": month, "year": year})
|
||||||
{"month": month, "year": year})
|
|
||||||
|
|
Loading…
Reference in a new issue