Commit f8be1ed1 by Renzo Lucioni

Merge pull request #12657 from edx/renzo/include-listing-url

Include program listing URL on detail pages
parents d8a8bacd f913cc52
...@@ -284,6 +284,7 @@ class TestProgramDetails(ProgramsApiConfigMixin, SharedModuleStoreTestCase): ...@@ -284,6 +284,7 @@ class TestProgramDetails(ProgramsApiConfigMixin, SharedModuleStoreTestCase):
"""Verify that program data is present.""" """Verify that program data is present."""
self.assertContains(response, 'programData') self.assertContains(response, 'programData')
self.assertContains(response, self.data['name']) self.assertContains(response, self.data['name'])
self.assertContains(response, reverse('program_listing_view'))
def test_login_required(self): def test_login_required(self):
""" """
......
...@@ -3,6 +3,7 @@ from urlparse import urljoin ...@@ -3,6 +3,7 @@ from urlparse import urljoin
from django.conf import settings from django.conf import settings
from django.contrib.auth.decorators import login_required from django.contrib.auth.decorators import login_required
from django.core.urlresolvers import reverse
from django.http import Http404 from django.http import Http404
from django.views.decorators.http import require_GET from django.views.decorators.http import require_GET
...@@ -65,6 +66,7 @@ def program_details(request, program_id): ...@@ -65,6 +66,7 @@ def program_details(request, program_id):
context = { context = {
'program_data': program_data, 'program_data': program_data,
'program_listing_url': reverse('program_listing_view'),
'nav_hidden': True, 'nav_hidden': True,
'disable_courseware_js': True, 'disable_courseware_js': True,
'uses_pattern_library': True 'uses_pattern_library': True
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
], ],
function(ProgramDetailsView) { function(ProgramDetailsView) {
return function (options) { return function (options) {
var ProgramDetails = new ProgramDetailsView(options.programData); var ProgramDetails = new ProgramDetailsView(options);
return ProgramDetails; return ProgramDetails;
}; };
}); });
......
...@@ -30,7 +30,8 @@ ...@@ -30,7 +30,8 @@
tpl: HtmlUtils.template(pageTpl), tpl: HtmlUtils.template(pageTpl),
initialize: function(options) { initialize: function(options) {
this.programModel = new Backbone.Model(options); this.options = options;
this.programModel = new Backbone.Model(this.options.programData);
this.courseCardCollection = new CourseCardCollection( this.courseCardCollection = new CourseCardCollection(
this.programModel.get('course_codes') this.programModel.get('course_codes')
); );
...@@ -44,7 +45,7 @@ ...@@ -44,7 +45,7 @@
postRender: function() { postRender: function() {
this.headerView = new HeaderView({ this.headerView = new HeaderView({
model: this.programModel model: new Backbone.Model(this.options)
}); });
new CollectionListView({ new CollectionListView({
el: '.js-course-list', el: '.js-course-list',
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
breakpoints: this.breakpoints breakpoints: this.breakpoints
}); });
if ( this.model.get('name') ) { if ( this.model.get('programData') ) {
HtmlUtils.setHtml(this.$el, this.tpl(data)); HtmlUtils.setHtml(this.$el, this.tpl(data));
this.postRender(); this.postRender();
} }
......
...@@ -10,30 +10,32 @@ define([ ...@@ -10,30 +10,32 @@ define([
var view = null, var view = null,
programModel, programModel,
context = { context = {
uuid: '12-ab', programListingUrl: '/dashboard/programs',
name: 'Astrophysics', programData: {
subtitle: 'Learn contemporary astrophysics from the leaders in the field.', uuid: '12-ab',
category: 'xseries', name: 'Astrophysics',
organizations: [ subtitle: 'Learn contemporary astrophysics from the leaders in the field.',
{ category: 'xseries',
display_name: 'Australian National University', organizations: [
img: 'common/test/data/static/picture1.jpg', {
key: 'ANUx' display_name: 'Australian National University',
} img: 'common/test/data/static/picture1.jpg',
], key: 'ANUx'
banner_image_urls: { }
w1440h480: 'common/test/data/static/picture1.jpg', ],
w726h242: 'common/test/data/static/picture2.jpg', banner_image_urls: {
w348h116: 'common/test/data/static/picture3.jpg' w1440h480: 'common/test/data/static/picture1.jpg',
}, w726h242: 'common/test/data/static/picture2.jpg',
program_details_url: '/dashboard/programs' w348h116: 'common/test/data/static/picture3.jpg'
},
program_details_url: '/dashboard/programs'
}
}; };
beforeEach(function() { beforeEach(function() {
setFixtures('<div class="js-program-header"></div>'); setFixtures('<div class="js-program-header"></div>');
programModel = new Backbone.Model(context);
view = new ProgramHeaderView({ view = new ProgramHeaderView({
model: programModel model: new Backbone.Model(context)
}); });
view.render(); view.render();
}); });
...@@ -47,11 +49,14 @@ define([ ...@@ -47,11 +49,14 @@ define([
}); });
it('should render the header based on the passed in model', function() { it('should render the header based on the passed in model', function() {
expect(view.$('.title').html()).toEqual(context.name); expect(view.$('.title').html()).toEqual(context.programData.name);
expect(view.$('.subtitle').html()).toEqual(context.subtitle); expect(view.$('.subtitle').html()).toEqual(context.programData.subtitle);
expect(view.$('.org-logo').length).toEqual(context.organizations.length); expect(view.$('.org-logo').length).toEqual(context.programData.organizations.length);
expect(view.$('.org-logo').attr('src')).toEqual(context.organizations[0].img); expect(view.$('.org-logo').attr('src')).toEqual(context.programData.organizations[0].img);
expect(view.$('.org-logo').attr('alt')).toEqual(context.organizations[0].display_name + '\'s logo'); expect(view.$('.org-logo').attr('alt')).toEqual(
context.programData.organizations[0].display_name + '\'s logo'
);
expect(view.$('.breadcrumb').attr('href')).toEqual(context.programListingUrl);
}); });
}); });
} }
......
...@@ -14,7 +14,8 @@ from openedx.core.djangolib.js_utils import ( ...@@ -14,7 +14,8 @@ from openedx.core.djangolib.js_utils import (
<%block name="js_extra"> <%block name="js_extra">
<%static:require_module module_name="js/learner_dashboard/program_details_factory" class_name="ProgramDetailsFactory"> <%static:require_module module_name="js/learner_dashboard/program_details_factory" class_name="ProgramDetailsFactory">
ProgramDetailsFactory({ ProgramDetailsFactory({
programData: ${program_data | n, dump_js_escaped_json} programData: ${program_data | n, dump_js_escaped_json},
programListingUrl: '${program_listing_url | n, js_escaped_string}',
}); });
</%static:require_module> </%static:require_module>
</%block> </%block>
......
<picture> <picture>
<source srcset="<%- banner_image_urls.w1440h480 %>" media="(min-width: <%- breakpoints.min['x-large'] %>)"> <source srcset="<%- programData.banner_image_urls.w1440h480 %>" media="(min-width: <%- breakpoints.min['x-large'] %>)">
<source srcset="<%- banner_image_urls.w726h242 %>" media="(min-width: <%- breakpoints.min.medium %>)"> <source srcset="<%- programData.banner_image_urls.w726h242 %>" media="(min-width: <%- breakpoints.min.medium %>)">
<img class="banner-image" srcset="<%- banner_image_urls.w348h116 %>" alt=""> <img class="banner-image" srcset="<%- programData.banner_image_urls.w348h116 %>" alt="">
</picture> </picture>
<h2 class="hd-2 title"><%- name %></h2> <h2 class="hd-2 title"><%- programData.name %></h2>
<p class="subtitle"><%- subtitle %></p> <p class="subtitle"><%- programData.subtitle %></p>
<a href="/dashboard/programs" class="breadcrumb"><%- gettext('Programs') %></a> <a href="<%- programListingUrl %>" class="breadcrumb"><%- gettext('Programs') %></a>
<span><%- StringUtils.interpolate( <span><%- StringUtils.interpolate(
gettext('{category}\'s program'), gettext('{category} program'),
{category: category} {category: programData.category}
) %></span> ) %></span>
<% _.each(organizations, function(org) { %> <% _.each(programData.organizations, function(org) { %>
<img src="<%- org.img %>" class="org-logo" alt="<%- StringUtils.interpolate( <img src="<%- org.img %>" class="org-logo" alt="<%- StringUtils.interpolate(
gettext('{organization}\'s logo'), gettext('{organization}\'s logo'),
{organization: org.display_name} {organization: org.display_name}
) %>"> ) %>">
<% }) %> <% }) %>
<% if (category === 'xseries') { %> <% if (programData.category === 'xseries') { %>
<p><%- StringUtils.interpolate( <p><%- StringUtils.interpolate(
gettext('To complete the {program} XSeries and earn an XSeries Certificate you must successfully earn a Verified Certificate in all courses shown below.'), gettext('To complete the {program} XSeries and earn an XSeries Certificate you must successfully earn a Verified Certificate in all courses shown below.'),
{program: name} {program: programData.name}
) %></p> ) %></p>
<% } %> <% } %>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment