Revert "Adding background image for xseries certificates on dashboard side bar panel"
This commit is contained in:
@@ -14,8 +14,6 @@ from edx_oauth2_provider.tests.factories import ClientFactory
|
||||
from opaque_keys.edx import locator
|
||||
from provider.constants import CONFIDENTIAL
|
||||
|
||||
from openedx.core.djangoapps.credentials.models import CredentialsApiConfig
|
||||
from openedx.core.djangoapps.credentials.tests.mixins import CredentialsDataMixin, CredentialsApiConfigMixin
|
||||
from openedx.core.djangoapps.programs.tests.mixins import (
|
||||
ProgramsApiConfigMixin,
|
||||
ProgramsDataMixin)
|
||||
@@ -31,9 +29,7 @@ from xmodule.modulestore.tests.factories import CourseFactory
|
||||
class TestProgramListing(
|
||||
ModuleStoreTestCase,
|
||||
ProgramsApiConfigMixin,
|
||||
ProgramsDataMixin,
|
||||
CredentialsDataMixin,
|
||||
CredentialsApiConfigMixin):
|
||||
ProgramsDataMixin):
|
||||
|
||||
"""
|
||||
Unit tests for getting the list of programs enrolled by a logged in user
|
||||
@@ -45,7 +41,6 @@ class TestProgramListing(
|
||||
Add a student
|
||||
"""
|
||||
super(TestProgramListing, self).setUp()
|
||||
ClientFactory(name=CredentialsApiConfig.OAUTH2_CLIENT_NAME, client_type=CONFIDENTIAL)
|
||||
ClientFactory(name=ProgramsApiConfig.OAUTH2_CLIENT_NAME, client_type=CONFIDENTIAL)
|
||||
self.student = UserFactory()
|
||||
self.create_programs_config(xseries_ad_enabled=True, program_listing_enabled=True)
|
||||
@@ -144,57 +139,3 @@ class TestProgramListing(
|
||||
self.assertEqual(response.status_code, 302)
|
||||
self.assertIsInstance(response, HttpResponseRedirect)
|
||||
self.assertIn('login', response.url) # pylint: disable=no-member
|
||||
|
||||
def _expected_credetials_data(self):
|
||||
""" Dry method for getting expected credentials."""
|
||||
|
||||
return [
|
||||
{
|
||||
"display_name": "Test Program A",
|
||||
"credential_url": "http://credentials.edx.org/credentials/dummy-uuid-1/"
|
||||
},
|
||||
{
|
||||
"display_name": "Test Program B",
|
||||
"credential_url": "http://credentials.edx.org/credentials/dummy-uuid-2/"
|
||||
}
|
||||
]
|
||||
|
||||
@httpretty.activate
|
||||
def test_get_xseries_certificates_with_data(self):
|
||||
|
||||
self.create_programs_config(program_listing_enabled=True)
|
||||
self.create_credentials_config(is_learner_issuance_enabled=True)
|
||||
|
||||
self.client.login(username=self.student.username, password=self.PASSWORD)
|
||||
|
||||
# mock programs and credentials apis
|
||||
self.mock_programs_api()
|
||||
self.mock_credentials_api(self.student, data=self.CREDENTIALS_API_RESPONSE, reset_url=False)
|
||||
|
||||
response = self.client.get(reverse("program_listing_view"))
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
for certificate in self._expected_credetials_data():
|
||||
self.assertIn(certificate['display_name'], response.content)
|
||||
self.assertIn(certificate['credential_url'], response.content)
|
||||
|
||||
self.assertIn('images/xseries-certificate-visual.png', response.content)
|
||||
|
||||
@httpretty.activate
|
||||
def test_get_xseries_certificates_without_data(self):
|
||||
|
||||
self.create_programs_config(program_listing_enabled=True)
|
||||
self.create_credentials_config(is_learner_issuance_enabled=True)
|
||||
|
||||
self.client.login(username=self.student.username, password=self.PASSWORD)
|
||||
|
||||
# mock programs and credentials apis
|
||||
self.mock_programs_api()
|
||||
self.mock_credentials_api(self.student, data={"results": []}, reset_url=False)
|
||||
|
||||
response = self.client.get(reverse("program_listing_view"))
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
for certificate in self._expected_credetials_data():
|
||||
self.assertNotIn(certificate['display_name'], response.content)
|
||||
self.assertNotIn(certificate['credential_url'], response.content)
|
||||
|
||||
@@ -9,7 +9,7 @@ from django.http import Http404
|
||||
from edxmako.shortcuts import render_to_response
|
||||
from openedx.core.djangoapps.programs.utils import get_engaged_programs
|
||||
from openedx.core.djangoapps.programs.models import ProgramsApiConfig
|
||||
from student.views import get_course_enrollments, _get_xseries_credentials
|
||||
from student.views import get_course_enrollments
|
||||
|
||||
|
||||
@login_required
|
||||
@@ -35,6 +35,5 @@ def view_programs(request):
|
||||
'programs': programs,
|
||||
'xseries_url': marketing_root if ProgramsApiConfig.current().show_xseries_ad else None,
|
||||
'nav_hidden': True,
|
||||
'show_program_listing': show_program_listing,
|
||||
'credentials': _get_xseries_credentials(request.user)
|
||||
'show_program_listing': show_program_listing
|
||||
})
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 14 KiB |
@@ -1,31 +0,0 @@
|
||||
;(function (define) {
|
||||
'use strict';
|
||||
define(['backbone',
|
||||
'jquery',
|
||||
'underscore',
|
||||
'gettext',
|
||||
'text!../../../templates/learner_dashboard/certificate.underscore'
|
||||
],
|
||||
function(
|
||||
Backbone,
|
||||
$,
|
||||
_,
|
||||
gettext,
|
||||
certificateTpl
|
||||
) {
|
||||
return Backbone.View.extend({
|
||||
el: '.certificates-list',
|
||||
tpl: _.template(certificateTpl),
|
||||
initialize: function(data) {
|
||||
this.context = data.context;
|
||||
this.render();
|
||||
},
|
||||
render: function() {
|
||||
if (this.context.certificatesData.length > 0) {
|
||||
this.$el.html(this.tpl(this.context));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
);
|
||||
}).call(this, define || RequireJS.define);
|
||||
@@ -6,7 +6,6 @@
|
||||
'underscore',
|
||||
'gettext',
|
||||
'js/learner_dashboard/views/explore_new_programs_view',
|
||||
'js/learner_dashboard/views/certificate_view',
|
||||
'text!../../../templates/learner_dashboard/sidebar.underscore'
|
||||
],
|
||||
function(
|
||||
@@ -15,7 +14,6 @@
|
||||
_,
|
||||
gettext,
|
||||
NewProgramsView,
|
||||
CertificateView,
|
||||
sidebarTpl
|
||||
) {
|
||||
return Backbone.View.extend({
|
||||
@@ -36,10 +34,6 @@
|
||||
this.newProgramsView = new NewProgramsView({
|
||||
context: this.context
|
||||
});
|
||||
|
||||
this.newCertificateView = new CertificateView({
|
||||
context: this.context
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,65 +0,0 @@
|
||||
define([
|
||||
'backbone',
|
||||
'jquery',
|
||||
'js/learner_dashboard/views/certificate_view'
|
||||
], function (Backbone, $, CertificateView) {
|
||||
|
||||
'use strict';
|
||||
describe('Certificate View', function () {
|
||||
var view = null,
|
||||
data = {
|
||||
context: {
|
||||
certificatesData: [
|
||||
{
|
||||
"display_name": "Testing",
|
||||
"credential_url": "https://credentials.stage.edx.org/credentials/dummy-uuid-1/"
|
||||
},
|
||||
{
|
||||
"display_name": "Testing2",
|
||||
"credential_url": "https://credentials.stage.edx.org/credentials/dummy-uuid-2/"
|
||||
}
|
||||
],
|
||||
xseriesImage: "/images/testing.png"
|
||||
}
|
||||
};
|
||||
|
||||
beforeEach(function() {
|
||||
setFixtures('<div class="certificates-list"></div>');
|
||||
view = new CertificateView(data);
|
||||
view.render();
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
view.remove();
|
||||
});
|
||||
|
||||
it('should exist', function() {
|
||||
expect(view).toBeDefined();
|
||||
});
|
||||
|
||||
it('should load the certificates based on passed in certificates list', function() {
|
||||
var $certificates = view.$el.find('.certificate-box');
|
||||
expect($certificates.length).toBe(2);
|
||||
|
||||
$certificates.each(function(index, el){
|
||||
expect($(el).html().trim()).toEqual(data.context.certificatesData[index].display_name);
|
||||
expect($(el).attr('href')).toEqual(data.context.certificatesData[index].credential_url);
|
||||
});
|
||||
expect(view.$el.find('.title').html().trim()).toEqual('XSeries Program Certificates:');
|
||||
expect(view.$el.find('img').attr('src')).toEqual('/images/testing.png');
|
||||
});
|
||||
|
||||
it('should display no certificate box if certificates list is empty', function() {
|
||||
var $certificate;
|
||||
view.remove();
|
||||
setFixtures('<div class="certificates-list"></div>');
|
||||
view = new CertificateView({
|
||||
context: {certificatesData: []}
|
||||
});
|
||||
view.render();
|
||||
$certificate = view.$el.find('.certificate-box');
|
||||
expect($certificate.length).toBe(0);
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
@@ -10,14 +10,7 @@ define([
|
||||
describe('Sidebar View', function () {
|
||||
var view = null,
|
||||
context = {
|
||||
xseriesUrl: 'http://www.edx.org/xseries',
|
||||
certificatesData: [
|
||||
{
|
||||
"display_name": "Testing",
|
||||
"credential_url": "https://credentials.stage.edx.org/credentials/dummy-uuid-1/"
|
||||
}
|
||||
],
|
||||
xseriesImage: '/image/test.png'
|
||||
xseriesUrl: 'http://www.edx.org/xseries'
|
||||
};
|
||||
|
||||
beforeEach(function() {
|
||||
@@ -45,23 +38,17 @@ define([
|
||||
expect($sidebar.find('.program-advertise .ad-link a').attr('href')).toEqual(context.xseriesUrl);
|
||||
});
|
||||
|
||||
it('should load the certificates based on passed in certificates list', function() {
|
||||
expect(view.$('.certificate-box').length).toBe(1);
|
||||
});
|
||||
|
||||
it('should not load the xseries advertising if no xseriesUrl passed in', function(){
|
||||
var $ad;
|
||||
view.remove();
|
||||
view = new SidebarView({
|
||||
el: '.sidebar',
|
||||
context: {certificatesData: []}
|
||||
context: {}
|
||||
});
|
||||
view.render();
|
||||
$ad = view.$el.find('.program-advertise');
|
||||
expect($ad.length).toBe(0);
|
||||
expect(view.$('.certificate-box').length).toBe(0);
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
@@ -754,8 +754,7 @@
|
||||
'lms/include/js/spec/markdown_editor_spec.js',
|
||||
'lms/include/js/spec/learner_dashboard/collection_list_view_spec.js',
|
||||
'lms/include/js/spec/learner_dashboard/sidebar_view_spec.js',
|
||||
'lms/include/js/spec/learner_dashboard/program_card_view_spec.js',
|
||||
'lms/include/js/spec/learner_dashboard/certificate_view_spec.js'
|
||||
'lms/include/js/spec/learner_dashboard/program_card_view_spec.js'
|
||||
]);
|
||||
|
||||
}).call(this, requirejs, define);
|
||||
|
||||
@@ -59,7 +59,6 @@
|
||||
@import "views/financial-assistance";
|
||||
@import 'views/bookmarks';
|
||||
@import 'course/auto-cert';
|
||||
@import 'xseries_certificates';
|
||||
@import 'views/program-list';
|
||||
@import 'views/api-access';
|
||||
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
@mixin xseries-certificate-container {
|
||||
border: 1px solid $gray-l3;
|
||||
box-sizing: border-box;
|
||||
padding: $baseline;
|
||||
background: $gray-l6;
|
||||
margin-top: $baseline;
|
||||
.title{
|
||||
@extend %t-title6;
|
||||
@extend %t-weight3;
|
||||
margin-bottom:$baseline;
|
||||
color: $gray;
|
||||
}
|
||||
.certificate-box{
|
||||
padding-top: $baseline;
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
@@ -19,11 +19,6 @@ $pl-button-color: #0079bc;
|
||||
.sidebar{
|
||||
@include outer-container;
|
||||
@include span-columns(12);
|
||||
float: right !important;
|
||||
margin-bottom: $baseline;
|
||||
.certificate-container{
|
||||
@include xseries-certificate-container();
|
||||
}
|
||||
.program-advertise{
|
||||
padding: $baseline;
|
||||
background-color: $body-bg;
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
<div class="certificate-container">
|
||||
<p class="title"><%- gettext('XSeries Program Certificates') %>:</p>
|
||||
<img src="<%- xseriesImage %>" alt="">
|
||||
<% _.each(certificatesData, function(certificate){ %>
|
||||
<a class="certificate-box" href="<%- gettext(certificate.credential_url) %>"><%- gettext(certificate.display_name) %></a>
|
||||
<% }); %>
|
||||
</div>
|
||||
@@ -12,9 +12,7 @@ from openedx.core.djangolib.js_utils import (
|
||||
<%static:require_module module_name="js/learner_dashboard/program_list_factory" class_name="ProgramListFactory">
|
||||
ProgramListFactory({
|
||||
programsData: ${programs | n, dump_js_escaped_json},
|
||||
certificatesData: ${credentials | n, dump_js_escaped_json},
|
||||
xseriesUrl: '${xseries_url | n, js_escaped_string}',
|
||||
xseriesImage: '${static.url('images/xseries-certificate-visual.png')}'
|
||||
xseriesUrl: '${xseries_url | n, js_escaped_string}'
|
||||
});
|
||||
</%static:require_module>
|
||||
</%block>
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
<div class="program-advertise"></div>
|
||||
<div class="certificates-list"></div>
|
||||
<div class="certificate-container"></div>
|
||||
|
||||
Reference in New Issue
Block a user