def get_pages_with_application(self, path, language): """Returns all pages containing application for current path, or any parrent. Returned list is sorted by path length, longer path first. """ paths = levelize_path(path) q = Q() for path in paths: # build q for all the paths q |= Q(title_set__path=path, title_set__language=language) eapp_pages = self.published().filter(q & Q(title_set__application_urls__gt="")).distinct() # add proper ordering app_pages.query.order_by.extend(("LENGTH(`cms_title`.`path`) DESC",)) return app_pages
def test_01_levelize_path(self): path = '/application/item/new' output = ['/application/item/new', '/application/item', '/application'] self.assertEqual(urlutils.levelize_path(path), output)
def test_01_levelize_path(self): path = '/application/item/new' output = ['/application/item/new', '/application/item', '/application'] self.assertEqual(urlutils.levelize_path(path), output)