Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
88192fd4
Commit
88192fd4
authored
Apr 19, 2016
by
Adam
Committed by
Awais
Apr 20, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Revert "Adding background image for xseries certificates on dashboard side bar panel""
parent
47e4804b
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
216 additions
and
8 deletions
+216
-8
lms/djangoapps/learner_dashboard/tests/test_programs.py
+60
-1
lms/djangoapps/learner_dashboard/views.py
+3
-2
lms/static/images/xseries-certificate-visual.png
+0
-0
lms/static/js/learner_dashboard/views/certificate_view.js
+31
-0
lms/static/js/learner_dashboard/views/sidebar_view.js
+6
-0
lms/static/js/spec/learner_dashboard/certificate_view_spec.js
+65
-0
lms/static/js/spec/learner_dashboard/sidebar_view_spec.js
+15
-2
lms/static/js/spec/main.js
+2
-1
lms/static/sass/_build-lms-v1.scss
+1
-0
lms/static/sass/_xseries_certificates.scss
+17
-0
lms/static/sass/views/_program-list.scss
+5
-0
lms/templates/learner_dashboard/certificate.underscore
+7
-0
lms/templates/learner_dashboard/programs.html
+3
-1
lms/templates/learner_dashboard/sidebar.underscore
+1
-1
No files found.
lms/djangoapps/learner_dashboard/tests/test_programs.py
View file @
88192fd4
...
@@ -14,6 +14,8 @@ from edx_oauth2_provider.tests.factories import ClientFactory
...
@@ -14,6 +14,8 @@ from edx_oauth2_provider.tests.factories import ClientFactory
from
opaque_keys.edx
import
locator
from
opaque_keys.edx
import
locator
from
provider.constants
import
CONFIDENTIAL
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
(
from
openedx.core.djangoapps.programs.tests.mixins
import
(
ProgramsApiConfigMixin
,
ProgramsApiConfigMixin
,
ProgramsDataMixin
)
ProgramsDataMixin
)
...
@@ -29,7 +31,9 @@ from xmodule.modulestore.tests.factories import CourseFactory
...
@@ -29,7 +31,9 @@ from xmodule.modulestore.tests.factories import CourseFactory
class
TestProgramListing
(
class
TestProgramListing
(
ModuleStoreTestCase
,
ModuleStoreTestCase
,
ProgramsApiConfigMixin
,
ProgramsApiConfigMixin
,
ProgramsDataMixin
):
ProgramsDataMixin
,
CredentialsDataMixin
,
CredentialsApiConfigMixin
):
"""
"""
Unit tests for getting the list of programs enrolled by a logged in user
Unit tests for getting the list of programs enrolled by a logged in user
...
@@ -41,6 +45,7 @@ class TestProgramListing(
...
@@ -41,6 +45,7 @@ class TestProgramListing(
Add a student
Add a student
"""
"""
super
(
TestProgramListing
,
self
)
.
setUp
()
super
(
TestProgramListing
,
self
)
.
setUp
()
ClientFactory
(
name
=
CredentialsApiConfig
.
OAUTH2_CLIENT_NAME
,
client_type
=
CONFIDENTIAL
)
ClientFactory
(
name
=
ProgramsApiConfig
.
OAUTH2_CLIENT_NAME
,
client_type
=
CONFIDENTIAL
)
ClientFactory
(
name
=
ProgramsApiConfig
.
OAUTH2_CLIENT_NAME
,
client_type
=
CONFIDENTIAL
)
self
.
student
=
UserFactory
()
self
.
student
=
UserFactory
()
self
.
create_programs_config
(
xseries_ad_enabled
=
True
,
program_listing_enabled
=
True
)
self
.
create_programs_config
(
xseries_ad_enabled
=
True
,
program_listing_enabled
=
True
)
...
@@ -139,3 +144,57 @@ class TestProgramListing(
...
@@ -139,3 +144,57 @@ class TestProgramListing(
self
.
assertEqual
(
response
.
status_code
,
302
)
self
.
assertEqual
(
response
.
status_code
,
302
)
self
.
assertIsInstance
(
response
,
HttpResponseRedirect
)
self
.
assertIsInstance
(
response
,
HttpResponseRedirect
)
self
.
assertIn
(
'login'
,
response
.
url
)
# pylint: disable=no-member
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
)
lms/djangoapps/learner_dashboard/views.py
View file @
88192fd4
...
@@ -9,7 +9,7 @@ from django.http import Http404
...
@@ -9,7 +9,7 @@ from django.http import Http404
from
edxmako.shortcuts
import
render_to_response
from
edxmako.shortcuts
import
render_to_response
from
openedx.core.djangoapps.programs.utils
import
get_engaged_programs
from
openedx.core.djangoapps.programs.utils
import
get_engaged_programs
from
openedx.core.djangoapps.programs.models
import
ProgramsApiConfig
from
openedx.core.djangoapps.programs.models
import
ProgramsApiConfig
from
student.views
import
get_course_enrollments
from
student.views
import
get_course_enrollments
,
_get_xseries_credentials
@login_required
@login_required
...
@@ -35,5 +35,6 @@ def view_programs(request):
...
@@ -35,5 +35,6 @@ def view_programs(request):
'programs'
:
programs
,
'programs'
:
programs
,
'xseries_url'
:
marketing_root
if
ProgramsApiConfig
.
current
()
.
show_xseries_ad
else
None
,
'xseries_url'
:
marketing_root
if
ProgramsApiConfig
.
current
()
.
show_xseries_ad
else
None
,
'nav_hidden'
:
True
,
'nav_hidden'
:
True
,
'show_program_listing'
:
show_program_listing
'show_program_listing'
:
show_program_listing
,
'credentials'
:
_get_xseries_credentials
(
request
.
user
)
})
})
lms/static/images/xseries-certificate-visual.png
0 → 100644
View file @
88192fd4
14 KB
lms/static/js/learner_dashboard/views/certificate_view.js
0 → 100644
View file @
88192fd4
;(
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
);
lms/static/js/learner_dashboard/views/sidebar_view.js
View file @
88192fd4
...
@@ -6,6 +6,7 @@
...
@@ -6,6 +6,7 @@
'underscore'
,
'underscore'
,
'gettext'
,
'gettext'
,
'js/learner_dashboard/views/explore_new_programs_view'
,
'js/learner_dashboard/views/explore_new_programs_view'
,
'js/learner_dashboard/views/certificate_view'
,
'text!../../../templates/learner_dashboard/sidebar.underscore'
'text!../../../templates/learner_dashboard/sidebar.underscore'
],
],
function
(
function
(
...
@@ -14,6 +15,7 @@
...
@@ -14,6 +15,7 @@
_
,
_
,
gettext
,
gettext
,
NewProgramsView
,
NewProgramsView
,
CertificateView
,
sidebarTpl
sidebarTpl
)
{
)
{
return
Backbone
.
View
.
extend
({
return
Backbone
.
View
.
extend
({
...
@@ -34,6 +36,10 @@
...
@@ -34,6 +36,10 @@
this
.
newProgramsView
=
new
NewProgramsView
({
this
.
newProgramsView
=
new
NewProgramsView
({
context
:
this
.
context
context
:
this
.
context
});
});
this
.
newCertificateView
=
new
CertificateView
({
context
:
this
.
context
});
}
}
});
});
}
}
...
...
lms/static/js/spec/learner_dashboard/certificate_view_spec.js
0 → 100644
View file @
88192fd4
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
);
});
});
}
);
lms/static/js/spec/learner_dashboard/sidebar_view_spec.js
View file @
88192fd4
...
@@ -10,7 +10,14 @@ define([
...
@@ -10,7 +10,14 @@ define([
describe
(
'Sidebar View'
,
function
()
{
describe
(
'Sidebar View'
,
function
()
{
var
view
=
null
,
var
view
=
null
,
context
=
{
context
=
{
xseriesUrl
:
'http://www.edx.org/xseries'
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'
};
};
beforeEach
(
function
()
{
beforeEach
(
function
()
{
...
@@ -38,17 +45,23 @@ define([
...
@@ -38,17 +45,23 @@ define([
expect
(
$sidebar
.
find
(
'.program-advertise .ad-link a'
).
attr
(
'href'
)).
toEqual
(
context
.
xseriesUrl
);
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
(){
it
(
'should not load the xseries advertising if no xseriesUrl passed in'
,
function
(){
var
$ad
;
var
$ad
;
view
.
remove
();
view
.
remove
();
view
=
new
SidebarView
({
view
=
new
SidebarView
({
el
:
'.sidebar'
,
el
:
'.sidebar'
,
context
:
{}
context
:
{
certificatesData
:
[]
}
});
});
view
.
render
();
view
.
render
();
$ad
=
view
.
$el
.
find
(
'.program-advertise'
);
$ad
=
view
.
$el
.
find
(
'.program-advertise'
);
expect
(
$ad
.
length
).
toBe
(
0
);
expect
(
$ad
.
length
).
toBe
(
0
);
expect
(
view
.
$
(
'.certificate-box'
).
length
).
toBe
(
0
);
});
});
});
});
}
}
);
);
lms/static/js/spec/main.js
View file @
88192fd4
...
@@ -754,7 +754,8 @@
...
@@ -754,7 +754,8 @@
'lms/include/js/spec/markdown_editor_spec.js'
,
'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/collection_list_view_spec.js'
,
'lms/include/js/spec/learner_dashboard/sidebar_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/program_card_view_spec.js'
,
'lms/include/js/spec/learner_dashboard/certificate_view_spec.js'
]);
]);
}).
call
(
this
,
requirejs
,
define
);
}).
call
(
this
,
requirejs
,
define
);
lms/static/sass/_build-lms-v1.scss
View file @
88192fd4
...
@@ -59,6 +59,7 @@
...
@@ -59,6 +59,7 @@
@import
"views/financial-assistance"
;
@import
"views/financial-assistance"
;
@import
'views/bookmarks'
;
@import
'views/bookmarks'
;
@import
'course/auto-cert'
;
@import
'course/auto-cert'
;
@import
'xseries_certificates'
;
@import
'views/program-list'
;
@import
'views/program-list'
;
@import
'views/api-access'
;
@import
'views/api-access'
;
...
...
lms/static/sass/_xseries_certificates.scss
0 → 100644
View file @
88192fd4
@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
;
}
}
lms/static/sass/views/_program-list.scss
View file @
88192fd4
...
@@ -19,6 +19,11 @@ $pl-button-color: #0079bc;
...
@@ -19,6 +19,11 @@ $pl-button-color: #0079bc;
.sidebar
{
.sidebar
{
@include
outer-container
;
@include
outer-container
;
@include
span-columns
(
12
);
@include
span-columns
(
12
);
@include
float
(
right
);
margin-bottom
:
$baseline
;
.certificate-container
{
@include
xseries-certificate-container
();
}
.program-advertise
{
.program-advertise
{
padding
:
$baseline
;
padding
:
$baseline
;
background-color
:
$body-bg
;
background-color
:
$body-bg
;
...
...
lms/templates/learner_dashboard/certificate.underscore
0 → 100644
View file @
88192fd4
<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>
lms/templates/learner_dashboard/programs.html
View file @
88192fd4
...
@@ -12,7 +12,9 @@ from openedx.core.djangolib.js_utils import (
...
@@ -12,7 +12,9 @@ from openedx.core.djangolib.js_utils import (
<
%
static:require_module
module_name=
"js/learner_dashboard/program_list_factory"
class_name=
"ProgramListFactory"
>
<
%
static:require_module
module_name=
"js/learner_dashboard/program_list_factory"
class_name=
"ProgramListFactory"
>
ProgramListFactory({
ProgramListFactory({
programsData: ${programs | n, dump_js_escaped_json},
programsData: ${programs | n, dump_js_escaped_json},
xseriesUrl: '${xseries_url | n, js_escaped_string}'
certificatesData: ${credentials | n, dump_js_escaped_json},
xseriesUrl: '${xseries_url | n, js_escaped_string}',
xseriesImage: '${static.url('images/xseries-certificate-visual.png')}'
});
});
</
%
static:require
_module
>
</
%
static:require
_module
>
</
%
block>
</
%
block>
...
...
lms/templates/learner_dashboard/sidebar.underscore
View file @
88192fd4
<div class="program-advertise"></div>
<div class="program-advertise"></div>
<div class="certificate
-container
"></div>
<div class="certificate
s-list
"></div>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment