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
ab27becf
Commit
ab27becf
authored
Apr 04, 2017
by
Clinton Blackburn
Committed by
Clinton Blackburn
Apr 05, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added program status filtering
The programs API endpoint now supports filtering by status. ECOM-7625
parent
996c385e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
0 deletions
+16
-0
course_discovery/apps/api/filters.py
+2
-0
course_discovery/apps/api/v1/tests/test_views/test_programs.py
+14
-0
No files found.
course_discovery/apps/api/filters.py
View file @
ab27becf
...
@@ -14,6 +14,7 @@ from rest_framework.exceptions import NotFound, PermissionDenied
...
@@ -14,6 +14,7 @@ from rest_framework.exceptions import NotFound, PermissionDenied
from
course_discovery.apps.api.utils
import
cast2int
from
course_discovery.apps.api.utils
import
cast2int
from
course_discovery.apps.core.models
import
Partner
from
course_discovery.apps.core.models
import
Partner
from
course_discovery.apps.course_metadata.choices
import
ProgramStatus
from
course_discovery.apps.course_metadata.models
import
Course
,
CourseRun
,
Organization
,
Program
from
course_discovery.apps.course_metadata.models
import
Course
,
CourseRun
,
Organization
,
Program
logger
=
logging
.
getLogger
(
__name__
)
logger
=
logging
.
getLogger
(
__name__
)
...
@@ -156,6 +157,7 @@ class CourseRunFilter(FilterSetMixin, django_filters.FilterSet):
...
@@ -156,6 +157,7 @@ class CourseRunFilter(FilterSetMixin, django_filters.FilterSet):
class
ProgramFilter
(
FilterSetMixin
,
django_filters
.
FilterSet
):
class
ProgramFilter
(
FilterSetMixin
,
django_filters
.
FilterSet
):
marketable
=
django_filters
.
MethodFilter
()
marketable
=
django_filters
.
MethodFilter
()
status
=
django_filters
.
MultipleChoiceFilter
(
choices
=
ProgramStatus
.
choices
)
type
=
django_filters
.
CharFilter
(
name
=
'type__name'
,
lookup_expr
=
'iexact'
)
type
=
django_filters
.
CharFilter
(
name
=
'type__name'
,
lookup_expr
=
'iexact'
)
types
=
CharListFilter
(
name
=
'type__slug'
,
lookup_expr
=
'in'
)
types
=
CharListFilter
(
name
=
'type__slug'
,
lookup_expr
=
'in'
)
uuids
=
UUIDListFilter
()
uuids
=
UUIDListFilter
()
...
...
course_discovery/apps/api/v1/tests/test_views/test_programs.py
View file @
ab27becf
...
@@ -166,6 +166,20 @@ class ProgramViewSetTests(SerializationMixin, APITestCase):
...
@@ -166,6 +166,20 @@ class ProgramViewSetTests(SerializationMixin, APITestCase):
self
.
assertEqual
(
list
(
Program
.
objects
.
marketable
()),
expected
)
self
.
assertEqual
(
list
(
Program
.
objects
.
marketable
()),
expected
)
self
.
assert_list_results
(
url
,
expected
,
expected_query_count
)
self
.
assert_list_results
(
url
,
expected
,
expected_query_count
)
def
test_filter_by_status
(
self
):
""" Verify the endpoint allows programs to filtered by one, or more, statuses. """
active
=
ProgramFactory
(
status
=
ProgramStatus
.
Active
)
retired
=
ProgramFactory
(
status
=
ProgramStatus
.
Retired
)
url
=
self
.
list_path
+
'?status=active'
self
.
assert_list_results
(
url
,
[
active
],
8
)
url
=
self
.
list_path
+
'?status=retired'
self
.
assert_list_results
(
url
,
[
retired
],
8
)
url
=
self
.
list_path
+
'?status=active&status=retired'
self
.
assert_list_results
(
url
,
[
retired
,
active
],
8
)
def
test_list_exclude_utm
(
self
):
def
test_list_exclude_utm
(
self
):
""" Verify the endpoint returns marketing URLs without UTM parameters. """
""" Verify the endpoint returns marketing URLs without UTM parameters. """
url
=
self
.
list_path
+
'?exclude_utm=1'
url
=
self
.
list_path
+
'?exclude_utm=1'
...
...
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