Skip to content

Commit

Permalink
add option for pulling favourited dashboards by username (#2661)
Browse files Browse the repository at this point in the history
* add option for pulling favourited dashboards by username

add tests

* fix too many lines pep8 error
  • Loading branch information
robert-digit authored and mistercrunch committed Apr 25, 2017
1 parent e9ed416 commit 1df37e6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
8 changes: 8 additions & 0 deletions superset/views/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1399,6 +1399,14 @@ def csrf_token(self):
mimetype='text/json',
)

@api
@has_access_api
@expose("/fave_dashboards_by_username/<username>/", methods=['GET'])
def fave_dashboards_by_username(self, username):
"""This lets us use a user's username to pull favourite dashboards"""
user = sm.find_user(username=username)
return self.fave_dashboards(user.get_id())

@api
@has_access_api
@expose("/fave_dashboards/<user_id>/", methods=['GET'])
Expand Down
6 changes: 4 additions & 2 deletions tests/core_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -609,8 +609,8 @@ def test_fetch_datasource_metadata(self):
for k in keys:
self.assertIn(k, resp.keys())

def test_user_profile(self):
self.login(username='admin')
def test_user_profile(self, username='admin'):
self.login(username=username)
slc = self.get_slice("Girls", db.session)

# Setting some faves
Expand Down Expand Up @@ -641,6 +641,8 @@ def test_user_profile(self):
self.assertNotIn('message', data)
data = self.get_json_resp('/superset/fave_dashboards/{}/'.format(userid))
self.assertNotIn('message', data)
data = self.get_json_resp('/superset/fave_dashboards_by_username/{}/'.format(username))
self.assertNotIn('message', data)


if __name__ == '__main__':
Expand Down

0 comments on commit 1df37e6

Please sign in to comment.