Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
course-discovery
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
course-discovery
Commits
f4a0736c
Commit
f4a0736c
authored
Jun 05, 2017
by
Afzal Wali
Committed by
Afzal Wali Naushahi
Jun 07, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Excluded hidden programs from typeahead endpoint
LEARNER-1124
parent
2a948ac2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
1 deletions
+15
-1
course_discovery/apps/api/v1/tests/test_views/test_search.py
+14
-0
course_discovery/apps/api/v1/views/search.py
+1
-1
No files found.
course_discovery/apps/api/v1/tests/test_views/test_search.py
View file @
f4a0736c
...
@@ -552,6 +552,20 @@ class TypeaheadSearchViewTests(DefaultPartnerMixin, TypeaheadSerializationMixin,
...
@@ -552,6 +552,20 @@ class TypeaheadSearchViewTests(DefaultPartnerMixin, TypeaheadSerializationMixin,
}
}
self
.
assertDictEqual
(
response_data
,
expected_response_data
)
self
.
assertDictEqual
(
response_data
,
expected_response_data
)
def
test_typeahead_hidden_programs
(
self
):
""" Verify that typeahead does not return hidden programs. """
title
=
"hiddenprogram"
program
=
ProgramFactory
(
title
=
title
,
hidden
=
False
,
status
=
ProgramStatus
.
Active
,
partner
=
self
.
partner
)
ProgramFactory
(
title
=
program
.
title
+
'hidden'
,
hidden
=
True
,
status
=
ProgramStatus
.
Active
,
partner
=
self
.
partner
)
response
=
self
.
get_response
({
'q'
:
program
.
title
})
self
.
assertEqual
(
response
.
status_code
,
200
)
response_data
=
response
.
json
()
expected_response_data
=
{
'course_runs'
:
[],
'programs'
:
[
self
.
serialize_program
(
program
)]
}
self
.
assertDictEqual
(
response_data
,
expected_response_data
)
def
test_exception
(
self
):
def
test_exception
(
self
):
""" Verify the view raises an error if the 'q' query string parameter is not provided. """
""" Verify the view raises an error if the 'q' query string parameter is not provided. """
response
=
self
.
get_response
()
response
=
self
.
get_response
()
...
...
course_discovery/apps/api/v1/views/search.py
View file @
f4a0736c
...
@@ -153,7 +153,7 @@ class TypeaheadSearchView(PartnerMixin, APIView):
...
@@ -153,7 +153,7 @@ class TypeaheadSearchView(PartnerMixin, APIView):
SQ
(
title_autocomplete
=
clean_query
)
|
SQ
(
title_autocomplete
=
clean_query
)
|
SQ
(
authoring_organizations_autocomplete
=
clean_query
)
SQ
(
authoring_organizations_autocomplete
=
clean_query
)
)
)
programs
=
programs
.
filter
(
status
=
ProgramStatus
.
Active
)
.
filter
(
partner
=
partner
.
short_code
)
programs
=
programs
.
filter
(
status
=
ProgramStatus
.
Active
)
.
exclude
(
hidden
=
True
)
.
filter
(
partner
=
partner
.
short_code
)
programs
=
programs
[:
self
.
RESULT_COUNT
]
programs
=
programs
[:
self
.
RESULT_COUNT
]
return
course_run_list
,
programs
return
course_run_list
,
programs
...
...
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