From 8ca590d4f3dfe239b59f04051c30fdc980353cd4 Mon Sep 17 00:00:00 2001
From: zubair-arbi <zubair.afzal@arbisoft.com>
Date: Mon, 24 Aug 2015 14:03:57 +0500
Subject: [PATCH] display course id instead of name in course name placeholder,
 if ajax call to get course data fails

---
 lms/static/js/commerce/views/receipt_view.js | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/lms/static/js/commerce/views/receipt_view.js b/lms/static/js/commerce/views/receipt_view.js
index 0ddd395c476..665aec401da 100644
--- a/lms/static/js/commerce/views/receipt_view.js
+++ b/lms/static/js/commerce/views/receipt_view.js
@@ -32,7 +32,7 @@ var edx = edx || {};
                 providerId;
 
             // Add the receipt info to the template context
-            this.courseKey = this.getOrderCourseKey(data)
+            this.courseKey = this.getOrderCourseKey(data);
             this.username = this.$el.data('username');
             _.extend(context, {
                 receipt: this.receiptContext(data),
@@ -43,15 +43,21 @@ var edx = edx || {};
 
             this.trackLinks();
 
-            this.getCourseData(this.courseKey).then(this.renderCourse, this.renderError)
+            this.renderCourseNamePlaceholder(this.courseKey);
 
             providerId = this.getCreditProviderId(data);
             if (providerId) {
                 this.getProviderData(providerId).then(this.renderProvider, this.renderError)
             }
         },
-        renderCourse: function(course) {
-            $(".course_name_placeholder").text(course.name);
+        renderCourseNamePlaceholder: function(courseId) {
+            // Display the course Id or name (if available) in the placeholder
+            var $courseNamePlaceholder = $(".course_name_placeholder");
+            $courseNamePlaceholder.text(courseId);
+
+            this.getCourseData(courseId).then(function(responseData) {
+                $courseNamePlaceholder.text(responseData.name);
+            });
         },
         renderProvider: function (context) {
             var templateHtml = $("#provider-tpl").html(),
@@ -136,7 +142,7 @@ var edx = edx || {};
                 url: _.sprintf(courseDetailUrl, courseId),
                 type: 'GET',
                 dataType: 'json'
-            }).retry({times: 5, timeout: 2000, statusCodes: [404]});
+            });
         },
 
         /**
-- 
GitLab