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

Fixing overwrite and save slice permissions for a give role #298

Merged
merged 15 commits into from
Apr 18, 2016

Conversation

sid88in
Copy link
Contributor

@sid88in sid88in commented Apr 8, 2016

@mistercrunch - I have fixed and tested slice save and slice overwrite permissions. Now a role can have flexibility to overwrite or save a slice. It will help in use cases where admin doesn't want users to overwrite a slice to mess up the dashboard.

@sid88in
Copy link
Contributor Author

sid88in commented Apr 8, 2016

It fixes #143

@landscape-bot
Copy link

Code Health
Repository health decreased by 0.04% when pulling 91bac04 on sid88in:slice_permissions into 0afa5d2 on airbnb:master.

@landscape-bot
Copy link

Code Health
Code quality remained the same when pulling b828f4b on sid88in:slice_permissions into 0afa5d2 on airbnb:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.1%) to 71.946% when pulling b828f4b on sid88in:slice_permissions into 0afa5d2 on airbnb:master.

@@ -468,7 +468,7 @@ def explore(self, datasource_type, datasource_id):

action = request.args.get('action')
if action in ('save', 'overwrite'):
return self.save(request.args, slc)
return self.saveoroverwriteslice(request.args, slc)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

underscore_between_words_please

@sid88in
Copy link
Contributor Author

sid88in commented Apr 9, 2016

  1. Fixed function name.
  2. Yes current changes will create new permissions. To avoid that, I have made new change.

For admin self.appbuilder.sm.has_access('can_edit', 'Slices') and self.appbuilder.sm.has_access('can_add', 'Slices') permissions are False. The only permission available to admin on Slices is [has menu access]. I have changed the view name to SliceModelView instead of Slices and it works. Tested.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.1%) to 71.946% when pulling 5f4c5aa on sid88in:slice_permissions into 0afa5d2 on airbnb:master.

@mistercrunch
Copy link
Member

Nice, ideally we'd disable the buttons in the UI as well. All you have to do is pass the same has_access calls as can_add and can_edit to the template, and sometime like {{ "disabled" if can_add }} in the class of the button

@sid88in
Copy link
Contributor Author

sid88in commented Apr 9, 2016

Thats a good catch. I thought about the same but didn't find any implementation in the current code to disable UI features based on access controls. I have updated and tested the code for disabling the button (basically calling appbuilder functions in the template). I don't see a need for {{ "disabled" if can_add }}. We can simply add it in the if condition to show the button or not. And now the backend handles the same as well. Let me know if you need further modifications in the way its implemented in this PR. I will then create another PR to do the same for some other important features like - save dashboard, download csv.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.04%) to 72.082% when pulling c1c31c3 on sid88in:slice_permissions into 0afa5d2 on airbnb:master.

@sid88in
Copy link
Contributor Author

sid88in commented Apr 9, 2016

Fyi - I tried replacing appbuilder.sm.has_access('can_edit', 'SliceModelView') with can_edit and it returned false. After reading template documentation I noticed one correct way to implement this is by calling objects passed in the render_template function. I don't see any current definition of can_edit and can_add in the current template code.

@landscape-bot
Copy link

Code Health
Repository health decreased by 0.07% when pulling c1c31c3 on sid88in:slice_permissions into 0afa5d2 on airbnb:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.4%) to 72.404% when pulling f962522 on sid88in:slice_permissions into 0afa5d2 on airbnb:master.

@mistercrunch
Copy link
Member

I meant you'd pass can_add=self.appbuilder.sm.has_access('can_add', 'Slices') to the template (same for can_edit), and use them to disable the buttons. I prefer disabling the buttons to hiding them, making it clear that the option exists and has not been granted.

@landscape-bot
Copy link

Code Health
Code quality remained the same when pulling f962522 on sid88in:slice_permissions into 0afa5d2 on airbnb:master.

1 similar comment
@landscape-bot
Copy link

Code Health
Code quality remained the same when pulling f962522 on sid88in:slice_permissions into 0afa5d2 on airbnb:master.

@sid88in
Copy link
Contributor Author

sid88in commented Apr 11, 2016

in the latest changes, I did the same. Im passing these parameters in the template to disable the buttons. So I think we are on the same page. Having said that I can remove these conditions from views.py (which seem redundant). What do you say?

@sid88in
Copy link
Contributor Author

sid88in commented Apr 11, 2016

or may be you meant passing the values of can_edit and can_add in the template from explore function in the views.py. I think thats the same as replacing can_edit and can_add by self.appbuilder.sm.has_access('can_add', 'SliceModelView) in the template itself. Whatever you prefer :)

@sid88in
Copy link
Contributor Author

sid88in commented Apr 11, 2016

I think you overlooked my first comment ;)
Pasting from above:

Thats a good catch. I thought about the same but didn't find any implementation in the current code to disable UI features based on access controls. I have updated and tested the code for disabling the button (basically calling appbuilder functions in the template). I don't see a need for {{ "disabled" if can_add }}. We can simply add it in the if condition to show the button or not. And now the backend handles the same as well. Let me know if you need further modifications in the way its implemented in this PR. I will then create another PR to do the same for some other important features like - save dashboard, download csv.

@sid88in
Copy link
Contributor Author

sid88in commented Apr 11, 2016

screen shot 2016-04-11 at 7 53 13 am

@mistercrunch
Copy link
Member

From my previous comment: " I prefer disabling the buttons to hiding them"

@sid88in
Copy link
Contributor Author

sid88in commented Apr 12, 2016

My bad. I didn't know the difference :/ I am testing the disabling feature on the UI - http://www.w3schools.com/bootstrap/tryit.asp?filename=trybs_button_active&stacked=h

@sid88in sid88in closed this Apr 12, 2016
@landscape-bot
Copy link

Code Health
Repository health increased by 0.04% when pulling 23303dd on sid88in:slice_permissions into badcd8b on airbnb:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.07%) to 72.391% when pulling 23303dd on sid88in:slice_permissions into badcd8b on airbnb:master.

@mistercrunch
Copy link
Member

Awesome! Mergin'

@mistercrunch mistercrunch merged commit afcdcf0 into apache:master Apr 18, 2016
tothandor pushed a commit to tothandor/incubator-superset that referenced this pull request Mar 27, 2018
This commit will only work if pull request apache#298 at cloudera/impyla is accepted,
but it may not do no harm if not.
It has also touched Hive impersonation, though it should not affect it.
graceguo-supercat pushed a commit to graceguo-supercat/superset that referenced this pull request Oct 4, 2021
* build: fix demo build

* fix: version

* build: add yarn.lock

* fix: clean up webpack config
zhaoyongjie pushed a commit to zhaoyongjie/incubator-superset that referenced this pull request Nov 17, 2021
* build: fix demo build

* fix: version

* build: add yarn.lock

* fix: clean up webpack config
zhaoyongjie pushed a commit to zhaoyongjie/incubator-superset that referenced this pull request Nov 24, 2021
* build: fix demo build

* fix: version

* build: add yarn.lock

* fix: clean up webpack config
zhaoyongjie pushed a commit to zhaoyongjie/incubator-superset that referenced this pull request Nov 25, 2021
* build: fix demo build

* fix: version

* build: add yarn.lock

* fix: clean up webpack config
zhaoyongjie pushed a commit to zhaoyongjie/incubator-superset that referenced this pull request Nov 26, 2021
* build: fix demo build

* fix: version

* build: add yarn.lock

* fix: clean up webpack config
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 0.8.9 labels Feb 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 0.8.9
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants