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
483cccb6
Commit
483cccb6
authored
Dec 15, 2014
by
Chris Dodge
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
also apply sorting rules overrides to the /courses view
parent
5c1834b6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
1 deletions
+33
-1
lms/djangoapps/branding/tests.py
+26
-0
lms/djangoapps/courseware/views.py
+7
-1
No files found.
lms/djangoapps/branding/tests.py
View file @
483cccb6
...
...
@@ -18,6 +18,8 @@ import student.views
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.tests.factories
import
CourseFactory
from
django.core.urlresolvers
import
reverse
FEATURES_WITH_STARTDATE
=
settings
.
FEATURES
.
copy
()
FEATURES_WITH_STARTDATE
[
'DISABLE_START_DATES'
]
=
False
FEATURES_WO_STARTDATE
=
settings
.
FEATURES
.
copy
()
...
...
@@ -140,6 +142,7 @@ class IndexPageCourseCardsSortingTests(ModuleStoreTestCase):
self
.
factory
=
RequestFactory
()
@patch
(
'student.views.render_to_response'
,
RENDER_MOCK
)
@patch
(
'courseware.views.render_to_response'
,
RENDER_MOCK
)
def
test_course_cards_sorted_by_default_sorting
(
self
):
response
=
self
.
client
.
get
(
'/'
)
self
.
assertEqual
(
response
.
status_code
,
200
)
...
...
@@ -151,7 +154,19 @@ class IndexPageCourseCardsSortingTests(ModuleStoreTestCase):
self
.
assertEqual
(
context
[
'courses'
][
1
]
.
id
,
self
.
starting_earlier
.
id
)
self
.
assertEqual
(
context
[
'courses'
][
2
]
.
id
,
self
.
course_with_default_start_date
.
id
)
# check the /courses view
response
=
self
.
client
.
get
(
reverse
(
'branding.views.courses'
))
self
.
assertEqual
(
response
.
status_code
,
200
)
((
template
,
context
),
_
)
=
RENDER_MOCK
.
call_args
self
.
assertEqual
(
template
,
'courseware/courses.html'
)
# Now the courses will be stored in their announcement dates.
self
.
assertEqual
(
context
[
'courses'
][
0
]
.
id
,
self
.
starting_later
.
id
)
self
.
assertEqual
(
context
[
'courses'
][
1
]
.
id
,
self
.
starting_earlier
.
id
)
self
.
assertEqual
(
context
[
'courses'
][
2
]
.
id
,
self
.
course_with_default_start_date
.
id
)
@patch
(
'student.views.render_to_response'
,
RENDER_MOCK
)
@patch
(
'courseware.views.render_to_response'
,
RENDER_MOCK
)
@patch.dict
(
'django.conf.settings.FEATURES'
,
{
'ENABLE_COURSE_SORTING_BY_START_DATE'
:
True
})
def
test_course_cards_sorted_by_start_date_show_earliest_first
(
self
):
response
=
self
.
client
.
get
(
'/'
)
...
...
@@ -163,3 +178,14 @@ class IndexPageCourseCardsSortingTests(ModuleStoreTestCase):
self
.
assertEqual
(
context
[
'courses'
][
0
]
.
id
,
self
.
starting_earlier
.
id
)
self
.
assertEqual
(
context
[
'courses'
][
1
]
.
id
,
self
.
starting_later
.
id
)
self
.
assertEqual
(
context
[
'courses'
][
2
]
.
id
,
self
.
course_with_default_start_date
.
id
)
# check the /courses view as well
response
=
self
.
client
.
get
(
reverse
(
'branding.views.courses'
))
self
.
assertEqual
(
response
.
status_code
,
200
)
((
template
,
context
),
_
)
=
RENDER_MOCK
.
call_args
self
.
assertEqual
(
template
,
'courseware/courses.html'
)
# now the courses will be sorted by their creation dates, earliest first.
self
.
assertEqual
(
context
[
'courses'
][
0
]
.
id
,
self
.
starting_earlier
.
id
)
self
.
assertEqual
(
context
[
'courses'
][
1
]
.
id
,
self
.
starting_later
.
id
)
self
.
assertEqual
(
context
[
'courses'
][
2
]
.
id
,
self
.
course_with_default_start_date
.
id
)
lms/djangoapps/courseware/views.py
View file @
483cccb6
...
...
@@ -33,6 +33,7 @@ from markupsafe import escape
from
courseware
import
grades
from
courseware.access
import
has_access
,
_adjust_start_date_for_beta_testers
from
courseware.courses
import
get_courses
,
get_course
,
get_studio_url
,
get_course_with_access
,
sort_by_announcement
from
courseware.courses
import
sort_by_start_date
from
courseware.masquerade
import
setup_masquerade
from
courseware.model_data
import
FieldDataCache
from
.module_render
import
toc_for_course
,
get_module_for_descriptor
,
get_module
...
...
@@ -103,7 +104,12 @@ def courses(request):
Render "find courses" page. The course selection work is done in courseware.courses.
"""
courses
=
get_courses
(
request
.
user
,
request
.
META
.
get
(
'HTTP_HOST'
))
courses
=
sort_by_announcement
(
courses
)
if
microsite
.
get_value
(
"ENABLE_COURSE_SORTING_BY_START_DATE"
,
settings
.
FEATURES
[
"ENABLE_COURSE_SORTING_BY_START_DATE"
]):
courses
=
sort_by_start_date
(
courses
)
else
:
courses
=
sort_by_announcement
(
courses
)
return
render_to_response
(
"courseware/courses.html"
,
{
'courses'
:
courses
})
...
...
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