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

feat: Add student role with minimal access in Superset #307

Merged
merged 7 commits into from
Aug 25, 2023

Conversation

nandodev-net
Copy link
Contributor

@nandodev-net nandodev-net commented Aug 17, 2023

Description:

This pull request introduces a new role for students, designed to be similar to the instructor role but with read-only access. The aim is to ensure students can only access and view assets for which they have permissions.

Changes:

  • Defined a base student role with minimal permissions.
  • Automated role assignment for students upon login.

Testing:

  • Logged in as a student at Superset dashboard

Screenshot from 2023-08-24 13-41-54

Screenshot from 2023-08-24 13-42-20

Please review the changes and provide feedback.

@openedx-webhooks
Copy link

openedx-webhooks commented Aug 17, 2023

Thanks for the pull request, @nandodev-net! Please note that it may take us up to several weeks or months to complete a review and merge your PR.

Feel free to add as much of the following information to the ticket as you can:

  • supporting documentation
  • Open edX discussion forum threads
  • timeline information ("this must be merged by XX date", and why that is)
  • partner information ("this is a course on edx.org")
  • any other information that can help Product understand the context for the PR

All technical communication about the code itself will be done via the GitHub pull request interface. As a reminder, our process documentation is here.

Please let us know once your PR is ready for our review and all tests are green.

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Aug 17, 2023
@Ian2012
Copy link
Contributor

Ian2012 commented Aug 18, 2023

You are missing the part where the role should be assigned automatically at login.

if bool("{{SUPERSET_BLOCK_STUDENT_ACCESS}}") and not roles:
raise Exception(f"Student {username} tried to access Superset")

You can use something similar to this:

if roles:
    return roles
if not bool("{{SUPERSET_BLOCK_STUDENT_ACCESS}}"):
   return ["student", f"student - {language}"]
raise Exception(f"Student {username} tried to access Superset")

@Ian2012
Copy link
Contributor

Ian2012 commented Aug 18, 2023

Also, as you are replicating the permissions for the instructor role. Can you create a template that holds the shared permissions for both roles and inject it where it corresponds?

@Ian2012
Copy link
Contributor

Ian2012 commented Aug 21, 2023

cc @nandodev-net

@itsjeyd itsjeyd added the waiting on author PR author needs to resolve review requests, answer questions, fix tests, etc. label Aug 22, 2023
@nandodev-net nandodev-net force-pushed the FG/Superset_student_rol_definition branch from f282bb4 to 850199f Compare August 22, 2023 19:35
config.yml Outdated Show resolved Hide resolved
@Ian2012 Ian2012 marked this pull request as ready for review August 22, 2023 21:08
@Ian2012 Ian2012 force-pushed the FG/Superset_student_rol_definition branch from 92c8233 to bd79be8 Compare August 23, 2023 14:43
@@ -174,9 +174,13 @@ def _get_user_roles(self, username, language):
return ["instructor", f"instructor-{language}"]
else:
roles = self.extra_get_user_roles(username, decoded_access_token)
if bool("{{SUPERSET_BLOCK_STUDENT_ACCESS}}") and not roles:
if roles:
return roles
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm somewhat concerned about this logic. Having a student role returned here would override SUPERSET_BLOCK_STUDENT_ACCESS. Maybe not a big deal, but can we add a check for that and throw an exception if it happens?

@Ian2012 Ian2012 requested a review from bmtcril August 24, 2023 21:30
Copy link
Contributor

@bmtcril bmtcril left a comment

Choose a reason for hiding this comment

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

Thanks @nandodev-net , looks good to me!

@Ian2012 Ian2012 merged commit 708505b into openedx:main Aug 25, 2023
5 checks passed
@openedx-webhooks
Copy link

@nandodev-net 🎉 Your pull request was merged! Please take a moment to answer a two question survey so we can improve your experience in the future.

@itsjeyd itsjeyd removed the waiting on author PR author needs to resolve review requests, answer questions, fix tests, etc. label Sep 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
open-source-contribution PR author is not from Axim or 2U
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

5 participants