Skip to content
Snippets Groups Projects
Commit 30c14b36 authored by Matthew Piatetsky's avatar Matthew Piatetsky
Browse files

bundles on track selection

parent 0ec4232c
No related merge requests found
......@@ -28,6 +28,8 @@ from lms.djangoapps.commerce.utils import EcommerceService
from lms.djangoapps.experiments.utils import get_experiment_user_metadata_context
from openedx.core.djangoapps.catalog.utils import get_currency_data
from openedx.core.djangoapps.embargo import api as embargo_api
from openedx.core.djangoapps.programs.utils import ProgramDataExtender, ProgramProgressMeter
from openedx.core.djangoapps.waffle_utils import WaffleFlag, WaffleFlagNamespace
from student.models import CourseEnrollment
from util.db import outer_atomic
from xmodule.modulestore.django import modulestore
......@@ -140,7 +142,24 @@ class ChooseModeView(View):
in CourseMode.modes_for_course(course_key, only_selectable=False)
)
course_id = text_type(course_key)
bundle_data = {}
bundles_on_track_selection = WaffleFlag(WaffleFlagNamespace(name=u'experiments'), u'bundles_on_track_selection')
if bundles_on_track_selection.is_enabled():
meter = ProgramProgressMeter(request.site, request.user, enrollments=[CourseEnrollment])
if meter.programs and meter.programs[0]:
program_data = meter.programs[0]
program_data = ProgramDataExtender(program_data, request.user, mobile_only=False).extend()
skus = program_data.get('skus')
ecommerce_service = EcommerceService()
bundle_data = {
'program_marketing_site_url': program_data.get('marketing_url'),
'program_bundle_url': ecommerce_service.get_checkout_page_url(*skus),
'discount_data': program_data.get('discount_data'),
}
context = {
"bundle_data": bundle_data,
"course_modes_choose_url": reverse(
"course_modes_choose",
kwargs={'course_id': course_id}
......
......@@ -5,7 +5,7 @@
from django.utils.translation import ugettext as _
from django.urls import reverse
from opaque_keys.edx.keys import CourseKey
from openedx.core.djangolib.js_utils import js_escaped_string
from openedx.core.djangolib.js_utils import dump_js_escaped_json, js_escaped_string
from openedx.core.djangolib.markup import HTML, Text
from openedx.features.learner_analytics import INCLUDE_UPSELL_MODAL
from openedx.features.portfolio_project import INCLUDE_PORTFOLIO_UPSELL_MODAL
......@@ -85,6 +85,9 @@ from openedx.features.portfolio_project import INCLUDE_PORTFOLIO_UPSELL_MODAL
%endif
<div id="currency_data" value="${currency_data}"></div>
<script type="application/json" id="bundle-data">
${bundle_data | n, dump_js_escaped_json}
</script>
<div class="container">
% if INCLUDE_UPSELL_MODAL.is_enabled():
${static.renderReact(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment