Handle anonymous and unenrolled users on the new course home page

LEARNER-1696
This commit is contained in:
Andy Armstrong
2017-07-03 13:16:22 -04:00
parent 65f876d728
commit a815003b3b
41 changed files with 581 additions and 316 deletions

View File

@@ -8,6 +8,7 @@ from django.utils.translation import ugettext as _
from course_tools import CourseTool
from courseware.courses import get_course_by_id
from student.models import CourseEnrollment
from views.course_reviews import CourseReviewsModuleFragmentView
from views.course_updates import CourseUpdatesFragmentView
@@ -35,11 +36,14 @@ class CourseUpdatesTool(CourseTool):
@classmethod
def is_enabled(cls, request, course_key):
"""
Returns True if this tool is enabled for the specified course key.
Returns True if the user should be shown course updates for this course.
"""
if not UNIFIED_COURSE_TAB_FLAG.is_enabled(course_key):
return False
if not CourseEnrollment.is_enrolled(request.user, course_key):
return False
course = get_course_by_id(course_key)
has_updates = CourseUpdatesFragmentView.has_updates(request, course)
return UNIFIED_COURSE_TAB_FLAG.is_enabled(course_key) and has_updates
return CourseUpdatesFragmentView.has_updates(request, course)
@classmethod
def url(cls, course_key):
@@ -72,8 +76,9 @@ class CourseReviewsTool(CourseTool):
"""
Returns True if this tool is enabled for the specified course key.
"""
reviews_configured = CourseReviewsModuleFragmentView.is_configured()
return SHOW_REVIEWS_TOOL_FLAG.is_enabled(course_key) and reviews_configured
if not SHOW_REVIEWS_TOOL_FLAG.is_enabled(course_key):
return False
return CourseReviewsModuleFragmentView.is_configured()
@classmethod
def url(cls, course_key):