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
d918cdb8
Commit
d918cdb8
authored
Nov 15, 2017
by
Albert St. Aubin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Addition of user filter parameter to the Entitlement API
[LEARNER-3274]
parent
68890dab
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
2 deletions
+17
-2
common/djangoapps/entitlements/api/v1/filters.py
+2
-2
common/djangoapps/entitlements/api/v1/tests/test_views.py
+15
-0
No files found.
common/djangoapps/entitlements/api/v1/filters.py
View file @
d918cdb8
...
...
@@ -34,8 +34,8 @@ class UUIDListFilter(CharListFilter):
class
CourseEntitlementFilter
(
filters
.
FilterSet
):
uuid
=
UUIDListFilter
()
course_uuid
=
UUIDListFilter
(
)
user
=
filters
.
CharFilter
(
name
=
'user__username'
)
class
Meta
:
model
=
CourseEntitlement
fields
=
(
'uuid'
,)
fields
=
(
'uuid'
,
'user'
)
common/djangoapps/entitlements/api/v1/tests/test_views.py
View file @
d918cdb8
...
...
@@ -88,6 +88,21 @@ class EntitlementViewSetTest(ModuleStoreTestCase):
results
=
response
.
data
.
get
(
'results'
,
[])
assert
results
==
CourseEntitlementSerializer
(
entitlements
,
many
=
True
)
.
data
def
test_get_user_entitlements
(
self
):
user2
=
UserFactory
()
CourseEntitlementFactory
.
create
()
entitlement_user2
=
CourseEntitlementFactory
.
create
(
user
=
user2
)
url
=
reverse
(
'entitlements_api:v1:entitlements-list'
)
url
+=
'?user={username}'
.
format
(
username
=
user2
.
username
)
response
=
self
.
client
.
get
(
url
,
content_type
=
'application/json'
,
)
assert
response
.
status_code
==
200
results
=
response
.
data
.
get
(
'results'
,
[])
assert
results
==
CourseEntitlementSerializer
([
entitlement_user2
],
many
=
True
)
.
data
def
test_get_entitlement_by_uuid
(
self
):
entitlement
=
CourseEntitlementFactory
()
CourseEntitlementFactory
.
create_batch
(
2
)
...
...
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