Skip to content

Commit

Permalink
Fix keyword sub to work with new course updates
Browse files Browse the repository at this point in the history
  • Loading branch information
kluo authored and stvstnfrd committed Sep 19, 2018
1 parent a423c53 commit a156a8a
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion openedx/features/course_experience/views/course_updates.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from lms.djangoapps.courseware.views.views import CourseTabView
from openedx.core.djangoapps.plugin_api.views import EdxFragmentView
from openedx.features.course_experience import default_course_url_name
from util.date_utils import get_default_time_display


class CourseUpdatesView(CourseTabView):
Expand Down Expand Up @@ -85,8 +86,18 @@ def get_ordered_updates(self, request, course):
key=lambda item: (self.safe_parse_date(item['date']), item['id']),
reverse=True
)
keyword_context = {
'username': request.user.username,
'user_id': request.user.id,
'name': request.user.profile.name,
'course_title': course.display_name,
'course_id': course.id,
'course_start_date': get_default_time_display(course.start),
'course_end_date': get_default_time_display(course.end),
}
for update in ordered_updates:
update['content'] = info_block.system.replace_urls(update['content'])
update['content'] = info_block.system.substitute_keywords_with_data(update['content'], keyword_context)
return ordered_updates

@classmethod
Expand All @@ -102,7 +113,18 @@ def get_plain_html_updates(self, request, course):
"""
info_module = get_course_info_section_module(request, request.user, course, 'updates')
info_block = getattr(info_module, '_xmodule', info_module)
return info_block.system.replace_urls(info_module.data) if info_module else ''
update_content = info_block.system.replace_urls(info_module.data) if info_module else ''
keyword_context = {
'username': request.user.username,
'user_id': request.user.id,
'name': request.user.profile.name,
'course_title': course.display_name,
'course_id': course.id,
'course_start_date': get_default_time_display(course.start),
'course_end_date': get_default_time_display(course.end),
}
update_content = info_block.system.substitute_keywords_with_data(update_content, keyword_context)
return update_content

@staticmethod
def safe_parse_date(date):
Expand Down

0 comments on commit a156a8a

Please sign in to comment.