feat: add marketing url to subscription upsell (#32560)
This commit is contained in:
@@ -31,6 +31,7 @@ from openedx.core.djangoapps.programs.utils import (
|
||||
get_industry_and_credit_pathways,
|
||||
get_program_and_course_data,
|
||||
get_program_marketing_url,
|
||||
get_program_subscriptions_marketing_url,
|
||||
get_program_urls,
|
||||
get_programs_subscription_data
|
||||
)
|
||||
@@ -59,10 +60,20 @@ class ProgramsFragmentView(EdxFragmentView):
|
||||
|
||||
meter = ProgramProgressMeter(request.site, user, mobile_only=mobile_only)
|
||||
is_user_b2c_subscriptions_enabled = b2c_subscriptions_enabled(mobile_only)
|
||||
programs_subscription_data = get_programs_subscription_data(user) if is_user_b2c_subscriptions_enabled else []
|
||||
programs_subscription_data = (
|
||||
get_programs_subscription_data(user)
|
||||
if is_user_b2c_subscriptions_enabled
|
||||
else []
|
||||
)
|
||||
subscriptions_marketing_url = (
|
||||
get_program_subscriptions_marketing_url()
|
||||
if is_user_b2c_subscriptions_enabled
|
||||
else ''
|
||||
)
|
||||
|
||||
context = {
|
||||
'marketing_url': get_program_marketing_url(programs_config, mobile_only),
|
||||
'subscriptions_marketing_url': subscriptions_marketing_url,
|
||||
'programs': meter.engaged_programs,
|
||||
'progress': meter.progress(),
|
||||
'programs_subscription_data': programs_subscription_data,
|
||||
|
||||
@@ -431,6 +431,7 @@ MKTG_URLS = {
|
||||
'TOS': '/edx-terms-service',
|
||||
'TOS_AND_HONOR': '/edx-terms-service',
|
||||
'WHAT_IS_VERIFIED_CERT': '/verified-certificate',
|
||||
'PROGRAM_SUBSCRIPTIONS': '/program-subscriptions',
|
||||
}
|
||||
|
||||
ENTERPRISE_MARKETING_FOOTER_QUERY_PARAMS = {}
|
||||
|
||||
@@ -6,6 +6,7 @@ describe('Sidebar View', () => {
|
||||
let view = null;
|
||||
const context = {
|
||||
marketingUrl: 'https://www.example.org/programs',
|
||||
subscriptionsMarketingUrl: 'https://www.example.org/program-subscriptions',
|
||||
isUserB2CSubscriptionsEnabled: true,
|
||||
};
|
||||
|
||||
@@ -53,8 +54,7 @@ describe('Sidebar View', () => {
|
||||
expect(view.$('.js-subscription-upsell a span:last').html().trim())
|
||||
.toEqual('Explore subscription options');
|
||||
expect(view.$('.js-subscription-upsell a').attr('href'))
|
||||
.not
|
||||
.toEqual(context.marketingUrl);
|
||||
.toEqual('https://www.example.org/program-subscriptions');
|
||||
});
|
||||
|
||||
it('should load the exploration panel given a marketing URL', () => {
|
||||
@@ -72,6 +72,7 @@ describe('Sidebar View', () => {
|
||||
el: '.sidebar',
|
||||
context: {
|
||||
isUserB2CSubscriptionsEnabled: true,
|
||||
subscriptionsMarketingUrl: '',
|
||||
},
|
||||
});
|
||||
view.render();
|
||||
|
||||
@@ -12,14 +12,14 @@ class SubscriptionUpsellView extends Backbone.View {
|
||||
super(Object.assign({}, defaults, options));
|
||||
}
|
||||
|
||||
initialize(options) {
|
||||
initialize({ context }) {
|
||||
this.tpl = HtmlUtils.template(subscriptionUpsellTpl);
|
||||
this.data = options.context;
|
||||
this.context = context;
|
||||
this.render();
|
||||
}
|
||||
|
||||
render() {
|
||||
const data = $.extend(this.context, {
|
||||
const data = $.extend({}, this.context, {
|
||||
minSubscriptionPrice: '$39',
|
||||
trialLength: 7,
|
||||
});
|
||||
|
||||
@@ -21,6 +21,7 @@ from openedx.core.djangolib.js_utils import (
|
||||
<%static:webpack entry="ProgramListFactory">
|
||||
ProgramListFactory({
|
||||
marketingUrl: '${marketing_url | n, js_escaped_string}',
|
||||
subscriptionsMarketingUrl: '${subscriptions_marketing_url | n, js_escaped_string}',
|
||||
programsData: ${programs | n, dump_js_escaped_json},
|
||||
programsSubscriptionData: ${programs_subscription_data | n, dump_js_escaped_json},
|
||||
userProgress: ${progress | n, dump_js_escaped_json},
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
{ minSubscriptionPrice, trialLength }
|
||||
) %>
|
||||
</p>
|
||||
<a href="" class="js-subscription-upsell-cta btn-brand btn cta-primary view-button align-self-stretch">
|
||||
<a href="<%- subscriptionsMarketingUrl %>" class="js-subscription-upsell-cta btn-brand btn cta-primary view-button align-self-stretch">
|
||||
<span class="icon fa fa-search" aria-hidden="true"></span>
|
||||
<span><%- gettext('Explore subscription options') %></span>
|
||||
</a>
|
||||
|
||||
@@ -131,6 +131,15 @@ def get_program_marketing_url(programs_config, mobile_only=False):
|
||||
return marketing_url
|
||||
|
||||
|
||||
def get_program_subscriptions_marketing_url():
|
||||
"""Build a URL used to link to subscription eligible programs on the marketing site."""
|
||||
marketing_urls = settings.MKTG_URLS
|
||||
return urljoin(
|
||||
marketing_urls.get('ROOT'),
|
||||
marketing_urls.get('PROGRAM_SUBSCRIPTIONS'),
|
||||
)
|
||||
|
||||
|
||||
def attach_program_detail_url(programs, mobile_only=False):
|
||||
"""Extend program representations by attaching a URL to be used when linking to program details.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user