Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-val
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-val
Commits
65349b38
Commit
65349b38
authored
Sep 18, 2014
by
Dave St.Germain
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move course video and youtube video lookups to query strings on /videos/
parent
14fb480a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
39 deletions
+19
-39
edxval/tests/test_views.py
+7
-3
edxval/urls.py
+0
-11
edxval/views.py
+12
-25
No files found.
edxval/tests/test_views.py
View file @
65349b38
...
@@ -325,6 +325,10 @@ class VideoListTest(APIAuthTestCase):
...
@@ -325,6 +325,10 @@ class VideoListTest(APIAuthTestCase):
Profile
.
objects
.
create
(
**
constants
.
PROFILE_DICT_DESKTOP
)
Profile
.
objects
.
create
(
**
constants
.
PROFILE_DICT_DESKTOP
)
super
(
VideoListTest
,
self
)
.
setUp
()
super
(
VideoListTest
,
self
)
.
setUp
()
def
tearDown
(
self
):
super
(
VideoListTest
,
self
)
.
tearDown
()
Video
.
objects
.
all
()
.
delete
()
# Tests for successful POST 201 requests.
# Tests for successful POST 201 requests.
def
test_complete_set_two_encoded_video_post
(
self
):
def
test_complete_set_two_encoded_video_post
(
self
):
"""
"""
...
@@ -494,12 +498,12 @@ class VideoListTest(APIAuthTestCase):
...
@@ -494,12 +498,12 @@ class VideoListTest(APIAuthTestCase):
self
.
assertEqual
(
len
(
videos
),
1
)
self
.
assertEqual
(
len
(
videos
),
1
)
self
.
assertEqual
(
videos
[
0
][
'courses'
],
[
course1
,
course2
])
self
.
assertEqual
(
videos
[
0
][
'courses'
],
[
course1
,
course2
])
url
=
reverse
(
'
course-video-list'
,
kwargs
=
{
'course_id'
:
course1
})
url
=
reverse
(
'
video-list'
)
+
'?course=
%
s'
%
course1
videos
=
self
.
client
.
get
(
url
)
.
data
videos
=
self
.
client
.
get
(
url
)
.
data
self
.
assertEqual
(
len
(
videos
),
1
)
self
.
assertEqual
(
len
(
videos
),
1
)
self
.
assertEqual
(
videos
[
0
][
'edx_video_id'
],
constants
.
VIDEO_DICT_ANIMAL
[
'edx_video_id'
])
self
.
assertEqual
(
videos
[
0
][
'edx_video_id'
],
constants
.
VIDEO_DICT_ANIMAL
[
'edx_video_id'
])
url
=
reverse
(
'
course-video-list'
,
kwargs
=
{
'course_id'
:
'animals/fish/salmon'
})
url
=
reverse
(
'
video-list'
)
+
'?course=animals/fish/salmon'
response
=
self
.
client
.
get
(
url
)
.
data
response
=
self
.
client
.
get
(
url
)
.
data
self
.
assertEqual
(
len
(
response
),
0
)
self
.
assertEqual
(
len
(
response
),
0
)
...
@@ -527,7 +531,7 @@ class VideoListTest(APIAuthTestCase):
...
@@ -527,7 +531,7 @@ class VideoListTest(APIAuthTestCase):
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_201_CREATED
)
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_201_CREATED
)
# now look up the vid by youtube id
# now look up the vid by youtube id
url
=
reverse
(
'
youtube-video-list'
,
kwargs
=
{
'youtube_id'
:
'AbcDef'
})
url
=
reverse
(
'
video-list'
)
+
'?youtube=AbcDef'
response
=
self
.
client
.
get
(
url
)
.
data
response
=
self
.
client
.
get
(
url
)
.
data
self
.
assertEqual
(
len
(
response
),
1
)
self
.
assertEqual
(
len
(
response
),
1
)
self
.
assertEqual
(
response
[
0
][
'edx_video_id'
],
video
[
'edx_video_id'
])
self
.
assertEqual
(
response
[
0
][
'edx_video_id'
],
video
[
'edx_video_id'
])
...
...
edxval/urls.py
View file @
65349b38
...
@@ -29,15 +29,4 @@ urlpatterns = patterns(
...
@@ -29,15 +29,4 @@ urlpatterns = patterns(
views
.
get_subtitle
,
views
.
get_subtitle
,
name
=
"subtitle-content"
name
=
"subtitle-content"
),
),
url
(
r'^courses/{}$'
.
format
(
settings
.
COURSE_ID_PATTERN
),
views
.
CourseVideoList
.
as_view
(),
name
=
"course-video-list"
),
url
(
r'^youtube/(?P<youtube_id>[-_\w]+)$'
,
views
.
YoutubeVideoList
.
as_view
(),
name
=
"youtube-video-list"
),
)
)
edxval/views.py
View file @
65349b38
...
@@ -58,32 +58,19 @@ class VideoList(generics.ListCreateAPIView):
...
@@ -58,32 +58,19 @@ class VideoList(generics.ListCreateAPIView):
lookup_field
=
"edx_video_id"
lookup_field
=
"edx_video_id"
serializer_class
=
VideoSerializer
serializer_class
=
VideoSerializer
class
CourseVideoList
(
generics
.
ListAPIView
):
"""
GET a list of videos for a course
"""
authentication_classes
=
(
OAuth2Authentication
,
SessionAuthentication
)
permission_classes
=
(
ReadRestrictedDjangoModelPermissions
,)
queryset
=
Video
.
objects
.
all
()
.
prefetch_related
(
"encoded_videos"
)
lookup_field
=
"course_id"
serializer_class
=
VideoSerializer
def
get_queryset
(
self
):
return
self
.
queryset
.
filter
(
courses__course_id
=
self
.
kwargs
[
'course_id'
])
class
YoutubeVideoList
(
generics
.
ListAPIView
):
"""
Get a list of videos for the given youtube id
"""
authentication_classes
=
(
OAuth2Authentication
,
SessionAuthentication
)
permission_classes
=
(
ReadRestrictedDjangoModelPermissions
,)
serializer_class
=
VideoSerializer
queryset
=
Video
.
objects
.
all
()
def
get_queryset
(
self
):
def
get_queryset
(
self
):
return
Video
.
by_youtube_id
(
self
.
kwargs
[
'youtube_id'
])
qset
=
Video
.
objects
.
all
()
.
prefetch_related
(
"encoded_videos"
,
"courses"
)
args
=
self
.
request
.
GET
course_id
=
args
.
get
(
'course'
)
if
course_id
:
# view videos by course id
qset
=
qset
.
filter
(
courses__course_id
=
course_id
)
youtube_id
=
args
.
get
(
'youtube'
)
if
youtube_id
:
# view videos by youtube id
qset
=
qset
&
Video
.
by_youtube_id
(
youtube_id
)
return
qset
class
ProfileList
(
generics
.
ListCreateAPIView
):
class
ProfileList
(
generics
.
ListCreateAPIView
):
...
...
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