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
ce57700d
Commit
ce57700d
authored
Jan 21, 2016
by
muhammad-ammar
Committed by
muzaffaryousaf
Feb 24, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
hide paging footer when only one page
parent
71ec1b94
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
100 additions
and
32 deletions
+100
-32
common/test/acceptance/pages/common/paging.py
+5
-0
common/test/acceptance/tests/lms/test_lms_edxnotes.py
+14
-9
lms/djangoapps/edxnotes/helpers.py
+5
-5
lms/djangoapps/edxnotes/tests.py
+53
-0
lms/static/js/edxnotes/views/notes_page.js
+3
-1
lms/static/js/edxnotes/views/page_factory.js
+0
-1
lms/static/js/edxnotes/views/tab_panel.js
+1
-1
lms/static/js/spec/edxnotes/helpers.js
+6
-3
lms/static/js/spec/edxnotes/views/tabs/recent_activity_spec.js
+7
-6
lms/static/js/spec/edxnotes/views/tabs/search_results_spec.js
+6
-6
No files found.
common/test/acceptance/pages/common/paging.py
View file @
ce57700d
...
...
@@ -63,3 +63,8 @@ class PaginatedUIMixin(object):
def
is_enabled
(
self
,
css
):
"""Return whether the given element is not disabled."""
return
'is-disabled'
not
in
self
.
q
(
css
=
css
)
.
attrs
(
'class'
)[
0
]
@property
def
footer_visible
(
self
):
""" Return True if footer is visible else False"""
return
self
.
q
(
css
=
'.pagination.bottom'
)
.
visible
common/test/acceptance/tests/lms/test_lms_edxnotes.py
View file @
ce57700d
...
...
@@ -401,7 +401,7 @@ class EdxNotesPageTest(EventsTestMixin, EdxNotesTestMixin):
updated
=
datetime
(
2015
,
1
,
1
,
1
,
1
,
1
,
1
)
.
isoformat
()
),
]
if
extra_notes
and
isinstance
(
extra_notes
,
int
)
:
if
extra_notes
>
0
:
for
__
in
range
(
extra_notes
):
self
.
raw_note_list
.
append
(
Note
(
...
...
@@ -499,10 +499,15 @@ class EdxNotesPageTest(EventsTestMixin, EdxNotesTestMixin):
"""
self
.
assertEqual
(
self
.
notes_page
.
count
(),
notes_count_on_current_page
)
self
.
assertEqual
(
self
.
notes_page
.
get_pagination_header_text
(),
header_text
)
self
.
assertEqual
(
self
.
notes_page
.
is_previous_page_button_enabled
(),
previous_button_enabled
)
self
.
assertEqual
(
self
.
notes_page
.
is_next_page_button_enabled
(),
next_button_enabled
)
self
.
assertEqual
(
self
.
notes_page
.
get_current_page_number
(),
current_page_number
)
self
.
assertEqual
(
self
.
notes_page
.
get_total_pages
,
total_pages
)
if
total_pages
>
1
:
self
.
assertEqual
(
self
.
notes_page
.
footer_visible
,
True
)
self
.
assertEqual
(
self
.
notes_page
.
is_previous_page_button_enabled
(),
previous_button_enabled
)
self
.
assertEqual
(
self
.
notes_page
.
is_next_page_button_enabled
(),
next_button_enabled
)
self
.
assertEqual
(
self
.
notes_page
.
get_current_page_number
(),
current_page_number
)
self
.
assertEqual
(
self
.
notes_page
.
get_total_pages
,
total_pages
)
else
:
self
.
assertEqual
(
self
.
notes_page
.
footer_visible
,
False
)
def
search_and_verify
(
self
):
"""
...
...
@@ -899,7 +904,7 @@ class EdxNotesPageTest(EventsTestMixin, EdxNotesTestMixin):
self
.
assert_viewed_event
(
'Search Results'
)
self
.
assert_search_event
(
'note'
,
4
)
@skip
(
"scroll to tag functionality is
remov
ed"
)
@skip
(
"scroll to tag functionality is
disabl
ed"
)
def
test_scroll_to_tag_recent_activity
(
self
):
"""
Scenario: Can scroll to a tag group from the Recent Activity view (default view)
...
...
@@ -911,7 +916,7 @@ class EdxNotesPageTest(EventsTestMixin, EdxNotesTestMixin):
self
.
notes_page
.
visit
()
self
.
_scroll_to_tag_and_verify
(
"pear"
,
3
)
@skip
(
"scroll to tag functionality is
remov
ed"
)
@skip
(
"scroll to tag functionality is
disabl
ed"
)
def
test_scroll_to_tag_course_structure
(
self
):
"""
Scenario: Can scroll to a tag group from the Course Structure view
...
...
@@ -923,7 +928,7 @@ class EdxNotesPageTest(EventsTestMixin, EdxNotesTestMixin):
self
.
notes_page
.
visit
()
.
switch_to_tab
(
"structure"
)
self
.
_scroll_to_tag_and_verify
(
"squash"
,
5
)
@skip
(
"scroll to tag functionality is
remov
ed"
)
@skip
(
"scroll to tag functionality is
disabl
ed"
)
def
test_scroll_to_tag_search
(
self
):
"""
Scenario: Can scroll to a tag group from the Search Results view
...
...
@@ -936,7 +941,7 @@ class EdxNotesPageTest(EventsTestMixin, EdxNotesTestMixin):
self
.
notes_page
.
visit
()
.
search
(
"note"
)
self
.
_scroll_to_tag_and_verify
(
"pumpkin"
,
4
)
@skip
(
"scroll to tag functionality is
remov
ed"
)
@skip
(
"scroll to tag functionality is
disabl
ed"
)
def
test_scroll_to_tag_from_tag_view
(
self
):
"""
Scenario: Can scroll to a tag group from the Tags view
...
...
lms/djangoapps/edxnotes/helpers.py
View file @
ce57700d
...
...
@@ -137,7 +137,7 @@ def preprocess_collection(user, course, collection):
store
=
modulestore
()
filtered_collection
=
list
()
cache
=
{}
include_
extra_info
=
settings
.
NOTES_DISABLED_TABS
==
[]
include_
path_info
=
(
'course_structure'
not
in
settings
.
NOTES_DISABLED_TABS
)
with
store
.
bulk_operations
(
course
.
id
):
for
model
in
collection
:
update
=
{
...
...
@@ -170,7 +170,7 @@ def preprocess_collection(user, course, collection):
log
.
debug
(
"Unit not found:
%
s"
,
usage_key
)
continue
if
include_
extra
_info
:
if
include_
path
_info
:
section
=
unit
.
get_parent
()
if
not
section
:
log
.
debug
(
"Section not found:
%
s"
,
usage_key
)
...
...
@@ -202,11 +202,11 @@ def preprocess_collection(user, course, collection):
usage_context
=
{
"unit"
:
get_module_context
(
course
,
unit
),
"section"
:
get_module_context
(
course
,
section
)
if
include_
extra
_info
else
{},
"chapter"
:
get_module_context
(
course
,
chapter
)
if
include_
extra
_info
else
{},
"section"
:
get_module_context
(
course
,
section
)
if
include_
path
_info
else
{},
"chapter"
:
get_module_context
(
course
,
chapter
)
if
include_
path
_info
else
{},
}
model
.
update
(
usage_context
)
if
include_
extra
_info
:
if
include_
path
_info
:
cache
[
section
]
=
cache
[
chapter
]
=
usage_context
cache
[
usage_id
]
=
cache
[
unit
]
=
usage_context
...
...
lms/djangoapps/edxnotes/tests.py
View file @
ce57700d
...
...
@@ -637,6 +637,59 @@ class EdxNotesHelpersTest(ModuleStoreTestCase):
[],
helpers
.
preprocess_collection
(
self
.
user
,
self
.
course
,
initial_collection
)
)
@override_settings
(
NOTES_DISABLED_TABS
=
[
'course_structure'
,
'tags'
])
def
test_preprocess_collection_with_disabled_tabs
(
self
,
):
"""
Tests that preprocess collection returns correct data if `course_structure` and `tags` are disabled.
"""
initial_collection
=
[
{
u"quote"
:
u"quote text1"
,
u"text"
:
u"text1"
,
u"usage_id"
:
unicode
(
self
.
html_module_1
.
location
),
u"updated"
:
datetime
(
2016
,
01
,
26
,
8
,
5
,
16
,
00000
)
.
isoformat
(),
},
{
u"quote"
:
u"quote text2"
,
u"text"
:
u"text2"
,
u"usage_id"
:
unicode
(
self
.
html_module_2
.
location
),
u"updated"
:
datetime
(
2016
,
01
,
26
,
9
,
6
,
17
,
00000
)
.
isoformat
(),
},
]
self
.
assertItemsEqual
(
[
{
'section'
:
{},
'chapter'
:
{},
"unit"
:
{
u"url"
:
self
.
_get_unit_url
(
self
.
course
,
self
.
chapter
,
self
.
sequential
),
u"display_name"
:
self
.
vertical
.
display_name_with_default_escaped
,
u"location"
:
unicode
(
self
.
vertical
.
location
),
},
u'text'
:
u'text1'
,
u'quote'
:
u'quote text1'
,
u'usage_id'
:
unicode
(
self
.
html_module_1
.
location
),
u'updated'
:
datetime
(
2016
,
01
,
26
,
8
,
5
,
16
)
},
{
'section'
:
{},
'chapter'
:
{},
"unit"
:
{
u"url"
:
self
.
_get_unit_url
(
self
.
course
,
self
.
chapter
,
self
.
sequential
),
u"display_name"
:
self
.
vertical
.
display_name_with_default_escaped
,
u"location"
:
unicode
(
self
.
vertical
.
location
),
},
u'text'
:
u'text2'
,
u'quote'
:
u'quote text2'
,
u'usage_id'
:
unicode
(
self
.
html_module_2
.
location
),
u'updated'
:
datetime
(
2016
,
01
,
26
,
9
,
6
,
17
)
}
],
helpers
.
preprocess_collection
(
self
.
user
,
self
.
course
,
initial_collection
)
)
def
test_get_parent_unit
(
self
):
"""
Tests `get_parent_unit` method for the successful result.
...
...
lms/static/js/edxnotes/views/notes_page.js
View file @
ce57700d
...
...
@@ -43,7 +43,9 @@ define([
tabsCollection
:
this
.
tabsCollection
,
scrollToTag
:
scrollToTag
});
}
if
(
!
_
.
contains
(
this
.
options
.
disabledTabs
,
'tags'
))
{
// Add the Tags model after the Course Structure model.
this
.
tabsCollection
.
push
(
tagsModel
);
}
...
...
lms/static/js/edxnotes/views/page_factory.js
View file @
ce57700d
...
...
@@ -27,7 +27,6 @@ define([
el
:
$
(
'.wrapper-student-notes'
).
get
(
0
),
collection
:
collection
,
debug
:
params
.
debugMode
,
endpoint
:
params
.
endpoint
,
perPage
:
params
.
pageSize
,
disabledTabs
:
params
.
disabledTabs
});
...
...
lms/static/js/edxnotes/views/tab_panel.js
View file @
ce57700d
...
...
@@ -16,7 +16,7 @@ function (gettext, _, Backbone, NoteItemView, PagingHeaderView, PagingFooterView
this
.
children
=
[];
if
(
this
.
options
.
createHeaderFooter
)
{
this
.
pagingHeaderView
=
new
PagingHeaderView
({
collection
:
this
.
collection
});
this
.
pagingFooterView
=
new
PagingFooterView
({
collection
:
this
.
collection
});
this
.
pagingFooterView
=
new
PagingFooterView
({
collection
:
this
.
collection
,
hideWhenOnePage
:
true
});
}
if
(
this
.
hasOwnProperty
(
'collection'
))
{
this
.
listenTo
(
this
.
collection
,
'page_changed'
,
this
.
render
);
...
...
lms/static/js/spec/edxnotes/helpers.js
View file @
ce57700d
...
...
@@ -218,10 +218,13 @@ define(['underscore', 'URI', 'common/js/spec_helpers/ajax_helpers'], function(_,
AjaxHelpers
.
respondWithJson
(
requests
,
responseJson
);
};
verifyPaginationInfo
=
function
(
view
,
headerMessage
,
currentPage
,
totalPages
)
{
verifyPaginationInfo
=
function
(
view
,
headerMessage
,
footerHidden
,
currentPage
,
totalPages
)
{
expect
(
view
.
$
(
'.search-count.listing-count'
).
text
().
trim
()).
toBe
(
headerMessage
);
expect
(
parseInt
(
view
.
$
(
'.pagination span.current-page'
).
text
().
trim
())).
toBe
(
currentPage
);
expect
(
parseInt
(
view
.
$
(
'.pagination span.total-pages'
).
text
().
trim
())).
toBe
(
totalPages
);
expect
(
view
.
$
(
'.pagination.bottom'
).
parent
().
hasClass
(
'hidden'
)).
toBe
(
footerHidden
);
if
(
!
footerHidden
)
{
expect
(
parseInt
(
view
.
$
(
'.pagination span.current-page'
).
text
().
trim
())).
toBe
(
currentPage
);
expect
(
parseInt
(
view
.
$
(
'.pagination span.total-pages'
).
text
().
trim
())).
toBe
(
totalPages
);
}
};
verifyPageData
=
function
(
view
,
tabsCollection
,
tabInfo
,
tabId
,
notes
)
{
...
...
lms/static/js/spec/edxnotes/views/tabs/recent_activity_spec.js
View file @
ce57700d
...
...
@@ -76,7 +76,7 @@ define([
it
(
'displays a tab and content with proper data and order'
,
function
()
{
var
view
=
getView
(
this
.
collection
,
this
.
tabsCollection
);
Helpers
.
verifyPaginationInfo
(
view
,
"Showing 1-3 out of 3 total"
,
1
,
1
);
Helpers
.
verifyPaginationInfo
(
view
,
"Showing 1-3 out of 3 total"
,
true
,
1
,
1
);
Helpers
.
verifyPageData
(
view
,
this
.
tabsCollection
,
tabInfo
,
recentActivityTabId
,
notes
);
});
...
...
@@ -107,10 +107,11 @@ define([
start
:
0
}
);
var
collection
=
new
NotesCollection
(
notes
,
{
perPage
:
10
,
parse
:
true
});
var
view
=
getView
(
collection
,
this
.
tabsCollection
);
Helpers
.
verifyPaginationInfo
(
view
,
"Showing 1-10 out of 12 total"
,
1
,
2
);
Helpers
.
verifyPaginationInfo
(
view
,
"Showing 1-10 out of 12 total"
,
false
,
1
,
2
);
Helpers
.
verifyPageData
(
view
,
this
.
tabsCollection
,
tabInfo
,
recentActivityTabId
,
notes
);
view
.
$
(
'input#page-number-input'
).
val
(
'2'
);
...
...
@@ -130,7 +131,7 @@ define([
}
);
Helpers
.
respondToRequest
(
requests
,
notes
,
true
);
Helpers
.
verifyPaginationInfo
(
view
,
"Showing 11-12 out of 12 total"
,
2
,
2
);
Helpers
.
verifyPaginationInfo
(
view
,
"Showing 11-12 out of 12 total"
,
false
,
2
,
2
);
Helpers
.
verifyPageData
(
view
,
this
.
tabsCollection
,
tabInfo
,
recentActivityTabId
,
notes
);
});
...
...
@@ -148,7 +149,7 @@ define([
var
collection
=
new
NotesCollection
(
page1Notes
,
{
perPage
:
10
,
parse
:
true
});
var
view
=
getView
(
collection
,
this
.
tabsCollection
);
Helpers
.
verifyPaginationInfo
(
view
,
"Showing 1-10 out of 15 total"
,
1
,
2
);
Helpers
.
verifyPaginationInfo
(
view
,
"Showing 1-10 out of 15 total"
,
false
,
1
,
2
);
Helpers
.
verifyPageData
(
view
,
this
.
tabsCollection
,
tabInfo
,
recentActivityTabId
,
page1Notes
);
view
.
$
(
'.pagination .next-page-link'
).
click
();
...
...
@@ -166,7 +167,7 @@ define([
}
);
Helpers
.
respondToRequest
(
requests
,
page2Notes
,
true
);
Helpers
.
verifyPaginationInfo
(
view
,
"Showing 11-15 out of 15 total"
,
2
,
2
);
Helpers
.
verifyPaginationInfo
(
view
,
"Showing 11-15 out of 15 total"
,
false
,
2
,
2
);
Helpers
.
verifyPageData
(
view
,
this
.
tabsCollection
,
tabInfo
,
recentActivityTabId
,
page2Notes
);
view
.
$
(
'.pagination .previous-page-link'
).
click
();
...
...
@@ -176,7 +177,7 @@ define([
);
Helpers
.
respondToRequest
(
requests
,
page1Notes
);
Helpers
.
verifyPaginationInfo
(
view
,
"Showing 1-10 out of 15 total"
,
1
,
2
);
Helpers
.
verifyPaginationInfo
(
view
,
"Showing 1-10 out of 15 total"
,
false
,
1
,
2
);
Helpers
.
verifyPageData
(
view
,
this
.
tabsCollection
,
tabInfo
,
recentActivityTabId
,
page1Notes
);
});
...
...
lms/static/js/spec/edxnotes/views/tabs/search_results_spec.js
View file @
ce57700d
...
...
@@ -91,7 +91,7 @@ define([
submitForm
(
view
.
searchBox
,
'second'
);
Helpers
.
respondToRequest
(
requests
,
responseJson
,
true
);
Helpers
.
verifyPageData
(
view
,
this
.
tabsCollection
,
tabInfo
,
searchResultsTabId
,
responseJson
);
Helpers
.
verifyPaginationInfo
(
view
,
"Showing 1-3 out of 3 total"
,
1
,
1
);
Helpers
.
verifyPaginationInfo
(
view
,
"Showing 1-3 out of 3 total"
,
true
,
1
,
1
);
});
it
(
'displays loading indicator when search is running'
,
function
()
{
...
...
@@ -242,7 +242,7 @@ define([
submitForm
(
view
.
searchBox
,
'awesome'
);
Helpers
.
respondToRequest
(
requests
,
notes
,
true
);
Helpers
.
verifyPaginationInfo
(
view
,
"Showing 1-10 out of 12 total"
,
1
,
2
);
Helpers
.
verifyPaginationInfo
(
view
,
"Showing 1-10 out of 12 total"
,
false
,
1
,
2
);
Helpers
.
verifyPageData
(
view
,
this
.
tabsCollection
,
tabInfo
,
searchResultsTabId
,
notes
);
view
.
$
(
'input#page-number-input'
).
val
(
'2'
);
...
...
@@ -262,7 +262,7 @@ define([
}
);
Helpers
.
respondToRequest
(
requests
,
notes
,
true
);
Helpers
.
verifyPaginationInfo
(
view
,
"Showing 11-12 out of 12 total"
,
2
,
2
);
Helpers
.
verifyPaginationInfo
(
view
,
"Showing 11-12 out of 12 total"
,
false
,
2
,
2
);
Helpers
.
verifyPageData
(
view
,
this
.
tabsCollection
,
tabInfo
,
searchResultsTabId
,
notes
);
});
...
...
@@ -281,7 +281,7 @@ define([
submitForm
(
view
.
searchBox
,
'awesome'
);
Helpers
.
respondToRequest
(
requests
,
page1Notes
,
true
);
Helpers
.
verifyPaginationInfo
(
view
,
"Showing 1-10 out of 15 total"
,
1
,
2
);
Helpers
.
verifyPaginationInfo
(
view
,
"Showing 1-10 out of 15 total"
,
false
,
1
,
2
);
Helpers
.
verifyPageData
(
view
,
this
.
tabsCollection
,
tabInfo
,
searchResultsTabId
,
page1Notes
);
view
.
$
(
'.pagination .next-page-link'
).
click
();
...
...
@@ -299,7 +299,7 @@ define([
}
);
Helpers
.
respondToRequest
(
requests
,
page2Notes
,
true
);
Helpers
.
verifyPaginationInfo
(
view
,
"Showing 11-15 out of 15 total"
,
2
,
2
);
Helpers
.
verifyPaginationInfo
(
view
,
"Showing 11-15 out of 15 total"
,
false
,
2
,
2
);
Helpers
.
verifyPageData
(
view
,
this
.
tabsCollection
,
tabInfo
,
searchResultsTabId
,
page2Notes
);
view
.
$
(
'.pagination .previous-page-link'
).
click
();
...
...
@@ -309,7 +309,7 @@ define([
);
Helpers
.
respondToRequest
(
requests
,
page1Notes
);
Helpers
.
verifyPaginationInfo
(
view
,
"Showing 1-10 out of 15 total"
,
1
,
2
);
Helpers
.
verifyPaginationInfo
(
view
,
"Showing 1-10 out of 15 total"
,
false
,
1
,
2
);
Helpers
.
verifyPageData
(
view
,
this
.
tabsCollection
,
tabInfo
,
searchResultsTabId
,
page1Notes
);
});
...
...
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