-
Notifications
You must be signed in to change notification settings - Fork 0
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 library roles support for roles API #124
Conversation
d37d261
to
1eb00da
Compare
f154c32
to
1c62ff5
Compare
1c62ff5
to
44aed5d
Compare
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.
small changes and it's good to go, thank you @tehreem-sadat !
result['courses'].update({ | ||
str(lib_key): lib_key.org | ||
for lib_key in modulestore().get_library_keys() | ||
if str(lib_key) in course_ids | ||
}) |
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 thought this was bad, then realized it's great! thank you!
for course_id in course_ids: | ||
if not re.match(cs.LIBRARY_ID_REGX, course_id): | ||
return False | ||
return True |
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.
for course_id in course_ids: | |
if not re.match(cs.LIBRARY_ID_REGX, course_id): | |
return False | |
return True | |
return all(re.match(cs.LIBRARY_ID_REGX, course_id) for course_id in course_ids) |
check_broken_rule( | ||
role == cs.COURSE_ACCESS_ROLES_LIBRARY_USER and course_id and not are_all_library_ids([course_id]), | ||
FXExceptionCodes.ROLE_INVALID_ENTRY, | ||
f'role {role} is only valid with library_id', | ||
) |
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.
validation order is a bit important in this function. Please move this after ....f'role {role} must have at least an org, it can also have a course_id!',
|
||
def get_library_keys(self): | ||
"""mock modulestore library keys method""" | ||
return [CourseKey.from_string(id) for id in self.ids] |
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.
Mocking is our enemy in tests. Please keep close to the real result as much as possible
return [CourseKey.from_string(id) for id in self.ids] | |
return [LibraryLocator.from_string(id) for id in self.ids] |
from opaque_keys.edx.locator import LibraryLocator
Add library roles and library_ids support for course access role APIs
Following are roles details
Related Issue: #107