feat: get subscription upsell values from env (#32770)
This commit is contained in:
@@ -6,6 +6,7 @@ import json
|
||||
from abc import ABC, abstractmethod
|
||||
from urllib.parse import quote
|
||||
|
||||
from django.conf import settings
|
||||
from django.contrib.sites.shortcuts import get_current_site
|
||||
from django.http import Http404
|
||||
from django.template.loader import render_to_string
|
||||
@@ -65,18 +66,22 @@ class ProgramsFragmentView(EdxFragmentView):
|
||||
if is_user_b2c_subscriptions_enabled
|
||||
else []
|
||||
)
|
||||
subscriptions_marketing_url = (
|
||||
get_program_subscriptions_marketing_url()
|
||||
subscription_upsell_data = (
|
||||
{
|
||||
'marketing_url': get_program_subscriptions_marketing_url(),
|
||||
'minimum_price': settings.SUBSCRIPTIONS_MINIMUM_PRICE,
|
||||
'trial_length': settings.SUBSCRIPTIONS_TRIAL_LENGTH,
|
||||
}
|
||||
if is_user_b2c_subscriptions_enabled
|
||||
else ''
|
||||
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,
|
||||
'subscription_upsell_data': subscription_upsell_data,
|
||||
'user_preferences': get_user_preferences(user),
|
||||
'is_user_b2c_subscriptions_enabled': is_user_b2c_subscriptions_enabled,
|
||||
'mobile_only': bool(mobile_only)
|
||||
@@ -152,12 +157,13 @@ class ProgramDetailsFragmentView(EdxFragmentView):
|
||||
'user_preferences': get_user_preferences(user),
|
||||
'program_data': program_data,
|
||||
'program_subscription_data': program_subscription_data,
|
||||
'is_user_b2c_subscriptions_enabled': is_user_b2c_subscriptions_enabled,
|
||||
'course_data': course_data,
|
||||
'certificate_data': certificate_data,
|
||||
'industry_pathways': industry_pathways,
|
||||
'credit_pathways': credit_pathways,
|
||||
'program_tab_view_enabled': program_tab_view_enabled(),
|
||||
'is_user_b2c_subscriptions_enabled': is_user_b2c_subscriptions_enabled,
|
||||
'subscriptions_trial_length': settings.SUBSCRIPTIONS_TRIAL_LENGTH,
|
||||
'discussion_fragment': {
|
||||
'configured': program_discussion_lti.is_configured,
|
||||
'iframe': program_discussion_lti.render_iframe()
|
||||
|
||||
@@ -5338,6 +5338,8 @@ SUBSCRIPTIONS_API_PATH = f"{SUBSCRIPTIONS_ROOT_URL}/api/v1/stripe-subscription/"
|
||||
SUBSCRIPTIONS_LEARNER_HELP_CENTER_URL = None
|
||||
SUBSCRIPTIONS_BUY_SUBSCRIPTION_URL = f"{SUBSCRIPTIONS_ROOT_URL}/api/v1/stripe-subscribe/"
|
||||
SUBSCRIPTIONS_MANAGE_SUBSCRIPTION_URL = None
|
||||
SUBSCRIPTIONS_MINIMUM_PRICE = '$39'
|
||||
SUBSCRIPTIONS_TRIAL_LENGTH = 7
|
||||
SUBSCRIPTIONS_SERVICE_WORKER_USERNAME = 'subscriptions_worker'
|
||||
|
||||
############## NOTIFICATIONS EXPIRY ##############
|
||||
|
||||
@@ -509,6 +509,8 @@ SUBSCRIPTIONS_API_PATH = f"{SUBSCRIPTIONS_ROOT_URL}/api/v1/stripe-subscription/"
|
||||
SUBSCRIPTIONS_LEARNER_HELP_CENTER_URL = None
|
||||
SUBSCRIPTIONS_BUY_SUBSCRIPTION_URL = f"{SUBSCRIPTIONS_ROOT_URL}/api/v1/stripe-subscribe/"
|
||||
SUBSCRIPTIONS_MANAGE_SUBSCRIPTION_URL = None
|
||||
SUBSCRIPTIONS_MINIMUM_PRICE = '$39'
|
||||
SUBSCRIPTIONS_TRIAL_LENGTH = 7
|
||||
|
||||
# API access management
|
||||
API_ACCESS_MANAGER_EMAIL = 'api-access@example.com'
|
||||
|
||||
@@ -677,3 +677,5 @@ SUBSCRIPTIONS_API_PATH = f"{SUBSCRIPTIONS_ROOT_URL}/api/v1/stripe-subscription/"
|
||||
SUBSCRIPTIONS_LEARNER_HELP_CENTER_URL = None
|
||||
SUBSCRIPTIONS_BUY_SUBSCRIPTION_URL = f"{SUBSCRIPTIONS_ROOT_URL}/api/v1/stripe-subscribe/"
|
||||
SUBSCRIPTIONS_MANAGE_SUBSCRIPTION_URL = None
|
||||
SUBSCRIPTIONS_MINIMUM_PRICE = '$39'
|
||||
SUBSCRIPTIONS_TRIAL_LENGTH = 7
|
||||
|
||||
@@ -15,6 +15,7 @@ class ProgramSubscriptionModel extends Backbone.Model {
|
||||
programData: { subscription_prices },
|
||||
urls = {},
|
||||
userPreferences = {},
|
||||
subscriptionsTrialLength: trialLength = 7,
|
||||
} = context;
|
||||
|
||||
const priceInUSD = subscription_prices?.find(({ currency }) => currency === 'USD');
|
||||
@@ -56,8 +57,6 @@ class ProgramSubscriptionModel extends Backbone.Model {
|
||||
userPreferences
|
||||
);
|
||||
|
||||
const trialLength = 7;
|
||||
|
||||
super(
|
||||
{
|
||||
hasActiveTrial,
|
||||
|
||||
@@ -6,7 +6,11 @@ describe('Sidebar View', () => {
|
||||
let view = null;
|
||||
const context = {
|
||||
marketingUrl: 'https://www.example.org/programs',
|
||||
subscriptionsMarketingUrl: 'https://www.example.org/program-subscriptions',
|
||||
subscriptionUpsellData: {
|
||||
marketing_url: 'https://www.example.org/program-subscriptions',
|
||||
minimum_price: '$39',
|
||||
trial_length: 7,
|
||||
},
|
||||
isUserB2CSubscriptionsEnabled: true,
|
||||
};
|
||||
|
||||
@@ -72,7 +76,7 @@ describe('Sidebar View', () => {
|
||||
el: '.sidebar',
|
||||
context: {
|
||||
isUserB2CSubscriptionsEnabled: true,
|
||||
subscriptionsMarketingUrl: '',
|
||||
subscriptionUpsellData: context.subscriptionUpsellData,
|
||||
},
|
||||
});
|
||||
view.render();
|
||||
|
||||
@@ -31,7 +31,7 @@ class SidebarView extends Backbone.View {
|
||||
postRender() {
|
||||
if (this.context.isUserB2CSubscriptionsEnabled) {
|
||||
this.subscriptionUpsellView = new SubscriptionUpsellView({
|
||||
context: this.context,
|
||||
subscriptionUpsellData: this.context.subscriptionUpsellData,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -12,17 +12,16 @@ class SubscriptionUpsellView extends Backbone.View {
|
||||
super(Object.assign({}, defaults, options));
|
||||
}
|
||||
|
||||
initialize({ context }) {
|
||||
initialize(options) {
|
||||
this.tpl = HtmlUtils.template(subscriptionUpsellTpl);
|
||||
this.context = context;
|
||||
this.subscriptionUpsellModel = new Backbone.Model(
|
||||
options.subscriptionUpsellData,
|
||||
);
|
||||
this.render();
|
||||
}
|
||||
|
||||
render() {
|
||||
const data = $.extend({}, this.context, {
|
||||
minSubscriptionPrice: '$39',
|
||||
trialLength: 7,
|
||||
});
|
||||
const data = this.subscriptionUpsellModel.toJSON();
|
||||
HtmlUtils.setHtml(this.$el, this.tpl(data));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ ProgramDetailsFactory({
|
||||
creditPathways: ${credit_pathways | n, dump_js_escaped_json},
|
||||
programTabViewEnabled: ${program_tab_view_enabled | n, dump_js_escaped_json},
|
||||
isUserB2CSubscriptionsEnabled: ${is_user_b2c_subscriptions_enabled | n, dump_js_escaped_json},
|
||||
subscriptionsTrialLength: ${subscriptions_trial_length | n, dump_js_escaped_json},
|
||||
discussionFragment: ${discussion_fragment, | n, dump_js_escaped_json},
|
||||
live_fragment: ${live_fragment, | n, dump_js_escaped_json}
|
||||
});
|
||||
|
||||
@@ -30,9 +30,9 @@ 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},
|
||||
subscriptionUpsellData: ${subscription_upsell_data | n, dump_js_escaped_json},
|
||||
userProgress: ${progress | n, dump_js_escaped_json},
|
||||
userPreferences: ${user_preferences | n, dump_js_escaped_json},
|
||||
isUserB2CSubscriptionsEnabled: ${is_user_b2c_subscriptions_enabled | n, dump_js_escaped_json},
|
||||
|
||||
@@ -8,10 +8,13 @@
|
||||
<p class="advertise-message">
|
||||
<%- StringUtils.interpolate(
|
||||
gettext('Now available for many popular programs, affordable monthly subscription pricing can help you manage your budget more effectively. Subscriptions start at {minSubscriptionPrice}/month USD per program, after a 7-day full access free trial. Cancel at any time.'),
|
||||
{ minSubscriptionPrice, trialLength }
|
||||
{
|
||||
minSubscriptionPrice: minimum_price,
|
||||
trialLength: trial_length,
|
||||
}
|
||||
) %>
|
||||
</p>
|
||||
<a href="<%- subscriptionsMarketingUrl %>" class="js-subscription-upsell-cta btn-brand btn cta-primary view-button align-self-stretch">
|
||||
<a href="<%- marketing_url %>" 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>
|
||||
|
||||
Reference in New Issue
Block a user