Skip to content

Commit

Permalink
wrapping all request params into url_params
Browse files Browse the repository at this point in the history
  • Loading branch information
Grace Guo committed Mar 8, 2018
1 parent 0f350ad commit 17197c1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
3 changes: 2 additions & 1 deletion superset/jinja_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ def url_param(param, default=None):
# Supporting POST as well as get
if request.form.get('form_data'):
form_data = json.loads(request.form.get('form_data'))
return form_data.get(param, default)
url_params = form_data['url_params'] or {}
return url_params.get(param, default)
return default


Expand Down
6 changes: 4 additions & 2 deletions superset/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -836,10 +836,12 @@ def get_filter_key(f):


def merge_request_params(form_data, params):
url_params = {}
for key, value in params.items():
if key == 'form_data':
if key in ('form_data', 'r'):
continue
form_data[key] = value
url_params[key] = value
form_data['url_params'] = url_params


def get_update_perms_flag():
Expand Down
3 changes: 2 additions & 1 deletion tests/utils_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,8 @@ def test_merge_request_params(self):
'dashboard_ids': '(1,2,3,4,5)',
}
merge_request_params(form_data, url_params)
self.assertIn('dashboard_ids', form_data.keys())
self.assertIn('url_params', form_data.keys())
self.assertIn('dashboard_ids', form_data['url_params'])
self.assertNotIn('form_data', form_data.keys())

def test_datetime_f(self):
Expand Down

0 comments on commit 17197c1

Please sign in to comment.