Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add option for pulling favourited dashboards by username #2661

Merged
merged 2 commits into from
Apr 25, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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