0002-dataviz-pass-request-in-context-during-page-variable.patch
combo/apps/dataviz/models.py | ||
---|---|---|
460 | 460 |
if not hasattr(self, '_request'): |
461 | 461 |
raise MissingRequest |
462 | 462 | |
463 |
return RequestContext(self._request, self._request.extra_context) |
|
463 |
ctx = RequestContext(self._request, self._request.extra_context) |
|
464 |
ctx['request'] = self._request |
|
465 |
return ctx |
|
464 | 466 | |
465 | 467 |
def parse_response(self, response, chart): |
466 | 468 |
# normalize axis to have a fake axis when there are no dimensions and |
combo/apps/dataviz/templates/combo/chartngcell.html | ||
---|---|---|
35 | 35 |
var chart_cell = $('#chart-{{cell.id}}').parent(); |
36 | 36 |
var new_width = Math.floor($(chart_cell).width()); |
37 | 37 |
var ratio = new_width / last_width; |
38 |
var qs = '?width=' + new_width |
|
38 |
var qs; |
|
39 |
if (window.location.search) { |
|
40 |
qs = window.location.search + '&'; |
|
41 |
} else { |
|
42 |
qs = '?'; |
|
43 |
} |
|
44 |
qs += 'width=' + new_width |
|
39 | 45 |
if(chart_filters_form) |
40 | 46 |
qs += '&' + chart_filters_form.serialize() |
41 | 47 |
if(extra_context) |
... | ... | |
46 | 52 |
} |
47 | 53 |
}).trigger('combo:resize-graphs'); |
48 | 54 |
$(window).on('combo:refresh-graphs', function() { |
49 |
var qs = '?width=' + last_width |
|
55 |
var qs; |
|
56 |
if (window.location.search) { |
|
57 |
qs = window.location.search + '&'; |
|
58 |
} else { |
|
59 |
qs = '?'; |
|
60 |
} |
|
61 |
qs += 'width=' + last_width |
|
50 | 62 |
if(chart_filters_form) |
51 | 63 |
qs += '&' + chart_filters_form.serialize() |
52 | 64 |
if(extra_context) |
tests/test_dataviz.py | ||
---|---|---|
1849 | 1849 |
slug='index', |
1850 | 1850 |
extra_variables={ |
1851 | 1851 |
'custom_date': '{{ "2021-02-03"|parse_date }}', |
1852 |
'from-request': '{{ request.GET.test }}', |
|
1852 | 1853 |
'not-a-date': 'not-a-date', |
1853 | 1854 |
'syntax-error': '{% for %}', |
1854 | 1855 |
}, |
... | ... | |
1962 | 1963 |
request = new_api_mock.call['requests'][-1] |
1963 | 1964 |
assert 'start' not in request.url |
1964 | 1965 | |
1966 |
cell.time_range_start_template = 'from-request' |
|
1967 |
cell.save() |
|
1968 |
app.get(location + '?test=2022-05-17') |
|
1969 |
request = new_api_mock.call['requests'][-1] |
|
1970 |
assert 'start=2022-05-17' in request.url |
|
1971 | ||
1965 | 1972 | |
1966 | 1973 |
@with_httmock(new_api_mock) |
1967 | 1974 |
def test_chartng_cell_new_api_filter_params_month(new_api_statistics, nocache, freezer): |
1968 |
- |