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
7506562f
Commit
7506562f
authored
Jul 02, 2013
by
David Baumgold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Another lettuce test, and fixes to make it work
parent
ca2339f1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
78 additions
and
10 deletions
+78
-10
cms/djangoapps/contentstore/features/textbooks.feature
+27
-0
cms/djangoapps/contentstore/features/textbooks.py
+48
-7
cms/djangoapps/contentstore/views/course.py
+2
-2
cms/static/js/models/textbook.js
+1
-1
No files found.
cms/djangoapps/contentstore/features/textbooks.feature
View file @
7506562f
...
@@ -18,3 +18,30 @@ Feature: Textbooks
...
@@ -18,3 +18,30 @@ Feature: Textbooks
Then
I should see a textbook named
"Economics"
with a chapter path containing
"/c4x/MITx/999/asset/textbook.pdf"
Then
I should see a textbook named
"Economics"
with a chapter path containing
"/c4x/MITx/999/asset/textbook.pdf"
And
I reload the page
And
I reload the page
Then
I should see a textbook named
"Economics"
with a chapter path containing
"/c4x/MITx/999/asset/textbook.pdf"
Then
I should see a textbook named
"Economics"
with a chapter path containing
"/c4x/MITx/999/asset/textbook.pdf"
Scenario
:
Create a textbook with multiple chapters
Given
I have opened a new course in Studio
And
I go to the textbooks page
When
I click on the New Textbook button
And
I name my textbook
"History"
And
I name the first chapter
"Britain"
And
I type in
"britain.pdf"
for the first chapter asset
And
I click Add a Chapter
And
I name the second chapter
"America"
And
I type in
"america.pdf"
for the second chapter asset
And
I save the textbook
Then
I should see a textbook named
"History"
with 2 chapters
And
I click the textbook chapters
Then
I should see a textbook named
"History"
with 2 chapters
And
the first chapter should be named
"Britain"
And
the first chapter should have an asset called
"britain.pdf"
And
the second chapter should be named
"America"
And
the second chapter should have an asset called
"america.pdf"
And
I reload the page
Then
I should see a textbook named
"History"
with 2 chapters
And
I click the textbook chapters
Then
I should see a textbook named
"History"
with 2 chapters
And
the first chapter should be named
"Britain"
And
the first chapter should have an asset called
"britain.pdf"
And
the second chapter should be named
"America"
And
the second chapter should have an asset called
"america.pdf"
cms/djangoapps/contentstore/features/textbooks.py
View file @
7506562f
...
@@ -42,14 +42,27 @@ def name_textbook(_step, name):
...
@@ -42,14 +42,27 @@ def name_textbook(_step, name):
input_css
=
".textbook input[name=textbook-name]"
input_css
=
".textbook input[name=textbook-name]"
world
.
css_fill
(
input_css
,
name
)
world
.
css_fill
(
input_css
,
name
)
@step
(
u'I name the first chapter "([^"]*)"'
)
@step
(
u'I name the (first|second|third) chapter "([^"]*)"'
)
def
name_chapter
(
_step
,
name
):
def
name_chapter
(
_step
,
ordinal
,
name
):
input_css
=
".textbook input.chapter-name"
index
=
[
"first"
,
"second"
,
"third"
]
.
index
(
ordinal
)
input_css
=
".textbook .chapter{i} input.chapter-name"
.
format
(
i
=
index
+
1
)
world
.
css_fill
(
input_css
,
name
)
world
.
css_fill
(
input_css
,
name
)
@step
(
u'I click the Upload Asset link for the first chapter'
)
@step
(
u'I type in "([^"]*)" for the (first|second|third) chapter asset'
)
def
click_upload_asset
(
_step
):
def
asset_chapter
(
_step
,
name
,
ordinal
):
button_css
=
".chapter .action-upload"
index
=
[
"first"
,
"second"
,
"third"
]
.
index
(
ordinal
)
input_css
=
".textbook .chapter{i} input.chapter-asset-path"
.
format
(
i
=
index
+
1
)
world
.
css_fill
(
input_css
,
name
)
@step
(
u'I click the Upload Asset link for the (first|second|third) chapter'
)
def
click_upload_asset
(
_step
,
ordinal
):
index
=
[
"first"
,
"second"
,
"third"
]
.
index
(
ordinal
)
button_css
=
".textbook .chapter{i} .action-upload"
.
format
(
i
=
index
+
1
)
world
.
css_click
(
button_css
)
@step
(
u'I click Add a Chapter'
)
def
click_add_chapter
(
_step
):
button_css
=
".textbook .action-add-chapter"
world
.
css_click
(
button_css
)
world
.
css_click
(
button_css
)
@step
(
u'I save the textbook'
)
@step
(
u'I save the textbook'
)
...
@@ -58,9 +71,37 @@ def save_textbook(_step):
...
@@ -58,9 +71,37 @@ def save_textbook(_step):
world
.
css_click
(
submit_css
)
world
.
css_click
(
submit_css
)
@step
(
u'I should see a textbook named "([^"]*)" with a chapter path containing "([^"]*)"'
)
@step
(
u'I should see a textbook named "([^"]*)" with a chapter path containing "([^"]*)"'
)
def
check_textbook
(
step
,
textbook_name
,
chapter_name
):
def
check_textbook
(
_
step
,
textbook_name
,
chapter_name
):
title
=
world
.
css_find
(
".textbook h3.textbook-title"
)
title
=
world
.
css_find
(
".textbook h3.textbook-title"
)
chapter
=
world
.
css_find
(
".textbook .wrap-textbook p"
)
chapter
=
world
.
css_find
(
".textbook .wrap-textbook p"
)
assert
title
.
text
==
textbook_name
,
"{} != {}"
.
format
(
title
.
text
,
textbook_name
)
assert
title
.
text
==
textbook_name
,
"{} != {}"
.
format
(
title
.
text
,
textbook_name
)
assert
chapter
.
text
==
chapter_name
,
"{} != {}"
.
format
(
chapter
.
text
,
chapter_name
)
assert
chapter
.
text
==
chapter_name
,
"{} != {}"
.
format
(
chapter
.
text
,
chapter_name
)
@step
(
u'I should see a textbook named "([^"]*)" with (
\
d+) chapters'
)
def
check_textbook
(
_step
,
textbook_name
,
num_chapters_str
):
num_chapters
=
int
(
num_chapters_str
)
title
=
world
.
css_find
(
".textbook .view-textbook h3.textbook-title"
)
toggle
=
world
.
css_find
(
".textbook .view-textbook .chapter-toggle"
)
assert
title
.
text
==
textbook_name
,
"{} != {}"
.
format
(
title
.
text
,
textbook_name
)
assert
toggle
.
text
==
"{num} PDF Chapters"
.
format
(
num
=
num_chapters
),
\
"Expected {num} chapters, found {real}"
.
format
(
num
=
num_chapters
,
real
=
toggle
.
text
)
@step
(
u'I click the textbook chapters'
)
def
click_chapters
(
_step
):
world
.
css_click
(
".textbook a.chapter-toggle"
)
@step
(
u'the (first|second|third) chapter should be named "([^"]*)"'
)
def
check_chapter_name
(
_step
,
ordinal
,
name
):
index
=
[
"first"
,
"second"
,
"third"
]
.
index
(
ordinal
)
chapter
=
world
.
css_find
(
".textbook .view-textbook ol.chapters li"
)[
index
]
element
=
chapter
.
find_by_css
(
".chapter-name"
)
assert
element
.
text
==
name
,
"Expected chapter named {expected}, found chapter named {actual}"
.
format
(
expected
=
name
,
actual
=
element
.
text
)
@step
(
u'the (first|second|third) chapter should have an asset called "([^"]*)"'
)
def
check_chapter_name
(
_step
,
ordinal
,
name
):
index
=
[
"first"
,
"second"
,
"third"
]
.
index
(
ordinal
)
chapter
=
world
.
css_find
(
".textbook .view-textbook ol.chapters li"
)[
index
]
element
=
chapter
.
find_by_css
(
".chapter-asset-path"
)
assert
element
.
text
==
name
,
"Expected chapter with asset {expected}, found chapter with asset {actual}"
.
format
(
expected
=
name
,
actual
=
element
.
text
)
cms/djangoapps/contentstore/views/course.py
View file @
7506562f
...
@@ -543,7 +543,7 @@ def create_textbook(request, org, course, name):
...
@@ -543,7 +543,7 @@ def create_textbook(request, org, course, name):
@login_required
@login_required
@ensure_csrf_cookie
@ensure_csrf_cookie
@require_http_methods
((
"GET"
,
"POST"
,
"DELETE"
))
@require_http_methods
((
"GET"
,
"POST"
,
"
PUT"
,
"
DELETE"
))
def
textbook_by_id
(
request
,
org
,
course
,
name
,
tid
):
def
textbook_by_id
(
request
,
org
,
course
,
name
,
tid
):
"""
"""
JSON API endpoint for manipulating a textbook via its internal ID.
JSON API endpoint for manipulating a textbook via its internal ID.
...
@@ -563,7 +563,7 @@ def textbook_by_id(request, org, course, name, tid):
...
@@ -563,7 +563,7 @@ def textbook_by_id(request, org, course, name, tid):
if
not
textbook
:
if
not
textbook
:
return
JsonResponse
(
status
=
404
)
return
JsonResponse
(
status
=
404
)
return
JsonResponse
(
textbook
)
return
JsonResponse
(
textbook
)
elif
request
.
method
==
'POST'
:
elif
request
.
method
in
(
'POST'
,
'PUT'
)
:
try
:
try
:
new_textbook
=
validate_textbook_json
(
request
.
body
)
new_textbook
=
validate_textbook_json
(
request
.
body
)
except
TextbookValidationError
as
e
:
except
TextbookValidationError
as
e
:
...
...
cms/static/js/models/textbook.js
View file @
7506562f
...
@@ -85,7 +85,7 @@ CMS.Models.Textbook = Backbone.AssociatedModel.extend({
...
@@ -85,7 +85,7 @@ CMS.Models.Textbook = Backbone.AssociatedModel.extend({
invalidChapters
.
push
(
chapter
);
invalidChapters
.
push
(
chapter
);
}
}
});
});
if
(
invalidChapters
)
{
if
(
!
_
.
isEmpty
(
invalidChapters
)
)
{
return
{
return
{
message
:
"All chapters must have a name and asset"
,
message
:
"All chapters must have a name and asset"
,
attributes
:
{
chapters
:
invalidChapters
}
attributes
:
{
chapters
:
invalidChapters
}
...
...
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