feat: add marketing url to subscription upsell (#32560)

This commit is contained in:
Nawfal Ahmed
2023-06-23 17:54:15 +05:00
committed by GitHub
parent ef0fa643f5
commit 80d151b404
7 changed files with 30 additions and 7 deletions

View File

@@ -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,

View File

@@ -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 = {}

View File

@@ -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();

View File

@@ -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,
});

View File

@@ -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},

View File

@@ -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>

View File

@@ -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.