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
8ed247b3
Commit
8ed247b3
authored
Jan 16, 2015
by
Nimisha Asthagiri
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #6662 from edx/mobile/MA-227
MA-227 Mobile announcements sort order correction.
parents
8394fb71
caee3331
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
12 deletions
+24
-12
lms/djangoapps/mobile_api/course_info/tests.py
+23
-11
lms/djangoapps/mobile_api/course_info/views.py
+1
-1
No files found.
lms/djangoapps/mobile_api/course_info/tests.py
View file @
8ed247b3
...
...
@@ -73,31 +73,43 @@ class TestUpdates(MobileAPITestCase, MobileAuthTestMixin, MobileEnrolledCourseAc
)
# store content in Updates item (either new or old format)
num_updates
=
3
if
new_format
:
course_update_data
=
{
"id"
:
1
,
"date"
:
"Some date"
,
"content"
:
"<a href=
\"
/static/
\"
>foo</a>"
,
"status"
:
CourseInfoModule
.
STATUS_VISIBLE
}
course_updates
.
items
=
[
course_update_data
]
for
num
in
range
(
1
,
num_updates
+
1
):
course_updates
.
items
.
append
(
{
"id"
:
num
,
"date"
:
"Date"
+
str
(
num
),
"content"
:
"<a href=
\"
/static/
\"
>Update"
+
str
(
num
)
+
"</a>"
,
"status"
:
CourseInfoModule
.
STATUS_VISIBLE
}
)
else
:
update_data
=
u"<ol><li><h2>Date</h2><a href=
\"
/static/
\"
>foo</a></li></ol>"
course_updates
.
data
=
update_data
update_data
=
""
# old format stores the updates with the newest first
for
num
in
range
(
num_updates
,
0
,
-
1
):
update_data
+=
"<li><h2>Date"
+
str
(
num
)
+
"</h2><a href=
\"
/static/
\"
>Update"
+
str
(
num
)
+
"</a></li>"
course_updates
.
data
=
u"<ol>"
+
update_data
+
"</ol>"
modulestore
()
.
update_item
(
course_updates
,
self
.
user
.
id
)
# call API
response
=
self
.
api_response
()
content
=
response
.
data
[
0
][
"content"
]
# pylint: disable=maybe-no-member
# verify static URLs are replaced in the content returned by the API
self
.
assertNotIn
(
"
\"
/static/"
,
content
)
self
.
assertNotIn
(
"
\"
/static/"
,
response
.
content
)
# verify static URLs remain in the underlying content
underlying_updates
=
modulestore
()
.
get_item
(
updates_usage_key
)
underlying_content
=
underlying_updates
.
items
[
0
][
'content'
]
if
new_format
else
underlying_updates
.
data
self
.
assertIn
(
"
\"
/static/"
,
underlying_content
)
# verify content and sort order of updates (most recent first)
for
num
in
range
(
1
,
num_updates
+
1
):
update_data
=
response
.
data
[
num_updates
-
num
]
# pylint: disable=maybe-no-member
self
.
assertEquals
(
num
,
update_data
[
'id'
])
self
.
assertEquals
(
"Date"
+
str
(
num
),
update_data
[
'date'
])
self
.
assertIn
(
"Update"
+
str
(
num
),
update_data
[
'content'
])
class
TestHandouts
(
MobileAPITestCase
,
MobileAuthTestMixin
,
MobileEnrolledCourseAccessTestMixin
):
"""
...
...
lms/djangoapps/mobile_api/course_info/views.py
View file @
8ed247b3
...
...
@@ -39,7 +39,7 @@ class CourseUpdatesList(generics.ListAPIView):
@mobile_course_access
()
def
list
(
self
,
request
,
course
,
*
args
,
**
kwargs
):
course_updates_module
=
get_course_info_section_module
(
request
,
course
,
'updates'
)
update_items
=
list
(
reversed
(
get_course_update_items
(
course_updates_module
))
)
update_items
=
get_course_update_items
(
course_updates_module
)
updates_to_show
=
[
update
for
update
in
update_items
...
...
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