forked from openedx/edx-platform
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #492 from ucsd-ets/alisalman/ucsd-courses
Restrict courses to ucsd students only
- Loading branch information
Showing
11 changed files
with
66 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1028,17 +1028,15 @@ class CourseFields(object): | |
), | ||
scope=Scope.settings | ||
) | ||
restricted_organizations = List( | ||
display_name=_("Restrict Course"), | ||
only_allow_ucsd_students = Boolean( | ||
display_name=_("Restrict course to UCSD students"), | ||
help=_( | ||
"Restrict course only to certain organizations, " | ||
"the default values is ['*'], it means all organization can access this course. " | ||
"To only allow ucsd emails, replace list with [\"ucsd.\"]. This allow all domains of ucsd i.e [email protected], [email protected]." | ||
"To further restric top level domains you can specify [domain].[top-level-domaain] i.e [\"ucsd.com\", \"ucsd.ca\", \"gmail.com\"]. " | ||
"Similary, you can add as many domains in the list to allow specific organization students to access this course" | ||
"Restrict course only to the ucsd students. " | ||
"If the value is true, It only allow students logedin with ucsd emails. " | ||
"Note that, the studnet's emails should contain @ucsd in their domain name. " | ||
), | ||
scope=Scope.settings, | ||
default=['*'], | ||
default=False, | ||
) | ||
|
||
class CourseModule(CourseFields, SequenceModule): # pylint: disable=abstract-method | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
""" | ||
Simple utility functions for computing access. | ||
""" | ||
from lms.djangoapps.courseware.access_response import AccessResponse | ||
from openedx.features.ucsd_features.utils import check_ucsd_email | ||
|
||
ACCESS_GRANTED = AccessResponse(True) | ||
ACCESS_DENIED = AccessResponse(False) | ||
|
||
def check_organization_access(user, course): | ||
""" | ||
Checks if the urers belogs to ucsd organization | ||
""" | ||
if course.only_allow_ucsd_students: | ||
if check_ucsd_email(user): | ||
return ACCESS_GRANTED | ||
return ACCESS_DENIED | ||
return ACCESS_GRANTED |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters