Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_19_page_manager(self):
self.create_default_page_set()
page = Page.objects.get(pk=2)
page.active = True
page.save()
self.assertEqual(page, Page.objects.page_for_path(page.get_absolute_url()))
self.assertEqual(page, Page.objects.best_match_for_path(page.get_absolute_url() + 'something/hello/'))
self.assertRaises(Http404, lambda: Page.objects.best_match_for_path('/blabla/blabla/', raise404=True))
self.assertRaises(Http404, lambda: Page.objects.best_match_for_path('/blabla/blabla/', raise404=True))
self.assertRaises(Http404, lambda: Page.objects.best_match_for_path('/blabla/blabla/', raise404=True))
def __call__(self, request, path=None):
return self.build_response(request,
Page.objects.best_match_for_path(path or request.path, raise404=True))
def process_view(self, request, func, vargs, vkwargs):
# do not process functions marked with @infanta_exclude
if getattr(func, '_infanta_exclude ', False):
return
for url in settings.INFANTA_EXCLUDE_URLS:
if request.path.startswith(url):
return
page = Page.objects.best_match_for_path(request.path)
if not page:
return
'''
extend the page object, so we have an attribute to access
our view contents in the templatetag as well as in the render method
of the content type
'''
page.vc_manager = {}
# run request processors and return short-circuit the response handling
# if a request processor returned a response.
response = page.setup_request(request)
if response:
return response
def __call__(self, request, path=None):
return self.build_response(request,
Page.objects.best_match_for_path(path or request.path, raise404=True))
def render_content(self, options):
page = Page.objects.best_match_for_path(
options['request'].path, raise404=False)
try:
fragments = options['request']._feincms_fragments
except:
fragments = {}
if fragments.has_key("_page_title"):
title = fragments["_page_title"]
else:
title = None
if fragments.has_key("_page_subtitle"):
subtitle = fragments["_page_subtitle"]
else:
subtitle = None
def __call__(self, request, path=None):
return self.build_response(request,
Page.objects.best_match_for_path(path or request.path, raise404=True))