Skip to content
Snippets Groups Projects
Unverified Commit 9e2eab50 authored by Dillon Dumesnil's avatar Dillon Dumesnil
Browse files

AA-454 and AA-470: Update language and bug fix for highlights

Since Course Highlights aren't necessarily weekly (self-paced courses),
update the language to be more generic. And then includes a bug fix to
not send highlights to learners after they have unenrolled from a course.
parent ef5832bc
No related branches found
No related tags found
No related merge requests found
...@@ -273,7 +273,7 @@ define(['jquery', 'backbone', 'underscore', 'gettext', 'js/views/baseview', ...@@ -273,7 +273,7 @@ define(['jquery', 'backbone', 'underscore', 'gettext', 'js/views/baseview',
}, },
getTitle: function() { getTitle: function() {
return gettext('Enable Weekly Highlight Emails'); return gettext('Enable Course Highlight Emails');
}, },
getIntroductionMessage: function() { getIntroductionMessage: function() {
......
<div class="course-highlights-setting"> <div class="course-highlights-setting">
<h2 id="highlights-enabled-label" class="status-highlights-enabled-label"> <h2 id="highlights-enabled-label" class="status-highlights-enabled-label">
<%- gettext('Weekly Highlight Emails') %> <%- gettext('Course Highlight Emails') %>
</h2> </h2>
<br> <br>
<% if (highlights_enabled_for_messaging) { %> <% if (highlights_enabled_for_messaging) { %>
......
<p> <p>
<%- gettext( <%- gettext(
'When you enable weekly highlight emails, learners ' + 'When you enable course highlight emails, learners ' +
'automatically receive weekly email messages for each section that ' + 'automatically receive email messages for each section that ' +
'has highlights. You cannot disable highlights after you start ' + 'has highlights. You cannot disable highlights after you start ' +
'sending them.' 'sending them.'
) %> ) %>
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
<% // xss-lint: disable=underscore-not-escaped %> <% // xss-lint: disable=underscore-not-escaped %>
<%= edx.HtmlUtils.interpolateHtml( <%= edx.HtmlUtils.interpolateHtml(
gettext( gettext(
'Are you sure you want to enable weekly highlight emails? ' 'Are you sure you want to enable course highlight emails? '
+ '{linkStart}Learn more.{linkEnd}' + '{linkStart}Learn more.{linkEnd}'
), ),
{ {
......
""" """
Contains methods for accessing weekly course highlights. Weekly highlights is a Contains methods for accessing course highlights. Course highlights is a
schedule experience built on the Schedules app. schedule experience built on the Schedules app.
""" """
......
...@@ -471,6 +471,7 @@ class CourseNextSectionUpdate(PrefixedDebugLoggerMixin, RecipientResolver): ...@@ -471,6 +471,7 @@ class CourseNextSectionUpdate(PrefixedDebugLoggerMixin, RecipientResolver):
schedules = Schedule.objects.select_related('enrollment').filter( schedules = Schedule.objects.select_related('enrollment').filter(
self.experience_filter, self.experience_filter,
active=True, active=True,
enrollment__is_active=True,
enrollment__course_id=self.course_id, enrollment__course_id=self.course_id,
enrollment__user__is_active=True, enrollment__user__is_active=True,
start_date__gte=target_date - course_duration, start_date__gte=target_date - course_duration,
......
...@@ -23,7 +23,7 @@ from openedx.core.djangoapps.schedules.models import ScheduleExperience ...@@ -23,7 +23,7 @@ from openedx.core.djangoapps.schedules.models import ScheduleExperience
from openedx.core.djangoapps.schedules.utils import reset_self_paced_schedule from openedx.core.djangoapps.schedules.utils import reset_self_paced_schedule
from openedx.core.djangoapps.theming.helpers import get_current_site from openedx.core.djangoapps.theming.helpers import get_current_site
from common.djangoapps.student.models import CourseEnrollment from common.djangoapps.student.models import CourseEnrollment
from common.djangoapps.student.signals import ENROLLMENT_TRACK_UPDATED from common.djangoapps.student.signals import ENROLL_STATUS_CHANGE, ENROLLMENT_TRACK_UPDATED
from common.djangoapps.track import segment from common.djangoapps.track import segment
from .config import CREATE_SCHEDULE_WAFFLE_FLAG from .config import CREATE_SCHEDULE_WAFFLE_FLAG
...@@ -61,6 +61,24 @@ def create_schedule(sender, **kwargs): # pylint: disable=unused-argument ...@@ -61,6 +61,24 @@ def create_schedule(sender, **kwargs): # pylint: disable=unused-argument
)) ))
@receiver(ENROLL_STATUS_CHANGE)
def update_schedule(sender, event, user, course_id, **kwargs): # pylint: disable=unused-argument
"""
When a CourseEnrollment's status is updated, update the Schedule's active status if configured.
"""
try:
schedule = Schedule.objects.get(enrollment__user=user, enrollment__course=course_id)
except Schedule.DoesNotExist:
# Exit since it could just be an indication of Schedules are not enabled.
return
if event == 'enroll':
schedule.active = True
elif event == 'unenroll':
schedule.active = False
schedule.save()
@receiver(COURSE_START_DATE_CHANGED) @receiver(COURSE_START_DATE_CHANGED)
def update_schedules_on_course_start_changed(sender, updated_course_overview, previous_start_date, **kwargs): # pylint: disable=unused-argument def update_schedules_on_course_start_changed(sender, updated_course_overview, previous_start_date, **kwargs): # pylint: disable=unused-argument
""" """
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment