diff --git a/cms/templates/js/certificate-details.underscore b/cms/templates/js/certificate-details.underscore
index bafde8f25f..a09a3baf89 100644
--- a/cms/templates/js/certificate-details.underscore
+++ b/cms/templates/js/certificate-details.underscore
@@ -64,7 +64,7 @@
-
+
<% } %>
diff --git a/cms/templates/js/content-group-details.underscore b/cms/templates/js/content-group-details.underscore
index a25fa42c1a..041439f7e4 100644
--- a/cms/templates/js/content-group-details.underscore
+++ b/cms/templates/js/content-group-details.underscore
@@ -28,11 +28,11 @@
<% if (_.isEmpty(usage)) { %>
-
+
<% } else { %>
-
+
<% } %>
diff --git a/cms/templates/js/group-configuration-details.underscore b/cms/templates/js/group-configuration-details.underscore
index eeae606a35..d6e989bab8 100644
--- a/cms/templates/js/group-configuration-details.underscore
+++ b/cms/templates/js/group-configuration-details.underscore
@@ -46,11 +46,11 @@
<% if (_.isEmpty(usage)) { %>
-
+
<% } else { %>
-
+
<% } %>
diff --git a/cms/templates/js/show-textbook.underscore b/cms/templates/js/show-textbook.underscore
index 99cf4c84a5..1c01997d1f 100644
--- a/cms/templates/js/show-textbook.underscore
+++ b/cms/templates/js/show-textbook.underscore
@@ -40,7 +40,7 @@
-
+
diff --git a/common/static/sass/_mixins.scss b/common/static/sass/_mixins.scss
index cf781c3b50..ef8a098974 100644
--- a/common/static/sass/_mixins.scss
+++ b/common/static/sass/_mixins.scss
@@ -313,10 +313,6 @@
background-color: $gray-l1;
color: $white;
}
-
- span {
- @extend %cont-text-sr;
- }
}
// button with no button shell until hover for understated actions
diff --git a/lms/djangoapps/student_account/test/test_views.py b/lms/djangoapps/student_account/test/test_views.py
index 7cf2f0cec3..c5f2c7fe66 100644
--- a/lms/djangoapps/student_account/test/test_views.py
+++ b/lms/djangoapps/student_account/test/test_views.py
@@ -595,6 +595,29 @@ class AccountSettingsViewTest(ThirdPartyAuthTestMixin, TestCase, ProgramsApiConf
self.assertEqual(order_detail, [])
+ def test_order_history_with_no_product(self):
+ response = {
+ 'results': [
+ factories.OrderFactory(
+ lines=[
+ factories.OrderLineFactory(
+ product=None
+ ),
+ factories.OrderLineFactory(
+ product=factories.ProductFactory(attribute_values=[factories.ProductAttributeFactory(
+ name='certificate_type',
+ value='verified'
+ )])
+ )
+ ]
+ )
+ ]
+ }
+ with mock_get_orders(response=response):
+ order_detail = get_user_orders(self.user)
+
+ self.assertEqual(len(order_detail), 1)
+
@override_settings(SITE_NAME=settings.MICROSITE_LOGISTRATION_HOSTNAME)
class MicrositeLogistrationTests(TestCase):
diff --git a/lms/djangoapps/student_account/views.py b/lms/djangoapps/student_account/views.py
index 0b71d8f7b3..ae62fd1f7b 100644
--- a/lms/djangoapps/student_account/views.py
+++ b/lms/djangoapps/student_account/views.py
@@ -334,21 +334,25 @@ def get_user_orders(user):
for order in commerce_user_orders:
if order['status'].lower() == 'complete':
for line in order['lines']:
- for attribute in line['product']['attribute_values']:
- if attribute['name'] == 'certificate_type' and attribute['value'] in allowed_course_modes:
- try:
- date_placed = datetime.strptime(order['date_placed'], "%Y-%m-%dT%H:%M:%SZ")
- order_data = {
- 'number': order['number'],
- 'price': order['total_excl_tax'],
- 'title': order['lines'][0]['title'],
- 'order_date': strftime_localized(date_placed.replace(tzinfo=pytz.UTC), 'SHORT_DATE'),
- 'receipt_url': commerce_configuration.receipt_page + order['number']
- }
- user_orders.append(order_data)
- except KeyError:
- log.exception('Invalid order structure: %r', order)
- return no_data
+ product = line.get('product')
+ if product:
+ for attribute in product['attribute_values']:
+ if attribute['name'] == 'certificate_type' and attribute['value'] in allowed_course_modes:
+ try:
+ date_placed = datetime.strptime(order['date_placed'], "%Y-%m-%dT%H:%M:%SZ")
+ order_data = {
+ 'number': order['number'],
+ 'price': order['total_excl_tax'],
+ 'title': order['lines'][0]['title'],
+ 'order_date': strftime_localized(
+ date_placed.replace(tzinfo=pytz.UTC), 'SHORT_DATE'
+ ),
+ 'receipt_url': commerce_configuration.receipt_page + order['number']
+ }
+ user_orders.append(order_data)
+ except KeyError:
+ log.exception('Invalid order structure: %r', order)
+ return no_data
return user_orders
@@ -421,6 +425,13 @@ def account_settings_context(request):
user = request.user
year_of_birth_options = [(unicode(year), unicode(year)) for year in UserProfile.VALID_YEARS]
+ try:
+ user_orders = get_user_orders(user)
+ except: # pylint: disable=bare-except
+ log.exception('Error fetching order history from Otto.')
+ # Return empty order list as account settings page expect a list and
+ # it will be broken if exception raised
+ user_orders = []
context = {
'auth': {},
@@ -447,7 +458,7 @@ def account_settings_context(request):
'user_preferences_api_url': reverse('preferences_api', kwargs={'username': user.username}),
'disable_courseware_js': True,
'show_program_listing': ProgramsApiConfig.current().show_program_listing,
- 'order_history': get_user_orders(user)
+ 'order_history': user_orders
}
if third_party_auth.is_enabled():