Commit fc7c1652 by sandroroux Committed by Calen Pennington

Modified criteria for upselling. User must have a dynamic deadline to receive an…

Modified criteria for upselling. User must have a dynamic deadline to receive an email with an upsell button
parent 956cb919
......@@ -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
......
......@@ -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:
......
......@@ -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(
......
......@@ -65,7 +65,7 @@
<p>
{% 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 %}
</p>
<p>
......
......@@ -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 %}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment