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
|
||||
|
||||
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"
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
)
|
||||
|
|
|
@ -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):
|
||||
name = 'gestioncof.cms'
|
||||
label = 'cofcms'
|
||||
verbose_name = 'CMS COF'
|
||||
name = "gestioncof.cms"
|
||||
label = "cofcms"
|
||||
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
|
||||
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,
|
||||
),
|
||||
),
|
||||
]
|
||||
|
|
|
@ -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()),
|
||||
])
|
||||
|
||||
content_panels = Page.content_panels + [
|
||||
StreamFieldPanel('body'),
|
||||
body = StreamField(
|
||||
[
|
||||
("heading", blocks.CharBlock(classname="full title")),
|
||||
("paragraph", blocks.RichTextBlock()),
|
||||
("image", ImageChooserBlock()),
|
||||
("iframe", IFrameBlock()),
|
||||
]
|
||||
)
|
||||
|
||||
subpage_types = ['COFDirectoryPage', 'COFPage']
|
||||
parent_page_types = ['COFPage', 'COFRootPage']
|
||||
content_panels = Page.content_panels + [StreamFieldPanel("body")]
|
||||
|
||||
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)
|
||||
|
|
|
@ -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,
|
||||
return _("le %s de %s à %s") % (
|
||||
datestart_string,
|
||||
timestart_string,
|
||||
formats.time_format(event.date_end))
|
||||
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
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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})
|
||||
|
|
Loading…
Reference in a new issue