Skip to content

Commit

Permalink
GN-561 Error when viewing a course Anonymous when course dates tab
Browse files Browse the repository at this point in the history
  • Loading branch information
igobranco authored and MaferMazu committed Apr 22, 2022
1 parent ff184fe commit 83c23c2
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
9 changes: 9 additions & 0 deletions lms/djangoapps/courseware/courses.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions lms/djangoapps/courseware/tabs.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,11 @@ def link_func(course, reverse_func):
tab_dict['link_func'] = link_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):
"""
Expand Down
11 changes: 8 additions & 3 deletions openedx/features/course_experience/views/course_home.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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']:
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 83c23c2

Please sign in to comment.