misc: add page absolute URI to cell rendering context (#28777
This commit is contained in:
parent
f598929c34
commit
192b426700
|
@ -9,7 +9,7 @@
|
|||
{% for category_formdefs in categories_formdefs %}
|
||||
<li><h4>{{ category_formdefs.grouper }}</h4></li>
|
||||
{% for formdef in category_formdefs.list|dictsort:"title" %}
|
||||
<li><a href="{{formdef.backoffice_submission_url}}?NameID={{name_id}}&ReturnURL={% page_absolute_url cell.page %}">{{formdef.title}}</a></li>
|
||||
<li><a href="{{formdef.backoffice_submission_url}}?NameID={{name_id}}&ReturnURL={{ absolute_uri|iriencode }}">{{formdef.title}}</a></li>
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
|
|
@ -692,6 +692,7 @@ class CellBase(six.with_metaclass(CellMeta, models.Model)):
|
|||
'site_base': request.build_absolute_uri('/')[:-1],
|
||||
'synchronous': True,
|
||||
'user': None, # compat
|
||||
'absolute_uri': request.build_absolute_uri,
|
||||
}
|
||||
if not self.is_relevant(context):
|
||||
return ''
|
||||
|
|
|
@ -143,6 +143,7 @@ def render_cell(request, cell):
|
|||
'cell': cell,
|
||||
'synchronous': True,
|
||||
'site_base': request.build_absolute_uri('/')[:-1],
|
||||
'absolute_uri': request.build_absolute_uri
|
||||
}
|
||||
if request.GET.get('ctx'):
|
||||
context.update(signing.loads(request.GET['ctx']))
|
||||
|
@ -353,7 +354,9 @@ def empty_site(request):
|
|||
|
||||
|
||||
def page(request):
|
||||
request.extra_context_data = {}
|
||||
request.extra_context_data = {
|
||||
'absolute_uri': request.build_absolute_uri()
|
||||
}
|
||||
url = request.path_info
|
||||
parts = [x for x in request.path_info.strip('/').split('/') if x]
|
||||
if len(parts) == 1 and parts[0] == 'index':
|
||||
|
|
|
@ -726,7 +726,7 @@ def test_sub_slug(app, john_doe, jane_doe):
|
|||
cell.save()
|
||||
|
||||
cell2 = JsonCell(page=page3, url='http://example.net', order=0, placeholder='content')
|
||||
cell2.template_string = 'AA{{ blah }}BB'
|
||||
cell2.template_string = 'AA{{ blah }}BB{{ absolute_uri }}CC'
|
||||
cell2.save()
|
||||
|
||||
with mock.patch('combo.utils.requests.get') as requests_get:
|
||||
|
@ -745,7 +745,10 @@ def test_sub_slug(app, john_doe, jane_doe):
|
|||
# check sub page
|
||||
resp = app.get('/users/whatever/plop/', status=404)
|
||||
resp = app.get('/users/whatever/blah/', status=200)
|
||||
assert 'AAwhateverBB' in resp.text
|
||||
cell_url = re.findall(r'data-ajax-cell-url="(.*)"', resp.text)[0]
|
||||
extra_ctx = re.findall(r'data-extra-context="(.*)"', resp.text)[0]
|
||||
resp = app.get(cell_url + '?ctx=' + extra_ctx)
|
||||
assert resp.text == 'AAwhateverBBhttp://testserver/users/whatever/blah/CC'
|
||||
|
||||
# custom behaviour for <user_id>, it will add the user to context
|
||||
page2.sub_slug = '(?P<user_id>[0-9]+)'
|
||||
|
|
Loading…
Reference in New Issue