-
Notifications
You must be signed in to change notification settings - Fork 14.6k
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
Make access request redirect to dashboard if user already has access #4469
Make access request redirect to dashboard if user already has access #4469
Conversation
bc33642
to
d1f004a
Compare
superset/views/core.py
Outdated
|
||
has_access = True | ||
for datasource in datasources: | ||
has_access &= (datasource and self.datasource_access(datasource)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find the all
and any
functions much more readable than the &=
, something like:
has_access = all((self.datasource_access(o) for o in datasources))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
8a21996
to
fc54600
Compare
superset/views/core.py
Outdated
( | ||
datasource and self.datasource_access(datasource) | ||
for datasource in datasources | ||
), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Watch out here, I'm pretty sure this dangling comma changes the structure from passing a tuple to all
to, instead, passing it a tuple of one element that contains a tuple.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a pretty common gotcha in python, v = 1,
makes v
a tuple
@mistercrunch Looks like it's a quirk with Python consistency. I initially didn't have trailing comma but the flake8 rules required me to add it and somehow python reads it correctly. Also, the check is done correctly. From my interpreter:
I removed the comma anyway. |
fc54600
to
fba8b93
Compare
PING |
Yeah I ran similar tests in an interpreter and still I'm confused as to how this works properly. I agree we cannot rely on this odd behavior as it may flap in the future or across python versions. LGTM |
With the access request feature, users who have access often revisit the access request page and are still shown the access request page.
This PR checks to make sure the user still doesn't have access before showing the access request page and redirects to the dashboard if they have access.
@john-bodley @mistercrunch