0002-backoffice-return-nothing-on-unknown-filter-59224.patch
tests/backoffice_pages/test_custom_view.py | ||
---|---|---|
133 | 133 |
assert 'Views must have at least one column.' in resp.text |
134 | 134 | |
135 | 135 | |
136 |
def test_backoffice_custom_view_unknown_filter(pub): |
|
137 |
create_superuser(pub) |
|
138 | ||
139 |
FormDef.wipe() |
|
140 |
pub.custom_view_class.wipe() |
|
141 |
formdef = FormDef() |
|
142 |
formdef.name = 'form title' |
|
143 |
formdef.fields = [] |
|
144 |
formdef.workflow_roles = {'_receiver': 1} |
|
145 |
formdef.store() |
|
146 | ||
147 |
formdef.data_class().wipe() |
|
148 |
for i in range(10): |
|
149 |
formdata = formdef.data_class()() |
|
150 |
formdata.jump_status('new') |
|
151 |
formdata.store() |
|
152 | ||
153 |
app = login(get_app(pub)) |
|
154 |
resp = app.get('/backoffice/management/form-title/') |
|
155 |
assert resp.text.count('<tr') == 10 + 1 |
|
156 | ||
157 |
custom_view = pub.custom_view_class() |
|
158 |
custom_view.title = 'custom test view' |
|
159 |
custom_view.formdef = formdef |
|
160 |
custom_view.visibility = 'any' |
|
161 |
custom_view.columns = {'list': [{'id': 'id'}]} |
|
162 |
custom_view.filters = {'filter-42': 'on', 'filter-42-value': 'foo', 'filter-foobar': 'baz'} |
|
163 |
custom_view.store() |
|
164 | ||
165 |
resp = app.get('/backoffice/management/form-title/custom-test-view/') |
|
166 |
assert resp.text.count('<tr') == 1 |
|
167 |
assert 'Invalid filters "42", "foobar"' in resp |
|
168 | ||
169 | ||
136 | 170 |
def test_backoffice_custom_view_user_filter(pub): |
137 | 171 |
superuser = create_superuser(pub) |
138 | 172 |
tests/backoffice_pages/test_filters.py | ||
---|---|---|
121 | 121 |
assert 'filter-4-value' in resp.forms['listing-settings'].fields |
122 | 122 | |
123 | 123 | |
124 |
def test_backoffice_unknown_filter(pub): |
|
125 |
create_superuser(pub) |
|
126 | ||
127 |
FormDef.wipe() |
|
128 |
formdef = FormDef() |
|
129 |
formdef.name = 'form-title' |
|
130 |
formdef.fields = [] |
|
131 |
formdef.workflow_roles = {'_receiver': 1} |
|
132 |
formdef.store() |
|
133 | ||
134 |
data_class = formdef.data_class() |
|
135 |
data_class.wipe() |
|
136 |
for i in range(10): |
|
137 |
formdata = data_class() |
|
138 |
formdata.just_created() |
|
139 |
formdata.jump_status('new') |
|
140 |
formdata.store() |
|
141 | ||
142 |
app = login(get_app(pub)) |
|
143 |
resp = app.get('/backoffice/management/form-title/') |
|
144 |
assert resp.text.count('<tr') == 11 |
|
145 |
resp = app.get('/backoffice/management/form-title/?filter-foobar=42') |
|
146 |
assert resp.text.count('<tr') == 1 |
|
147 |
assert 'Invalid filter "foobar"' in resp |
|
148 |
resp = app.get('/backoffice/management/form-title/?filter-42=on&filter-42-value=foobar') |
|
149 |
assert resp.text.count('<tr') == 1 |
|
150 |
assert 'Invalid filter "42"' in resp |
|
151 | ||
152 |
resp = app.get('/backoffice/management/form-title/?filter-foobar=42&filter-baz=35') |
|
153 |
assert resp.text.count('<tr') == 1 |
|
154 |
assert 'Invalid filters "baz", "foobar"' in resp |
|
155 |
resp = app.get('/backoffice/management/form-title/?filter-42=on&filter-42-value=foobar&filter-baz=35') |
|
156 |
assert resp.text.count('<tr') == 1 |
|
157 |
assert 'Invalid filters "42", "baz"' in resp |
|
158 | ||
159 | ||
124 | 160 |
def test_backoffice_bool_filter(pub): |
125 | 161 |
create_superuser(pub) |
126 | 162 |
create_environment(pub) |
wcs/backoffice/management.py | ||
---|---|---|
1834 | 1834 |
) |
1835 | 1835 |
% {'filters': '", "'.join(f for f in unknown_filters)} |
1836 | 1836 |
) |
1837 |
raise RequestError(error_message) |
|
1837 |
if self.view_type == 'json': |
|
1838 |
raise RequestError(error_message) |
|
1839 |
if self.view_type == 'table': |
|
1840 |
get_session().message = ('warning', error_message) |
|
1841 |
criterias.append(Equal('status', '_none')) |
|
1838 | 1842 | |
1839 | 1843 |
return criterias |
1840 | 1844 | |
... | ... | |
2133 | 2137 |
return job.file_content |
2134 | 2138 | |
2135 | 2139 |
def json(self): |
2140 |
self.view_type = 'json' |
|
2136 | 2141 |
anonymise = get_request().has_anonymised_data_api_restriction() |
2137 | 2142 |
self.check_access() |
2138 | 2143 |
get_response().set_content_type('application/json') |
2139 |
- |