limit bundling code to users with less than 4 enrollments

This commit is contained in:
Matthew Piatetsky
2018-02-15 18:55:02 -05:00
parent 15e07d7cc5
commit 70ec5e47c6
2 changed files with 14 additions and 16 deletions

View File

@@ -526,7 +526,6 @@ def student_dashboard(request):
enrollment_message = _create_recent_enrollment_message(
course_enrollments, course_modes_by_course
)
course_optouts = Optout.objects.filter(user=user).values_list('course_id', flat=True)
sidebar_account_activation_message = ''
@@ -590,20 +589,18 @@ def student_dashboard(request):
# 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 = {}
if len(course_enrollments) < 4:
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')
checkout_page_url = ecommerce_service.get_checkout_page_url(*skus)
program_data['completeProgramURL'] = checkout_page_url + '&bundle=' + program_data.get('uuid')
programs_data[program_uuid] = program_data
except: # pylint: disable=bare-except
pass
# Construct a dictionary of course mode information
# used to render the course list. We re-use the course modes dict

View File

@@ -3,6 +3,7 @@
<%def name="online_help_token()"><% return "learnerdashboard" %></%def>
<%namespace name='static' file='static_content.html'/>
<%!
import json
import pytz
from courseware.context_processor import user_timezone_locale_prefs
from datetime import datetime, timedelta
@@ -146,7 +147,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" data-programs=${programs_data}>
<ul class="listing-courses" data-programs='${json.dumps(programs_data)}'>
<% share_settings = getattr(settings, 'SOCIAL_SHARING_SETTINGS', {}) %>
% for dashboard_index, enrollment in enumerate(course_entitlements + course_enrollments):
<%