?_filter_column=col&_filter_op=op&_filter_value=value redirect

Part of implementing the filters UI (refs #86) - the following:

    /trees/Trees?_filter_column=SiteOrder&_filter_op=gt&_filter_value=2

Now redirects to this;

    /trees/Trees?SiteOrder__gt=2
This commit is contained in:
Simon Willison 2017-11-19 12:25:29 -08:00
commit 386fb11d42
No known key found for this signature in database
GPG key ID: FBB38AFE227189DB
3 changed files with 53 additions and 6 deletions

View file

@ -120,9 +120,17 @@ def validate_sql_select(sql):
def path_with_added_args(request, args):
current = request.raw_args.copy()
current.update(args)
return request.path + '?' + urllib.parse.urlencode(current)
current = {
key: value
for key, value in request.raw_args.items()
if key not in args
}
current.update({
key: value
for key, value in args.items()
if value is not None
})
return request.path + '?' + urllib.parse.urlencode(sorted(current.items()))
def path_with_ext(request, ext):