Compare commits

...

1 commit

Author SHA1 Message Date
Martin Pépin
e56123e5f7
Sitecof: always use absolute URLs
Remaining to do: change the 'sitecof' slug to 'news' in production.

By using absolute URLs we can prevent Daphne from adding the /gestion
prefix and serve the COF site under cof.ens.fr/news rather than
cof.ens.fr/gestion/sitecof
2020-08-30 15:20:37 +02:00

View file

@ -9,6 +9,12 @@ from wagtail.images.blocks import ImageChooserBlock
from wagtail.images.edit_handlers import ImageChooserPanel from wagtail.images.edit_handlers import ImageChooserPanel
# Récriture des URL publiques par surcharge de get_url
class AbsoluteURLMixin:
def get_url(self, request=None, current_site=None):
return self.get_full_url(request=request)
# Page pouvant afficher des actualités # Page pouvant afficher des actualités
class COFActuIndexMixin: class COFActuIndexMixin:
@property @property
@ -18,7 +24,7 @@ class COFActuIndexMixin:
# Racine du site du COF # Racine du site du COF
class COFRootPage(RoutablePageMixin, Page, COFActuIndexMixin): class COFRootPage(AbsoluteURLMixin, RoutablePageMixin, Page, COFActuIndexMixin):
introduction = RichTextField("Introduction") introduction = RichTextField("Introduction")
content_panels = Page.content_panels + [ content_panels = Page.content_panels + [
@ -62,7 +68,7 @@ class IFrameBlock(blocks.StructBlock):
# Page lambda du site # Page lambda du site
class COFPage(Page): class COFPage(AbsoluteURLMixin, Page):
body = StreamField( body = StreamField(
[ [
("heading", blocks.CharBlock(classname="full title")), ("heading", blocks.CharBlock(classname="full title")),
@ -83,7 +89,7 @@ class COFPage(Page):
# Actualités # Actualités
class COFActuIndexPage(Page, COFActuIndexMixin): class COFActuIndexPage(AbsoluteURLMixin, Page, COFActuIndexMixin):
subpage_types = ["COFActuPage"] subpage_types = ["COFActuPage"]
parent_page_types = ["COFRootPage"] parent_page_types = ["COFRootPage"]
@ -108,7 +114,7 @@ class COFActuIndexPage(Page, COFActuIndexMixin):
return context return context
class COFActuPage(RoutablePageMixin, Page): class COFActuPage(AbsoluteURLMixin, 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(
@ -145,7 +151,7 @@ class COFActuPage(RoutablePageMixin, Page):
# Annuaires (Clubs, partenaires, bonnes adresses) # Annuaires (Clubs, partenaires, bonnes adresses)
class COFDirectoryPage(Page): class COFDirectoryPage(AbsoluteURLMixin, Page):
introduction = RichTextField("Introduction") introduction = RichTextField("Introduction")
alphabetique = models.BooleanField( alphabetique = models.BooleanField(
"Tri par ordre alphabétique ?", default=True, blank=True "Tri par ordre alphabétique ?", default=True, blank=True
@ -171,7 +177,7 @@ class COFDirectoryPage(Page):
verbose_name_plural = "Annuaires" verbose_name_plural = "Annuaires"
class COFDirectoryEntryPage(Page): class COFDirectoryEntryPage(AbsoluteURLMixin, Page):
body = RichTextField("Description") body = RichTextField("Description")
links = StreamField( links = StreamField(
[ [