Projet

Général

Profil

0001-wcs-add-cancelurl-query-parameter-to-links-in-forms-.patch

Frédéric Péters, 28 décembre 2021 11:36

Télécharger (2,47 ko)

Voir les différences:

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

 .../templates/combo/wcs/forms_of_category.html |  2 +-
 tests/test_wcs.py                              | 18 ++++++++++++++++++
 2 files changed, 19 insertions(+), 1 deletion(-)
combo/apps/wcs/templates/combo/wcs/forms_of_category.html
16 16
<ul>
17 17
{% for form in forms %}
18 18
<li class="{{ form.css_classes|join:" " }}"
19
  ><a href="{{ form.url }}tryauth">{{ form.title }}</a>
19
  ><a href="{{ form.url }}tryauth?cancelurl={{ absolute_uri|iriencode }}">{{ form.title }}</a>
20 20
  {% if form.description %}<div class="description">{{ form.description|safe }}</div>{% endif %}
21 21
  </li>
22 22
{% endfor %}
tests/test_wcs.py
1092 1092
        context.pop('combo_display_even_empty_categories')
1093 1093

  
1094 1094

  
1095
@mock.patch('combo.apps.wcs.utils.requests.send', side_effect=mocked_requests_send)
1096
def test_forms_of_category_cancelurl(mock_send, app):
1097
    page = Page(title='xxx', slug='test_forms_of_category_cell_render', template_name='standard')
1098
    page.save()
1099
    cell = WcsFormsOfCategoryCell(page=page, placeholder='content', order=0)
1100
    cell.category_reference = 'default:test-9'
1101
    cell.ordering = 'alpha'
1102
    cell.save()
1103
    resp = app.get(page.get_online_url())
1104
    ajax_cell_url = PyQuery(resp.text).find('[data-ajax-cell-url]').attr('data-ajax-cell-url')
1105
    extra_ctx = PyQuery(resp.text).find('[data-ajax-cell-url]').attr('data-extra-context')
1106
    cell_resp = app.get(ajax_cell_url + '?ctx=' + extra_ctx)
1107
    assert (
1108
        PyQuery(cell_resp.text).find('a').attr('href')
1109
        == 'http://127.0.0.1:8999/a-second-form-title/tryauth?cancelurl=http://testserver/test_forms_of_category_cell_render/'
1110
    )
1111

  
1112

  
1095 1113
@mock.patch('combo.apps.wcs.utils.requests.send', side_effect=mocked_requests_send)
1096 1114
def test_forms_of_category_cell_validity(mock_send, context):
1097 1115
    page = Page.objects.create(
1098
-