Sitecof: Récriture des URLs publiques #752
2 changed files with 14 additions and 11 deletions
|
@ -206,5 +206,5 @@ MAIL_DATA = {
|
|||
# SiteCOF URL rewrite rules
|
||||
# ---
|
||||
|
||||
SITECOF_INTERNAL_URL = r"/gestion/(en/|fr/|)sitecof/"
|
||||
SITECOF_PUBLIC_URL = r"/\\1news/"
|
||||
SITECOF_INTERNAL_URL = r"^/gestion/(en/|fr/|)sitecof/"
|
||||
SITECOF_PUBLIC_URL = "/\\1news/"
|
||||
|
|
|
@ -14,16 +14,19 @@ from wagtail.images.edit_handlers import ImageChooserPanel
|
|||
|
||||
# Récriture des URL publiques par surcharge de get_url
|
||||
class COFRewriteUrlMixin:
|
||||
def get_url(self, request=None, current_site=None):
|
||||
url = super().get_url(request, current_site)
|
||||
pattern = getattr(
|
||||
settings, "SITECOF_INTERNAL_URL", r"/gestion/(en/|fr/|)sitecof/"
|
||||
)
|
||||
replace = getattr(settings, "SITECOF_PUBLIC_URL", "/\\1news/")
|
||||
url = re.sub(pattern, replace, url)
|
||||
return url
|
||||
def get_url_parts(self, request=None, current_site=None):
|
||||
(site_id, root_url, page_path) = super().get_url_parts(request)
|
||||
|
||||
url = property(get_url)
|
||||
if page_path is None:
|
||||
return (site_id, root_url, page_path)
|
||||
|
||||
pattern = getattr(settings, "SITECOF_INTERNAL_URL", r"^/(en/|fr/|)sitecof/")
|
||||
replace = getattr(settings, "SITECOF_PUBLIC_URL", "/\\1news/")
|
||||
|
||||
print(pattern, replace, page_path)
|
||||
page_path = re.sub(pattern, replace, page_path)
|
||||
|
||||
return (site_id, root_url, page_path)
|
||||
|
||||
|
||||
# Page pouvant afficher des actualités
|
||||
|
|
Loading…
Reference in a new issue