0001-wcs-add-cancelurl-query-parameter-to-form-links-6011.patch
combo/apps/wcs/models.py | ||
---|---|---|
18 | 18 |
import collections |
19 | 19 |
import copy |
20 | 20 |
import logging |
21 |
import urllib.parse |
|
21 | 22 | |
22 | 23 |
from django.conf import settings |
23 | 24 |
from django.contrib.postgres.fields import JSONField |
... | ... | |
124 | 125 |
populate_cache() |
125 | 126 | |
126 | 127 |
def get_cell_extra_context(self, context): |
128 |
request = context.get('request') |
|
127 | 129 |
context = super().get_cell_extra_context(context) |
128 | 130 |
context['slug'] = self.formdef_reference.split(':')[-1] |
129 | 131 |
context['title'] = self.cached_title |
130 | 132 |
context['url'] = self.cached_url + 'tryauth' |
133 |
if request: |
|
134 |
context['url'] += '?cancelurl=%s' % urllib.parse.quote(request.build_absolute_uri()) |
|
131 | 135 |
if self.cached_json: |
132 | 136 |
context['description'] = mark_safe(self.cached_json.get('description', '')) |
133 | 137 |
context['css_classes'] = get_formdef_css_classes(self.cached_json) |
tests/test_wcs.py | ||
---|---|---|
2707 | 2707 |
page=page, |
2708 | 2708 |
placeholder=cell.link_placeholder, |
2709 | 2709 |
cached_title='A title', |
2710 |
cached_url='http://example.com', |
|
2710 |
cached_url='http://example.com/',
|
|
2711 | 2711 |
cached_json={'keywords': ['bar']}, |
2712 | 2712 |
order=0, |
2713 | 2713 |
) |
2714 | 2714 | |
2715 | 2715 |
resp = app.get('/test_list_of_links_with_form_render/') |
2716 |
assert 'A title' in resp |
|
2717 |
assert 'keyword-bar' in resp |
|
2716 |
assert PyQuery(resp.text).find('.links-list a').text() == 'A title' |
|
2717 |
assert PyQuery(resp.text).find('.links-list li').attr('class') == 'keyword-bar' |
|
2718 |
assert ( |
|
2719 |
PyQuery(resp.text).find('.links-list a').attr('href') |
|
2720 |
== 'http://example.com/tryauth?cancelurl=http%3A//testserver/test_list_of_links_with_form_render/' |
|
2721 |
) |
|
2718 | 2722 | |
2719 | 2723 | |
2720 | 2724 |
def test_view_page_with_wcs_cells_num_queries(app, admin_user): |
2721 |
- |