Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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: Course roles service #33734
feat: Course roles service #33734
Changes from 60 commits
8f7f612
a793577
3883210
7752009
54cec18
9c180e0
d8ffa7b
668510e
29f1f76
5051704
343656b
9d5e690
f596a53
7f937d9
2cffa51
ab2cce3
4cd51d0
7249516
1198f99
1fac6ec
7b4a7dc
5cb6194
c6eeb28
c11118e
d09690e
1385fb0
95d4ebe
b56fdb1
4545279
2aa8be4
828863d
19d4e96
bd89bbc
8e6b144
c67f544
bd3fb11
1f9d3af
bd157c5
73c6f58
f7cd140
9a25c60
b675a6e
da941de
85e3a4e
bbe7130
e445147
030adfe
ae37a84
e7ea5c4
d03ac33
22a05d7
ab2de2b
e688cba
e9702ad
0ed7b41
f44fe1f
ef74b7f
af387ac
dcdc955
9a270e2
37b8e5c
dbb3d30
c0e5f63
4edd1c5
90a9872
3cb6a01
97eab69
301ddca
aa289b5
46641af
3f6c734
44961e7
4da0366
d8b680f
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
Long term note: One architectural failure mode I'm worried about here is if people find it difficult to add new permissions and instead start using other permissions that imply a role.
For instance, say someone wants to add a permission for the Staff Debug information under Components in the LMS rendering. But adding a permission and doing the data migration sounds hard. Then they browse through this class and think to themselves, "Well, if they can
VIEW_ALL_CONTENT
ANDMANAGE_STUDENTS
, then they're course staff and they should be able to see the Staff Debug info..." and we get into the mode where people are re-deriving roles implicitly from permissions and extrapolating those onto other implied permissions.I'm not saying we're doomed to this. Just that it's a risk and that we'll need docs and outreach, presentations, etc. in order to make sure that developers working on this will have the right mindset. This gets more likely if there's any real friction to adding permissions–long approval process, unclear docs, any perception of operational risk in the event of a rollback, etc.
Come to think on it, this whole thing would make for a great Open edX Conference talk or a Meetup presentation.
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.
We agree this presents a risk and have been thinking through strategies to mitigate for this risk. We do not think this presents an immediate risk, but plan to add documentation around how and when to add a permission in OEP-66 and within the djangoapps/course_roles/docs folder.
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.
Nit: It seems odd to have a permission that tells you what you can't do. It looks like this is supposed to be exclusive with
VIEW_ALL_CONTENT
so that you only have one or the other, but I would have expected this permission to beVIEW_LIVE_PUBLISHED_CONTENT
and for staff to have both.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.
A role can have both permissions, but in that case
VIEW_ONLY_LIVE_PUBLISHED_CONTENT
will not actually add any access. All content includes all live published content so having both would be a redundancy, but it won't cause any issues in the code.This permission (
VIEW_ONLY_LIVE_PUBLISHED_CONTENT
) exists so that it can be given to users who should only see live published content and not published content before it is live or unpublished content.@cablaa77 Please let us know if you agree the permission name should be changed to
VIEW_LIVE_PUBLISHED_CONTENT
fromVIEW_ONLY_LIVE_PUBLISHED_CONTENT
.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 guess the general pattern I am leery of is that people will start to use a permission check as a proxy for the absence of other permissions, and that it will introduce unnecessary coupling when we want to change things later. But I don't have a concrete case off the top of my head, and I won't block approving this PR over this.
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.
The permission name is being changed to
VIEW_LIVE_PUBLISHED_CONTENT
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.
Why is managing Libraries a Course Role/Permission?
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.
This permission is for the v1 content libraries. It will not need to exist if v2 content libraries is live, migrations are completed, and v1 code is removed before this code goes live, but a permission was included in case v1 content libraries is still live when a new role built off these permissions is created. This permission will be removed once v1 content libraries is fully sunset.
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 see. So v1 libraries will definitely still be around when this rolls out (for the community, even if edx.org decides to do the upgrade before then).
I'd like to understand a little more what it means when someone has this permission, because I'm not clear on what it would mean to have permission to
MANAGE_LIBRARIES
for a specific course, when the library exists outside of that course.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.
Looking through the existing code, we found only one location (so far) where the code checks if a user has the
LibraryUser
role.This permission will be added as a permission check where the role is currently checked and used to create the
LibraryUser
role incourse_roles
, but at this time we haven't identified any additional locations where we would add a check for the new permission.course_roles
permissions checks are not dependent on the level on which the permission was granted, but just that the user has that permission in the context in question. This means if the user has theLibraryUser
role at the org-wide level, they have that permission for all courses within the org. It also means if we check if the user has the permission, we are checking for course, org, and instance wide assignment of the permission.course_roles
has a fk dependency so we cannot assign acourse_role
on the library itself. It is also possible that the migration order of roles fromstudent_courseaccessrole
tocourse_roles_role
can be altered so that theLibraryUser
role stays on thestudent_courseaccessrole
until after the point in time when the named release is using v2 content libraries and this permission (and role) are no longer relevant.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.
FWIW, I'd suggest leaving this behind in
student_courseaccessrole
, but I'm okay either way in the short term.