Index: cms/converters.py |
=================================================================== |
--- a/cms/converters.py |
+++ b/cms/converters.py |
@@ -442,6 +442,8 @@ |
'get_page_content': self.get_page_content, |
'get_pages_metadata': self.get_pages_metadata, |
'get_canonical_url': self.get_canonical_url, |
+ 'get_page_url': self.get_page_url, |
+ 'page_has_locale': self.page_has_locale, |
} |
for dirname, dictionary in [('filters', filters), |
@@ -588,6 +590,18 @@ |
stack.append(item) |
return structured |
+ def page_has_locale(self, page, locale): |
+ return self._params['source'].has_locale(locale, page) |
+ |
+ def get_page_url(self, page, locale=None, redirect=False): |
Vasily Kuznetsov
2019/01/14 13:29:27
The redirect argument is great, but it's not descr
rhowell
2019/01/14 14:56:47
Done.
|
+ if not locale: |
+ locale = self._params['locale'] |
+ if self.page_has_locale(page, locale): |
Vasily Kuznetsov
2019/01/14 13:29:27
Since the body of this if is the same as that of t
rhowell
2019/01/14 14:56:47
Yeah, I agree. Done.
|
+ return self._params['source'].resolve_link(page, locale)[1] |
+ if redirect: |
+ return self._params['source'].resolve_link(page, locale)[1] |
+ raise Exception('{} does not exist in {}'.format(page, locale)) |
+ |
converters = { |
'html': RawConverter, |