From 07afe7e2c559134b4b9ca5a5aa369d056fa2cfac Mon Sep 17 00:00:00 2001 From: Ivo Branco Date: Wed, 16 Jun 2021 16:19:54 +0000 Subject: [PATCH] GN-561 Error when viewing a course Anonymous when course dates tab --- lms/djangoapps/courseware/courses.py | 9 +++++++++ lms/djangoapps/courseware/tabs.py | 6 ++++++ .../features/course_experience/views/course_home.py | 11 ++++++++--- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/lms/djangoapps/courseware/courses.py b/lms/djangoapps/courseware/courses.py index 9f9bfefbdc3..7174c2e8ee3 100644 --- a/lms/djangoapps/courseware/courses.py +++ b/lms/djangoapps/courseware/courses.py @@ -477,7 +477,16 @@ def get_course_date_blocks(course, user, request=None, include_access=False, VerificationDeadlineDate, VerifiedUpgradeDeadlineDate, ] + if not course.self_paced and certs_api.get_active_web_certificate(course): + default_block_classes.insert(0, CertificateAvailableDate) + blocks.extend([cls(course, user) for cls in default_block_classes]) + if RELATIVE_DATES_FLAG.is_enabled(course.id) and user and user.is_authenticated: + blocks.append(CourseExpiredDate(course, user)) + blocks.extend(get_course_assignment_date_blocks( + course, user, request, num_return=num_assignments, + include_access=include_access, include_past_dates=include_past_dates, + )) blocks = filter(lambda b: b.is_allowed and b.date and (include_past_dates or b.is_enabled), blocks) return sorted(blocks, key=date_block_key_fn) diff --git a/lms/djangoapps/courseware/tabs.py b/lms/djangoapps/courseware/tabs.py index 0a8cc2da5c2..1fc7149c732 100644 --- a/lms/djangoapps/courseware/tabs.py +++ b/lms/djangoapps/courseware/tabs.py @@ -343,6 +343,12 @@ def link_func(course, reverse_func): super().__init__(tab_dict) + @classmethod + def is_enabled(cls, course, user=None): + """Returns true if this tab is enabled.""" + return RELATIVE_DATES_FLAG.is_enabled(course.id) and super(DatesTab, cls).is_enabled(course, user=user) + + def get_course_tab_list(user, course): """ Retrieves the course tab list from xmodule.tabs and manipulates the set as necessary diff --git a/openedx/features/course_experience/views/course_home.py b/openedx/features/course_experience/views/course_home.py index a4d031f3320..c01f57e1f55 100644 --- a/openedx/features/course_experience/views/course_home.py +++ b/openedx/features/course_experience/views/course_home.py @@ -120,9 +120,6 @@ def render_to_fragment(self, request, course_id=None, **kwargs): # lint-amnesty course_key = CourseKey.from_string(course_id) course = get_course_with_access(request.user, 'load', course_key) - # Render the course dates as a fragment - dates_fragment = CourseDatesFragmentView().render_to_fragment(request, course_id=course_id, **kwargs) - # Render the full content to enrolled users, as well as to course and global staff. # Unenrolled users who are not course or global staff are given only a subset. enrollment = CourseEnrollment.get_enrollment(request.user, course_key) @@ -145,6 +142,7 @@ def render_to_fragment(self, request, course_id=None, **kwargs): # lint-amnesty has_visited_course = None resume_course_url = None handouts_html = None + dates_fragment = None course_overview = CourseOverview.get_from_id(course.id) if user_access['is_enrolled'] or user_access['is_staff']: @@ -172,6 +170,13 @@ def render_to_fragment(self, request, course_id=None, **kwargs): # lint-amnesty request.user, course_overview ) + + next_up_banner_fragment = NextUpBannerFragmentView().render_to_fragment( + assignment_title=resume_course_title, resume_course_url=resume_course_url, assignment_duration='10 min' + ) + + dates_fragment = CourseDatesFragmentView().render_to_fragment(request, course_id=course_id, **kwargs) + elif allow_public_outline or allow_public: outline_fragment = CourseOutlineFragmentView().render_to_fragment( request, course_id=course_id, user_is_enrolled=False, **kwargs