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
80246abd
Commit
80246abd
authored
Dec 21, 2016
by
Ahsan Ulhaq
Committed by
GitHub
Dec 21, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #496 from edx/ahsan/Add-searchable-courserun-filter
Added searchable courseruns filter
parents
f8189381
5a2a9322
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
18 additions
and
1 deletions
+18
-1
course_discovery/apps/api/filters.py
+1
-1
course_discovery/apps/api/v1/tests/test_views/test_course_runs.py
+10
-0
course_discovery/apps/api/v1/views/course_runs.py
+6
-0
course_discovery/apps/course_metadata/tests/factories.py
+1
-0
No files found.
course_discovery/apps/api/filters.py
View file @
80246abd
...
...
@@ -150,7 +150,7 @@ class CourseRunFilter(FilterSetMixin, django_filters.FilterSet):
class
Meta
:
model
=
CourseRun
fields
=
[
'keys'
]
fields
=
[
'keys'
,
'hidden'
]
class
ProgramFilter
(
FilterSetMixin
,
django_filters
.
FilterSet
):
...
...
course_discovery/apps/api/v1/tests/test_views/test_course_runs.py
View file @
80246abd
...
...
@@ -173,6 +173,16 @@ class CourseRunViewSetTests(SerializationMixin, ElasticsearchTestMixin, APITestC
url
=
reverse
(
'api:v1:course_run-list'
)
+
'?marketable=1'
self
.
assert_list_results
(
url
,
expected
)
def
test_filter_by_hidden
(
self
):
""" Verify the endpoint filters course runs that are hidden. """
CourseRun
.
objects
.
all
()
.
delete
()
course_runs
=
CourseRunFactory
.
create_batch
(
3
,
course__partner
=
self
.
partner
)
hidden_course_runs
=
CourseRunFactory
.
create_batch
(
3
,
hidden
=
True
,
course__partner
=
self
.
partner
)
url
=
reverse
(
'api:v1:course_run-list'
)
self
.
assert_list_results
(
url
,
course_runs
+
hidden_course_runs
)
url
=
reverse
(
'api:v1:course_run-list'
)
+
'?hidden=False'
self
.
assert_list_results
(
url
,
course_runs
)
def
test_filter_by_active
(
self
):
""" Verify the endpoint filters course runs to those that are active. """
CourseRun
.
objects
.
all
()
.
delete
()
...
...
course_discovery/apps/api/v1/views/course_runs.py
View file @
80246abd
...
...
@@ -81,6 +81,12 @@ class CourseRunViewSet(PartnerMixin, viewsets.ReadOnlyModelViewSet):
type: string
paramType: query
multiple: false
- name: hidden
description: Filter based on wether the course run is hidden from search.
required: false
type: Boolean
paramType: query
multiple: false
- name: active
description: Retrieve active course runs. A course is considered active if its end date has not passed,
and it is open for enrollment.
...
...
course_discovery/apps/course_metadata/tests/factories.py
View file @
80246abd
...
...
@@ -127,6 +127,7 @@ class CourseRunFactory(factory.DjangoModelFactory):
max_effort
=
FuzzyInteger
(
10
,
20
)
pacing_type
=
FuzzyChoice
([
name
for
name
,
__
in
CourseRunPacing
.
choices
])
slug
=
FuzzyText
()
hidden
=
False
weeks_to_complete
=
FuzzyInteger
(
1
)
@factory.post_generation
...
...
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