diff --git a/lms/djangoapps/courseware/date_summary.py b/lms/djangoapps/courseware/date_summary.py index 4cb2af0ab1..98478899fb 100644 --- a/lms/djangoapps/courseware/date_summary.py +++ b/lms/djangoapps/courseware/date_summary.py @@ -405,11 +405,7 @@ def verified_upgrade_deadline_link(user, course=None, course_id=None): ecommerce_service = EcommerceService() if ecommerce_service.is_enabled(user): if course is not None and isinstance(course, CourseOverview): - course_mode = [ - mode - for mode in course.modes - if mode.slug == CourseMode.VERIFIED - ] + course_mode = course.modes.get(mode_slug=CourseMode.VERIFIED) else: course_mode = CourseMode.objects.get( course_id=course_id, mode_slug=CourseMode.VERIFIED diff --git a/openedx/core/djangoapps/schedules/management/commands/tests/test_send_recurring_nudge.py b/openedx/core/djangoapps/schedules/management/commands/tests/test_send_recurring_nudge.py index c7760eda2e..bc86491251 100644 --- a/openedx/core/djangoapps/schedules/management/commands/tests/test_send_recurring_nudge.py +++ b/openedx/core/djangoapps/schedules/management/commands/tests/test_send_recurring_nudge.py @@ -269,8 +269,9 @@ class TestSendRecurringNudge(CacheIsolationTestCase): self.assertEqual(len(sent_messages), 1) - for args in sent_messages: - tasks._recurring_nudge_schedule_send(*args) + with self.assertNumQueries(SEND_QUERIES): + for args in sent_messages: + tasks._recurring_nudge_schedule_send(*args) self.assertEqual(mock_channel.deliver.call_count, 1) for (_name, (_msg, email), _kwargs) in mock_channel.deliver.mock_calls: diff --git a/openedx/core/djangoapps/schedules/tasks.py b/openedx/core/djangoapps/schedules/tasks.py index 5f2998be8c..3c843c4546 100644 --- a/openedx/core/djangoapps/schedules/tasks.py +++ b/openedx/core/djangoapps/schedules/tasks.py @@ -182,11 +182,22 @@ def _add_upsell_button_to_email_template(a_user, a_schedule, template_context): # Check and upgrade link performs a query on CourseMode, which is triggering failures in # test_send_recurring_nudge.py upgrade_link, upgrade_date = check_and_get_upgrade_link_and_date(a_user, a_schedule.enrollment) + has_dynamic_deadline = a_schedule.upgrade_deadline is not None + has_upgrade_link = upgrade_link is not None + show_upsell = has_dynamic_deadline and has_upgrade_link + + template_context['show_upsell'] = show_upsell + if show_upsell: + template_context['upsell_link'] = upgrade_link + template_context['user_schedule_upgrade_deadline_time'] = dateformat.format( + upgrade_date, + get_format( + 'DATE_FORMAT', + lang=a_schedule.enrollment.course.language, + use_l10n=True + ) + ) - template_context['show_upsell'] = upgrade_link is not None - template_context['upsell_link'] = upgrade_link - template_context['user_schedule_upgrade_deadline_time'] = upgrade_date - @task(ignore_result=True, routing_key=ROUTING_KEY) def recurring_nudge_schedule_bin( diff --git a/openedx/core/djangoapps/schedules/templates/schedules/edx_ace/recurringnudge_day3/email/body.html b/openedx/core/djangoapps/schedules/templates/schedules/edx_ace/recurringnudge_day3/email/body.html index e60fa8378a..bee7b4e05a 100644 --- a/openedx/core/djangoapps/schedules/templates/schedules/edx_ace/recurringnudge_day3/email/body.html +++ b/openedx/core/djangoapps/schedules/templates/schedules/edx_ace/recurringnudge_day3/email/body.html @@ -65,7 +65,7 @@
{% blocktrans trimmed %} Don't miss the opportunity to highlight your new knowledge and skills by earning a verified - certificate. Upgrade by {{ user_schedule_upgrade_deadline_time|date:"l, F dS, Y" }}. + certificate. Upgrade by {{ user_schedule_upgrade_deadline_time }}. {% endblocktrans %}
diff --git a/openedx/core/djangoapps/schedules/templates/schedules/edx_ace/recurringnudge_day3/email/body.txt b/openedx/core/djangoapps/schedules/templates/schedules/edx_ace/recurringnudge_day3/email/body.txt index f04db8ce7e..a6704ac851 100644 --- a/openedx/core/djangoapps/schedules/templates/schedules/edx_ace/recurringnudge_day3/email/body.txt +++ b/openedx/core/djangoapps/schedules/templates/schedules/edx_ace/recurringnudge_day3/email/body.txt @@ -16,9 +16,11 @@ {% trans "Start learning now" %} <{{ course_url }}> {% endif %} +{% if show_upsell %} {% blocktrans trimmed %} Don't miss the opportunity to highlight your new knowledge and skills by earning a verified - certificate. Upgrade by {{ user_schedule_upgrade_deadline_time|date:"l, F dS, Y" }}. + certificate. Upgrade by {{ user_schedule_upgrade_deadline_time }}. Upgrade Now! <{{ upsell_link }}> {% endblocktrans %} +{% endif %}