Skip to content
Snippets Groups Projects
Unverified Commit bb8f9ae9 authored by Matthew Piatetsky's avatar Matthew Piatetsky Committed by GitHub
Browse files

Merge pull request #17431 from edx/bundling_test_handle_exceptions

handle exceptions and create the necessary html in optimizely
parents 3fd91f35 618146e4
No related merge requests found
......@@ -585,25 +585,25 @@ def student_dashboard(request):
ecommerce_service = EcommerceService()
inverted_programs = meter.invert_programs()
urls, program_data = {}, {}
urls, programs_data = {}, {}
bundles_on_dashboard_flag = WaffleFlag(WaffleFlagNamespace(name=u'student.experiments'), u'bundles_on_dashboard')
if bundles_on_dashboard_flag.is_enabled():
programs_data = meter.programs
if programs_data and inverted_programs and inverted_programs.values():
program_uuid = inverted_programs.values()[0][0]['uuid']
meter.programs = [get_programs(request.site, uuid=program_uuid)]
program_data = meter.programs[0]
program_data = ProgramDataExtender(program_data, request.user).extend()
skus = program_data.get('skus')
urls = {
'commerce_api_url': reverse('commerce_api:v0:baskets:create'),
'buy_button_url': ecommerce_service.get_checkout_page_url(*skus)
}
urls['completeProgramURL'] = urls['buy_button_url'] + '&bundle=' + program_data.get('uuid')
# TODO: Delete this code and the relevant HTML code after testing LEARNER-3072 is complete
if bundles_on_dashboard_flag.is_enabled() and inverted_programs and inverted_programs.items():
for program in inverted_programs.values():
try:
program_uuid = program[0]['uuid']
program_data = get_programs(request.site, uuid=program_uuid)
program_data = ProgramDataExtender(program_data, request.user).extend()
skus = program_data.get('skus')
program_data['completeProgramURL'] = ecommerce_service.get_checkout_page_url(*skus) + '&bundle=' + program_data.get('uuid')
programs_data[program_uuid] = program_data
except:
pass
try:
programs_data = json.dumps(programs_data)
except:
programs_data = {}
# Construct a dictionary of course mode information
# used to render the course list. We re-use the course modes dict
......@@ -709,7 +709,7 @@ def student_dashboard(request):
context = {
'urls': urls,
'program_data': program_data,
'programs_data': programs_data,
'enterprise_message': enterprise_message,
'consent_required_courses': consent_required_courses,
'enterprise_customer_name': enterprise_customer_name,
......
......@@ -335,22 +335,6 @@ from util.course import get_link_for_about_page, get_encoded_course_sharing_utm_
</li>
% endfor
</ul>
<div class="complete-div" data-programdata="${program_data}">
% if program_data.get('is_learner_eligible_for_one_click_purchase'):
<div class="complete-program-dashboard-div"><span class="complete-program-dashboard-span">${_('Buy all remaining courses in this program and save 10%')}</span>
<a href="${urls.get('completeProgramURL')}" class="btn-brand btn cta-primary upgrade-button complete-program-dashboard-button">
${_('Upgrade All Remaining Courses (')}
% if program_data.get('discount_data', {}).get('is_discounted'):
<span class='list-price'>
${' ${price:.2f} '.format(price=program_data.get('discount_data', {}).get('total_incl_tax_excl_discounts'))}
</span>
% endif
${_(' ${price:.2f} {currency} ) '.format(price=program_data.get('full_program_price'),
currency=program_data.get('discount_data', {}).get('currency')))}
</a>
</div>
% endif
</div>
</div>
% endif
......
......@@ -146,7 +146,7 @@ from student.models import CourseEnrollment
<h2 class="header-courses">${_("My Courses")}</h2>
</header>
% if len(course_entitlements + course_enrollments) > 0:
<ul class="listing-courses">
<ul class="listing-courses" data-programs=${programs_data}>
<% share_settings = getattr(settings, 'SOCIAL_SHARING_SETTINGS', {}) %>
% for dashboard_index, enrollment in enumerate(course_entitlements + course_enrollments):
<%
......
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