Add new course dates fragment.
Also add it to the course home page.
This commit is contained in:
committed by
Andy Armstrong
parent
97c084514f
commit
e12a704cea
27
openedx/features/course_experience/views/course_dates.py
Normal file
27
openedx/features/course_experience/views/course_dates.py
Normal file
@@ -0,0 +1,27 @@
|
||||
"""
|
||||
Fragment for rendering the course dates sidebar.
|
||||
"""
|
||||
from django.template.loader import render_to_string
|
||||
from opaque_keys.edx.keys import CourseKey
|
||||
from web_fragments.fragment import Fragment
|
||||
from openedx.core.djangoapps.plugin_api.views import EdxFragmentView
|
||||
from courseware.courses import get_course_with_access, get_course_date_blocks
|
||||
|
||||
|
||||
class CourseDatesFragmentView(EdxFragmentView):
|
||||
"""
|
||||
A fragment to important dates within a course.
|
||||
"""
|
||||
def render_to_fragment(self, request, course_id=None, **kwargs):
|
||||
"""
|
||||
Render the course dates fragment.
|
||||
"""
|
||||
course_key = CourseKey.from_string(course_id)
|
||||
course = get_course_with_access(request.user, 'load', course_key, check_if_enrolled=False)
|
||||
course_date_blocks = get_course_date_blocks(course, request.user)
|
||||
|
||||
context = {
|
||||
'course_date_blocks': course_date_blocks
|
||||
}
|
||||
html = render_to_string('course_experience/course-dates-fragment.html', context)
|
||||
return Fragment(html)
|
||||
Reference in New Issue
Block a user