Sitecof : Surcharge get_url_parts plutôt que get_url
This commit is contained in:
parent
a59711183d
commit
737a3e377c
2 changed files with 14 additions and 11 deletions
|
@ -206,5 +206,5 @@ MAIL_DATA = {
|
||||||
# SiteCOF URL rewrite rules
|
# SiteCOF URL rewrite rules
|
||||||
# ---
|
# ---
|
||||||
|
|
||||||
SITECOF_INTERNAL_URL = r"/gestion/(en/|fr/|)sitecof/"
|
SITECOF_INTERNAL_URL = r"^/gestion/(en/|fr/|)sitecof/"
|
||||||
SITECOF_PUBLIC_URL = r"/\\1news/"
|
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
|
# Récriture des URL publiques par surcharge de get_url
|
||||||
class COFRewriteUrlMixin:
|
class COFRewriteUrlMixin:
|
||||||
def get_url(self, request=None, current_site=None):
|
def get_url_parts(self, request=None, current_site=None):
|
||||||
url = super().get_url(request, current_site)
|
(site_id, root_url, page_path) = super().get_url_parts(request)
|
||||||
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
|
|
||||||
|
|
||||||
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
|
# Page pouvant afficher des actualités
|
||||||
|
|
Loading…
Reference in a new issue