mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Even more complicated redirect scheme
This:
?_filter_column_1=name&_filter_op_1=contains&_filter_value_1=hello
&_filter_column_2=age&_filter_op_2=gte&_filter_value_2=12
Now redirects to this:
?name__contains=hello&age__gte=12
This is needed for the filter editing interface, refs #86
This commit is contained in:
parent
c8e7c85fd3
commit
53534b6e9d
3 changed files with 78 additions and 21 deletions
|
|
@ -278,6 +278,32 @@ def test_add_filter_redirects(app_client):
|
|||
assert response.headers['Location'].endswith('?content__isnull=5')
|
||||
|
||||
|
||||
def test_existing_filter_redirects(app_client):
|
||||
filter_args = urllib.parse.urlencode({
|
||||
'_filter_column_1': 'name',
|
||||
'_filter_op_1': 'contains',
|
||||
'_filter_value_1': 'hello',
|
||||
'_filter_column_2': 'age',
|
||||
'_filter_op_2': 'gte',
|
||||
'_filter_value_2': '22',
|
||||
'_filter_column_3': 'age',
|
||||
'_filter_op_3': 'lt',
|
||||
'_filter_value_3': '30',
|
||||
'_filter_column_4': 'name',
|
||||
'_filter_op_4': 'contains',
|
||||
'_filter_value_4': 'world',
|
||||
})
|
||||
path_base = app_client.get(
|
||||
'/test_tables/simple_primary_key', allow_redirects=False, gather_request=False
|
||||
).headers['Location']
|
||||
path = path_base + '?' + filter_args
|
||||
response = app_client.get(path, allow_redirects=False, gather_request=False)
|
||||
assert response.status == 302
|
||||
assert response.headers['Location'].endswith(
|
||||
'?age__gte=22&age__lt=30&name__contains=hello&name__contains=world'
|
||||
)
|
||||
|
||||
|
||||
TABLES = '''
|
||||
CREATE TABLE simple_primary_key (
|
||||
pk varchar(30) primary key,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue