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
This commit is contained in:
parent
f10bd1eea2
commit
e56123e5f7
1 changed files with 12 additions and 6 deletions
|
@ -9,6 +9,12 @@ from wagtail.images.blocks import ImageChooserBlock
|
|||
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
|
||||
class COFActuIndexMixin:
|
||||
@property
|
||||
|
@ -18,7 +24,7 @@ class COFActuIndexMixin:
|
|||
|
||||
|
||||
# Racine du site du COF
|
||||
class COFRootPage(RoutablePageMixin, Page, COFActuIndexMixin):
|
||||
class COFRootPage(AbsoluteURLMixin, RoutablePageMixin, Page, COFActuIndexMixin):
|
||||
introduction = RichTextField("Introduction")
|
||||
|
||||
content_panels = Page.content_panels + [
|
||||
|
@ -62,7 +68,7 @@ class IFrameBlock(blocks.StructBlock):
|
|||
|
||||
|
||||
# Page lambda du site
|
||||
class COFPage(Page):
|
||||
class COFPage(AbsoluteURLMixin, Page):
|
||||
body = StreamField(
|
||||
[
|
||||
("heading", blocks.CharBlock(classname="full title")),
|
||||
|
@ -83,7 +89,7 @@ class COFPage(Page):
|
|||
|
||||
|
||||
# Actualités
|
||||
class COFActuIndexPage(Page, COFActuIndexMixin):
|
||||
class COFActuIndexPage(AbsoluteURLMixin, Page, COFActuIndexMixin):
|
||||
subpage_types = ["COFActuPage"]
|
||||
parent_page_types = ["COFRootPage"]
|
||||
|
||||
|
@ -108,7 +114,7 @@ class COFActuIndexPage(Page, COFActuIndexMixin):
|
|||
return context
|
||||
|
||||
|
||||
class COFActuPage(RoutablePageMixin, Page):
|
||||
class COFActuPage(AbsoluteURLMixin, RoutablePageMixin, Page):
|
||||
chapo = models.TextField("Description rapide", blank=True)
|
||||
body = RichTextField("Contenu")
|
||||
image = models.ForeignKey(
|
||||
|
@ -145,7 +151,7 @@ class COFActuPage(RoutablePageMixin, Page):
|
|||
|
||||
|
||||
# Annuaires (Clubs, partenaires, bonnes adresses)
|
||||
class COFDirectoryPage(Page):
|
||||
class COFDirectoryPage(AbsoluteURLMixin, Page):
|
||||
introduction = RichTextField("Introduction")
|
||||
alphabetique = models.BooleanField(
|
||||
"Tri par ordre alphabétique ?", default=True, blank=True
|
||||
|
@ -171,7 +177,7 @@ class COFDirectoryPage(Page):
|
|||
verbose_name_plural = "Annuaires"
|
||||
|
||||
|
||||
class COFDirectoryEntryPage(Page):
|
||||
class COFDirectoryEntryPage(AbsoluteURLMixin, Page):
|
||||
body = RichTextField("Description")
|
||||
links = StreamField(
|
||||
[
|
||||
|
|
Loading…
Reference in a new issue