misc: give redirection URL access to subpage regex components (#28919)

This commit is contained in:
Frédéric Péters 2018-12-11 20:43:08 +01:00
parent b80464063d
commit eed3f2c1a8
2 changed files with 4 additions and 3 deletions

View File

@ -410,8 +410,8 @@ class Page(models.Model):
ordered_pages = Page.get_as_reordered_flat_hierarchy(cls.objects.all())
return [x.get_serialized_page() for x in ordered_pages]
def get_redirect_url(self):
return utils.get_templated_url(self.redirect_url)
def get_redirect_url(self, context=None):
return utils.get_templated_url(self.redirect_url, context=context)
def get_last_update_time(self):
cells = CellBase.get_cells(page_id=self.id)

View File

@ -440,7 +440,8 @@ def publish_page(request, page, status=200, template_name=None):
raise PermissionDenied()
if page.redirect_url:
return HttpResponseRedirect(page.get_redirect_url())
return HttpResponseRedirect(
page.get_redirect_url(context=request.extra_context_data))
cells = CellBase.get_cells(page=page)
extend_with_parent_cells(cells, hierarchy=pages)