def get_base_url(): try: _id, root_path, root_url = Site.get_site_root_paths()[0] return root_url except IndexError: pass return None
def get_url(self, obj): root_path = Site.get_site_root_paths() if len(root_path): root_path = root_path[0][1] if obj.url_path == root_path: return '/' elif root_path in obj.url_path: if obj.url_path.index(root_path) == 0: return obj.url.replace(root_path, '/', 1) return obj.url_path
def get_url(self, obj): """ Overrides BuildableDetailView's get_url() to return a url from the Page model url_path property """ root_path = Site.get_site_root_paths() if len(root_path): root_path = root_path[0][1] if obj.url_path == root_path: return '/' elif root_path in obj.url_path: if obj.url_path.index(root_path) == 0: return obj.url.replace(root_path, '/', 1) return obj.url_path
def get_url_parts(self): root_paths = set(Site.get_site_root_paths()) test_site_paths = set([x for x in root_paths if 'test' in Site.objects.get(id=x[0]).site_name.lower()]) prod_site_paths = root_paths - test_site_paths if False and self.content_type.app_label == 'kehmet': root_paths = test_site_paths else: root_paths = prod_site_paths for (site_id, root_path, root_url) in root_paths: if self.url_path.startswith(root_path): page_path = reverse('wagtail_serve', args=(self.url_path[len(root_path):],)) # Remove the trailing slash from the URL reverse generates if # WAGTAIL_APPEND_SLASH is False and we're not trying to serve # the root path if not WAGTAIL_APPEND_SLASH and page_path != '/': page_path = page_path.rstrip('/') return (site_id, root_url, page_path)
def get_url_parts(self): root_paths = set(Site.get_site_root_paths()) test_site_paths = set([x for x in root_paths if 'test' in Site.objects.get(id=x[0]).site_name.lower()]) prod_site_paths = root_paths - test_site_paths if self.content_type.app_label == 'kehmet': root_paths = test_site_paths else: root_paths = prod_site_paths for (site_id, root_path, root_url) in root_paths: if self.url_path.startswith(root_path): page_path = reverse('wagtail_serve', args=(self.url_path[len(root_path):],)) # Remove the trailing slash from the URL reverse generates if # WAGTAIL_APPEND_SLASH is False and we're not trying to serve # the root path if not WAGTAIL_APPEND_SLASH and page_path != '/': page_path = page_path.rstrip('/') return (site_id, root_url, page_path)
def local_url(self): root_paths = Site.get_site_root_paths() for (id, root_path, root_url) in Site.get_site_root_paths(): if self.url_path.startswith(root_path): return self.url_path[len(root_path) - 1:]
def get_main_site_root_url(): for site_id, root_path, root_url in Site.get_site_root_paths(): if root_path == '/home/': return root_url
def get_main_site_root_url(): for site_id, root_path, root_url in Site.get_site_root_paths(): if root_path == '/home/': return root_url
def ready(self): from wagtail.wagtailcore.models import Site root_paths = Site.get_site_root_paths() Site.get_site_root_paths = lambda: root_paths
def local_url(self): for (id, root_path, root_url) in Site.get_site_root_paths(): if self.url_path.startswith(root_path): return self.url_path[len(root_path) - 1:]