ECOM-1421 implementing the functionality

This commit is contained in:
Awais
2015-04-15 18:21:39 +05:00
parent fd99d55218
commit 2cd265292f
5 changed files with 52 additions and 9 deletions

View File

@@ -18,7 +18,8 @@ log = logging.getLogger(__name__)
def redirect_if_blocked(course_key, access_point='enrollment', **kwargs):
"""Redirect if the user does not have access to the course.
"""Redirect if the user does not have access to the course. In case of blocked if access_point
is not enrollment and course has enabled is_disabled_access_check then user can view that course.
Arguments:
course_key (CourseKey): Location of the course the user is trying to access.
@@ -30,7 +31,11 @@ def redirect_if_blocked(course_key, access_point='enrollment', **kwargs):
if settings.FEATURES.get('EMBARGO'):
is_blocked = not check_course_access(course_key, **kwargs)
if is_blocked:
return message_url_path(course_key, access_point)
if access_point == "courseware":
if not RestrictedCourse.is_disabled_access_check(course_key):
return message_url_path(course_key, access_point)
else:
return message_url_path(course_key, access_point)
def check_course_access(course_key, user=None, ip_address=None, url=None):