-
Notifications
You must be signed in to change notification settings - Fork 4k
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 course advanced setting invite_only configurable site-wide #27252
Conversation
Thanks for the pull request, @asadiqbal08! I've created OSPR-5719 to keep track of it in JIRA, where we prioritize reviews. 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:
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. |
@asadiqbal08 Thank you for your contribution. Looks like this is ready for our review. |
@@ -928,7 +930,7 @@ def course_about(request, course_id): | |||
|
|||
# Used to provide context to message to student if enrollment not allowed | |||
can_enroll = bool(request.user.has_perm(ENROLL_IN_COURSE, course)) | |||
invitation_only = course.invitation_only | |||
invitation_only = is_course_default_invite_only_enabled() or course.invitation_only |
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.
Will course.invitation_only always be True or False, or can it be not set (None)?
It strikes me that with the logic here, if the toggle is set to True, it will never be possible to override it for one course. All courses will be invite only.
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.
@pdpinch It either be True/False
.
It strikes me that with the logic here, if the toggle is set to True, it will never be possible to override it for one course. All courses will be invite only.
hmmm but what I get yet, We are giving precedence to COURSE_DEFAULT_INVITE_ONLY
flag in the task.
I mean, If is_course_default_invite_only_enabled
is True
then all courses will be invite only. Is it not the requirement here ? mean, reference to earlier merge: PR
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.
As is, the PR meets the MIT ODL use case, but I feel like the setting name suggests a different behavior. COURSE_DEFAULT_INVITE_ONLY
sounds like it should only change the default setting, instead of overriding the setting for all courses.
We could either:
- Change the logic, or
- Change the setting to
COURSES_INVITE_ONLY
6b9c553
to
7d71607
Compare
I updated the PR description and subject to reflect the new setting name and expected behavior. This should be reflected in the commit message as well. |
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.
LGTM!
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.
Reviewed this from a naive perspective of the feature. Just a few comments for clarity, but the code looks good.
@@ -500,6 +501,39 @@ def test__has_access_course_can_enroll(self): | |||
) | |||
assert not access._has_access_course(user, 'enroll', course) | |||
|
|||
@override_settings(COURSES_INVITE_ONLY=False) | |||
def test__course_default_invite_only_flag_false(self): | |||
"""Tests that default value of COURSES_INVITE_ONLY as False.""" |
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.
As someone rather new to these features, the tests are somewhat unclear. Look at the above test - there's lots of comments around the assert statements & mock course creation to explain what's going on. Could you please add such comments for clarity? I wouldn't hate a more descriptive docstring, either.
Also a nit on the docstring format to do:
"""
Tests that default value of COURSES_INVITE_ONLY as False.
"""
course = self._mock_course(invitation=False) | ||
self.assertFalse(access._has_access_course(user, 'enroll', course)) | ||
|
||
def _mock_course(self, invitation): |
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.
Since this is specific to your tests, I wonder if it should have a more specific name such as _mock_course_with_invitation
or something better than that, ha
lms/djangoapps/courseware/toggles.py
Outdated
# .. toggle_implementation: SettingToggle | ||
# .. toggle_type: feature_flag | ||
# .. toggle_default: False | ||
# .. toggle_description: Set this to manage the default value for INVITE_ONLY across all courses in a given deployment |
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'm not sure I 100% follow this description, and I'm not sure why. Maybe Setting this sets the default value of INVITE_ONLY across all courses in a given deployment
Your PR has finished running tests. There were no failures. |
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.
Please squash & rebase then myself or @pdpinch can merge
edit: please also use Conventional Commits
@asadiqbal08 🎉 Your pull request was merged! Please take a moment to answer a two question survey so we can improve your experience in the future. |
@pdpinch please be sure to use Conventional Commits before merging in the future - thanks! |
Setting COURSES_INVITE_ONLY to True overrides the INVITE_ONLY setting across all courses in a given deployment. Co-authored-by: tasawernawaz <[email protected]> Co-authored-by: asadiqbal08 <[email protected]> (cherry picked from commit 80298ae)
Sorry @sarina I missed your comment https://github.com/edx/edx-platform/pull/27252#issuecomment-819477760 -- but I thought this was a conventional commit: edx/edx-platform@80298ae Did I overlook something? |
@pdpinch huh. I just looked at the list of commits on the PR and saw none of them were conventional: |
Fixes mitodl#135 and reference to previous PR# https://github.com/edx/edx-platform/pull/20596
Background:
We would like to make the
defaultvalue of the invitation_required attribute of the courseware object configurable via a feature flag, to be namedCOURSE_DEFAULT_INVITE_ONLYCOURSES_INVITE_ONLYAs it is currently, this is a manually updated flag in the course advanced settings and we would like to be able to manage the
defaultvalue across all courses in a given deployment. The default value of the added setting should remain the same as the current setting of False, but allow us to set it to True through the existing settings mechanism.We have merged this solution in our forked repository mitodl#126.