Skip to content

Commit

Permalink
Merge pull request openedx#6388 from open-craft/content_libraries/11-…
Browse files Browse the repository at this point in the history
…UI-updates

Content libraries UI Updates (SOL-80)
  • Loading branch information
antoviaque committed Jan 8, 2015
2 parents 924a7a0 + b65f158 commit 49c4500
Show file tree
Hide file tree
Showing 40 changed files with 336 additions and 350 deletions.
2 changes: 1 addition & 1 deletion cms/djangoapps/contentstore/features/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def log_into_studio(
world.log_in(username=uname, password=password, email=email, name=name)
# Navigate to the studio dashboard
world.visit('/')
assert_in(uname, world.css_text('h2.title', timeout=10))
assert_in(uname, world.css_text('span.account-username', timeout=10))


def add_course_author(user, course):
Expand Down
10 changes: 6 additions & 4 deletions cms/djangoapps/contentstore/features/courses.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ def i_create_a_course(step):
create_a_course()


@step('I click the course link in My Courses$')
def i_click_the_course_link_in_my_courses(step):
# pylint disable=unused-argument, invalid-name
@step('I click the course link in Studio Home$')
def i_click_the_course_link_in_studio_home(step):
course_css = 'a.course-link'
world.css_click(course_css)

Expand All @@ -52,8 +53,9 @@ def courseware_page_has_loaded_in_studio(step):
assert world.is_css_present(course_title_css)


@step('I see the course listed in My Courses$')
def i_see_the_course_in_my_courses(step):
@step('I see the course listed in Studio Home$')
# pylint disable=unused-argument
def i_see_the_course_in_studio_home(step):
course_css = 'h3.class-title'
assert world.css_has_text(course_css, world.scenario_dict['COURSE'].display_name)

Expand Down
2 changes: 1 addition & 1 deletion cms/djangoapps/contentstore/features/help.feature
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Feature: CMS.Help
Scenario: Users can access online help within a course
Given I have opened a new course in Studio

And I click the course link in My Courses
And I click the course link in Studio Home
Then I should see online help for "outline"

And I go to the course updates page
Expand Down
2 changes: 1 addition & 1 deletion cms/djangoapps/contentstore/features/signup.feature
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ Feature: CMS.Sign in
And I visit the url "/signin?next=http://www.google.com/"
When I fill in and submit the signin form
And I wait for "2" seconds
Then I should see that the path is "/course/"
Then I should see that the path is "/home/"
2 changes: 1 addition & 1 deletion cms/djangoapps/contentstore/features/signup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def i_press_the_button_on_the_registration_form(step):

@step('I should see an email verification prompt')
def i_should_see_an_email_verification_prompt(step):
world.css_has_text('h1.page-header', u'My Courses')
world.css_has_text('h1.page-header', u'Studio Home')
world.css_has_text('div.msg h3.title', u'We need to verify your email address')


Expand Down
11 changes: 5 additions & 6 deletions cms/djangoapps/contentstore/tests/test_contentstore.py
Original file line number Diff line number Diff line change
Expand Up @@ -1166,11 +1166,10 @@ def assert_course_permission_denied(self):

def test_course_index_view_with_no_courses(self):
"""Test viewing the index page with no courses"""
# Create a course so there is something to view
resp = self.client.get_html('/course/')
resp = self.client.get_html('/home/')
self.assertContains(
resp,
'<h1 class="page-header">My Courses</h1>',
'<h1 class="page-header">Studio Home</h1>',
status_code=200,
html=True
)
Expand All @@ -1189,7 +1188,7 @@ def test_item_factory(self):
def test_course_index_view_with_course(self):
"""Test viewing the index page with an existing course"""
CourseFactory.create(display_name='Robot Super Educational Course')
resp = self.client.get_html('/course/')
resp = self.client.get_html('/home/')
self.assertContains(
resp,
'<h3 class="course-title">Robot Super Educational Course</h3>',
Expand Down Expand Up @@ -1604,7 +1603,7 @@ def assertInCourseListing(self, course_key):
Asserts that the given course key is in the accessible course listing section of the html
and NOT in the unsucceeded course action section of the html.
"""
course_listing = lxml.html.fromstring(self.client.get_html('/course/').content)
course_listing = lxml.html.fromstring(self.client.get_html('/home/').content)
self.assertEqual(len(self.get_course_listing_elements(course_listing, course_key)), 1)
self.assertEqual(len(self.get_unsucceeded_course_action_elements(course_listing, course_key)), 0)

Expand All @@ -1613,7 +1612,7 @@ def assertInUnsucceededCourseActions(self, course_key):
Asserts that the given course key is in the unsucceeded course action section of the html
and NOT in the accessible course listing section of the html.
"""
course_listing = lxml.html.fromstring(self.client.get_html('/course/').content)
course_listing = lxml.html.fromstring(self.client.get_html('/home/').content)
self.assertEqual(len(self.get_course_listing_elements(course_listing, course_key)), 0)
self.assertEqual(len(self.get_unsucceeded_course_action_elements(course_listing, course_key)), 1)

Expand Down
10 changes: 5 additions & 5 deletions cms/djangoapps/contentstore/tests/test_i18n.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ def test_course_plain_english(self):
self.client = AjaxEnabledTestClient()
self.client.login(username=self.uname, password=self.password)

resp = self.client.get_html('/course/')
resp = self.client.get_html('/home/')
self.assertContains(resp,
'<h1 class="page-header">My Courses</h1>',
'<h1 class="page-header">Studio Home</h1>',
status_code=200,
html=True)

Expand All @@ -56,13 +56,13 @@ def test_course_explicit_english(self):
self.client.login(username=self.uname, password=self.password)

resp = self.client.get_html(
'/course/',
'/home/',
{},
HTTP_ACCEPT_LANGUAGE='en',
)

self.assertContains(resp,
'<h1 class="page-header">My Courses</h1>',
'<h1 class="page-header">Studio Home</h1>',
status_code=200,
html=True)

Expand All @@ -81,7 +81,7 @@ def test_course_with_accents(self):
self.client.login(username=self.uname, password=self.password)

resp = self.client.get_html(
'/course/',
'/home/',
{},
HTTP_ACCEPT_LANGUAGE='eo'
)
Expand Down
10 changes: 5 additions & 5 deletions cms/djangoapps/contentstore/tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,13 +234,13 @@ def test_login_link_on_activation_age(self):
def test_private_pages_auth(self):
"""Make sure pages that do require login work."""
auth_pages = (
'/course/',
'/home/',
)

# These are pages that should just load when the user is logged in
# (no data needed)
simple_auth_pages = (
'/course/',
'/home/',
)

# need an activated user
Expand All @@ -266,7 +266,7 @@ def test_private_pages_auth(self):
def test_index_auth(self):

# not logged in. Should return a redirect.
resp = self.client.get_html('/course/')
resp = self.client.get_html('/home/')
self.assertEqual(resp.status_code, 302)

# Logged in should work.
Expand All @@ -283,7 +283,7 @@ def test_inactive_session_timeout(self):
self.login(self.email, self.pw)

# make sure we can access courseware immediately
course_url = '/course/'
course_url = '/home/'
resp = self.client.get_html(course_url)
self.assertEquals(resp.status_code, 200)

Expand All @@ -293,7 +293,7 @@ def test_inactive_session_timeout(self):
resp = self.client.get_html(course_url)

# re-request, and we should get a redirect to login page
self.assertRedirects(resp, settings.LOGIN_REDIRECT_URL + '?next=/course/')
self.assertRedirects(resp, settings.LOGIN_REDIRECT_URL + '?next=/home/')


class ForumTestCase(CourseTestCase):
Expand Down
6 changes: 4 additions & 2 deletions cms/djangoapps/contentstore/views/course.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Views related to operations on course objects
"""
from django.shortcuts import redirect
import json
import random
import string # pylint: disable=deprecated-module
Expand Down Expand Up @@ -71,7 +72,8 @@
from xmodule.course_module import CourseFields


__all__ = ['course_info_handler', 'course_handler', 'course_info_update_handler',
__all__ = ['course_info_handler', 'course_handler', 'course_listing',
'course_info_update_handler',
'course_rerun_handler',
'settings_handler',
'grading_handler',
Expand Down Expand Up @@ -230,7 +232,7 @@ def course_handler(request, course_key_string=None):
return HttpResponseBadRequest()
elif request.method == 'GET': # assume html
if course_key_string is None:
return course_listing(request)
return redirect(reverse("home"))
else:
return course_index(request, CourseKey.from_string(course_key_string))
else:
Expand Down
2 changes: 1 addition & 1 deletion cms/djangoapps/contentstore/views/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def _create_library(request):
'ErrMsg': _(
'There is already a library defined with the same '
'organization and library code. Please '
'change either organization or library code to be unique.'
'change your library code so that it is unique within your organization.'
)
})

Expand Down
2 changes: 1 addition & 1 deletion cms/djangoapps/contentstore/views/public.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,6 @@ def login_page(request):
def howitworks(request):
"Proxy view"
if request.user.is_authenticated():
return redirect('/course/')
return redirect('/home/')
else:
return render_to_response('howitworks.html', {})
4 changes: 2 additions & 2 deletions cms/djangoapps/contentstore/views/tests/test_course_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def check_index_and_outline(self, authed_client):
"""
Test getting the list of courses and then pulling up their outlines
"""
index_url = '/course/'
index_url = '/home/'
index_response = authed_client.get(index_url, {}, HTTP_ACCEPT='text/html')
parsed_html = lxml.html.fromstring(index_response.content)
course_link_eles = parsed_html.find_class('course-link')
Expand All @@ -68,7 +68,7 @@ def test_libraries_on_course_index(self):
# Add a library:
lib1 = LibraryFactory.create()

index_url = '/course/'
index_url = '/home/'
index_response = self.client.get(index_url, {}, HTTP_ACCEPT='text/html')
parsed_html = lxml.html.fromstring(index_response.content)
library_link_elements = parsed_html.find_class('library-link')
Expand Down
22 changes: 11 additions & 11 deletions cms/static/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ define(["domReady", "jquery", "underscore", "js/utils/cancel_on_escape", "js/vie
"js/views/utils/create_library_utils", "js/views/utils/view_utils"],
function (domReady, $, _, CancelOnEscape, CreateCourseUtilsFactory, CreateLibraryUtilsFactory, ViewUtils) {
"use strict";
var CreateCourseUtils = CreateCourseUtilsFactory({
var CreateCourseUtils = new CreateCourseUtilsFactory({
name: '.new-course-name',
org: '.new-course-org',
number: '.new-course-number',
Expand All @@ -21,7 +21,7 @@ define(["domReady", "jquery", "underscore", "js/utils/cancel_on_escape", "js/vie
error: 'error'
});

var CreateLibraryUtils = CreateLibraryUtilsFactory({
var CreateLibraryUtils = new CreateLibraryUtilsFactory({
name: '.new-library-name',
org: '.new-library-org',
number: '.new-library-number',
Expand Down Expand Up @@ -60,17 +60,17 @@ define(["domReady", "jquery", "underscore", "js/utils/cancel_on_escape", "js/vie
};

analytics.track('Created a Course', course_info);
CreateCourseUtils.createCourse(course_info, function (errorMessage) {
CreateCourseUtils.create(course_info, function (errorMessage) {
$('.create-course .wrap-error').addClass('is-shown');
$('#course_creation_error').html('<p>' + errorMessage + '</p>');
$('.new-course-save').addClass('is-disabled');
$('.new-course-save').addClass('is-disabled').attr('aria-disabled', true);
});
};

var makeCancelHandler = function (addType) {
return function(e) {
e.preventDefault();
$('.new-'+addType+'-button').removeClass('is-disabled');
$('.new-'+addType+'-button').removeClass('is-disabled').attr('aria-disabled', false);
$('.wrapper-create-'+addType).removeClass('is-shown');
// Clear out existing fields and errors
$('#create-'+addType+'-form input[type=text]').val('');
Expand All @@ -82,8 +82,8 @@ define(["domReady", "jquery", "underscore", "js/utils/cancel_on_escape", "js/vie

var addNewCourse = function (e) {
e.preventDefault();
$('.new-course-button').addClass('is-disabled');
$('.new-course-save').addClass('is-disabled');
$('.new-course-button').addClass('is-disabled').attr('aria-disabled', true);
$('.new-course-save').addClass('is-disabled').attr('aria-disabled', true);
var $newCourse = $('.wrapper-create-course').addClass('is-shown');
var $cancelButton = $newCourse.find('.new-course-cancel');
var $courseName = $('.new-course-name');
Expand Down Expand Up @@ -114,17 +114,17 @@ define(["domReady", "jquery", "underscore", "js/utils/cancel_on_escape", "js/vie
};

analytics.track('Created a Library', lib_info);
CreateLibraryUtils.createLibrary(lib_info, function (errorMessage) {
CreateLibraryUtils.create(lib_info, function (errorMessage) {
$('.create-library .wrap-error').addClass('is-shown');
$('#library_creation_error').html('<p>' + errorMessage + '</p>');
$('.new-library-save').addClass('is-disabled');
$('.new-library-save').addClass('is-disabled').attr('aria-disabled', true);
});
};

var addNewLibrary = function (e) {
e.preventDefault();
$('.new-library-button').addClass('is-disabled');
$('.new-library-save').addClass('is-disabled');
$('.new-library-button').addClass('is-disabled').attr('aria-disabled', true);
$('.new-library-save').addClass('is-disabled').attr('aria-disabled', true);
var $newLibrary = $('.wrapper-create-library').addClass('is-shown');
var $cancelButton = $newLibrary.find('.new-library-cancel');
var $libraryName = $('.new-library-name');
Expand Down
9 changes: 9 additions & 0 deletions cms/static/js/spec/views/pages/container_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,15 @@ define(["jquery", "underscore", "underscore.string", "js/common_helpers/ajax_hel
containerPage.$(".new-component .new-component-type a.single-template")[index].click();
};

it('Attaches a handler to new component button', function() {
containerPage = getContainerPage();
containerPage.render();
// Stub jQuery.scrollTo module.
$.scrollTo = jasmine.createSpy('jQuery.scrollTo');
containerPage.$('.new-component-button').click();
expect($.scrollTo).toHaveBeenCalled();
});

it('sends the correct JSON to the server', function () {
renderContainerPage(this, mockContainerXBlockHtml);
clickNewComponent(0);
Expand Down
4 changes: 2 additions & 2 deletions cms/static/js/spec/views/pages/course_rerun_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ define(["jquery", "js/common_helpers/ajax_helpers", "js/spec_helpers/view_helper
},
mockCreateCourseRerunHTML = readFixtures('mock/mock-create-course-rerun.underscore');

var CreateCourseUtils = CreateCourseUtilsFactory(selectors, classes);
var CreateCourseUtils = new CreateCourseUtilsFactory(selectors, classes);

var fillInFields = function (org, number, run, name) {
$(selectors.org).val(org);
Expand Down Expand Up @@ -62,7 +62,7 @@ define(["jquery", "js/common_helpers/ajax_helpers", "js/spec_helpers/view_helper
describe("Error messages", function () {
var setErrorMessage = function(selector, message) {
var element = $(selector).parent();
CreateCourseUtils.setNewCourseFieldInErr(element, message);
CreateCourseUtils.setFieldInErr(element, message);
return element;
};

Expand Down
3 changes: 3 additions & 0 deletions cms/static/js/spec/views/pages/index_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ define(["jquery", "js/common_helpers/ajax_helpers", "js/spec_helpers/view_helper
expect($('.create-course .wrap-error')).toHaveClass('is-shown');
expect($('#course_creation_error')).toContainText('error message');
expect($('.new-course-save')).toHaveClass('is-disabled');
expect($('.new-course-save')).toHaveAttr('aria-disabled', 'true');
});

it("saves new libraries", function () {
Expand Down Expand Up @@ -97,6 +98,7 @@ define(["jquery", "js/common_helpers/ajax_helpers", "js/spec_helpers/view_helper
fillInLibraryFields.apply(this, values_with_blank);
expect($('.create-library li.field.text input[value=]').parent()).toHaveClass('error');
expect($('.new-library-save')).toHaveClass('is-disabled');
expect($('.new-library-save')).toHaveAttr('aria-disabled', 'true');
$('.new-library-save').click();
expect(requests.length).toEqual(requests_count); // Expect no new requests
}
Expand All @@ -123,6 +125,7 @@ define(["jquery", "js/common_helpers/ajax_helpers", "js/spec_helpers/view_helper
expect($('.create-library .wrap-error')).toHaveClass('is-shown');
expect($('#library_creation_error')).toContainText('error message');
expect($('.new-library-save')).toHaveClass('is-disabled');
expect($('.new-library-save')).toHaveAttr('aria-disabled', 'true');
});

it("can switch tabs", function() {
Expand Down
4 changes: 2 additions & 2 deletions cms/static/js/views/course_rerun.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
define(["domReady", "jquery", "underscore", "js/views/utils/create_course_utils", "js/views/utils/view_utils"],
function (domReady, $, _, CreateCourseUtilsFactory, ViewUtils) {
var CreateCourseUtils = CreateCourseUtilsFactory({
var CreateCourseUtils = new CreateCourseUtilsFactory({
name: '.rerun-course-name',
org: '.rerun-course-org',
number: '.rerun-course-number',
Expand Down Expand Up @@ -41,7 +41,7 @@ define(["domReady", "jquery", "underscore", "js/views/utils/create_course_utils"
};

analytics.track('Reran a Course', course_info);
CreateCourseUtils.createCourse(course_info, function (errorMessage) {
CreateCourseUtils.create(course_info, function (errorMessage) {
$('.wrapper-error').addClass('is-shown').removeClass('is-hidden');
$('#course_rerun_error').html('<p>' + errorMessage + '</p>');
$('.rerun-course-save').addClass('is-disabled').removeClass('is-processing').html(gettext('Create Re-run'));
Expand Down
Loading

0 comments on commit 49c4500

Please sign in to comment.