wcs: add ?cancelurl query parameter to links in forms of category cell (#58848)

This commit is contained in:
Frédéric Péters 2021-12-28 10:38:47 +01:00
parent c122f8892e
commit 6b0a078848
2 changed files with 19 additions and 1 deletions

View File

@ -16,7 +16,7 @@
<ul>
{% for form in forms %}
<li class="{{ form.css_classes|join:" " }}"
><a href="{{ form.url }}tryauth">{{ form.title }}</a>
><a href="{{ form.url }}tryauth?cancelurl={{ absolute_uri|iriencode }}">{{ form.title }}</a>
{% if form.description %}<div class="description">{{ form.description|safe }}</div>{% endif %}
</li>
{% endfor %}

View File

@ -1093,6 +1093,24 @@ def test_forms_of_category_cell_render(mock_send, context):
context.pop('combo_display_even_empty_categories')
@mock.patch('combo.apps.wcs.utils.requests.send', side_effect=mocked_requests_send)
def test_forms_of_category_cancelurl(mock_send, app):
page = Page(title='xxx', slug='test_forms_of_category_cell_render', template_name='standard')
page.save()
cell = WcsFormsOfCategoryCell(page=page, placeholder='content', order=0)
cell.category_reference = 'default:test-9'
cell.ordering = 'alpha'
cell.save()
resp = app.get(page.get_online_url())
ajax_cell_url = PyQuery(resp.text).find('[data-ajax-cell-url]').attr('data-ajax-cell-url')
extra_ctx = PyQuery(resp.text).find('[data-ajax-cell-url]').attr('data-extra-context')
cell_resp = app.get(ajax_cell_url + '?ctx=' + extra_ctx)
assert (
PyQuery(cell_resp.text).find('a').attr('href')
== 'http://127.0.0.1:8999/a-second-form-title/tryauth?cancelurl=http://testserver/test_forms_of_category_cell_render/'
)
@mock.patch('combo.apps.wcs.utils.requests.send', side_effect=mocked_requests_send)
def test_forms_of_category_cell_validity(mock_send, context):
page = Page.objects.create(