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
e1c4537b
Commit
e1c4537b
authored
Sep 18, 2014
by
Dave St.Germain
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Lookup video by youtube id
parent
22bef6f9
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
1 deletions
+34
-1
edxval/models.py
+14
-1
edxval/urls.py
+5
-0
edxval/views.py
+15
-0
No files found.
edxval/models.py
View file @
e1c4537b
...
...
@@ -32,7 +32,7 @@ from django.core.validators import MinValueValidator, RegexValidator
from
django.core.urlresolvers
import
reverse
url_regex
=
r'^[a-zA-Z0-9\-]*$'
url_regex
=
r'^[a-zA-Z0-9\-
_
]*$'
class
Profile
(
models
.
Model
):
...
...
@@ -60,6 +60,7 @@ class Profile(models.Model):
def
__unicode__
(
self
):
return
self
.
profile_name
class
Video
(
models
.
Model
):
"""
Model for a Video group with the same content.
...
...
@@ -87,6 +88,18 @@ class Video(models.Model):
def
__str__
(
self
):
return
self
.
edx_video_id
@classmethod
def
by_youtube_id
(
cls
,
youtube_id
):
"""
Look up video by youtube id
"""
url
=
'://youtu.be/
%
s'
%
youtube_id
qset
=
cls
.
objects
.
filter
(
encoded_videos__profile__profile_name
=
'youtube'
,
encoded_videos__url__endswith
=
url
)
.
prefetch_related
(
'encoded_videos'
,
'courses'
,
'subtitles'
)
return
qset
class
CourseVideo
(
models
.
Model
):
"""
...
...
edxval/urls.py
View file @
e1c4537b
...
...
@@ -34,5 +34,10 @@ urlpatterns = patterns(
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 @
e1c4537b
...
...
@@ -60,6 +60,9 @@ class VideoList(generics.ListCreateAPIView):
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"
)
...
...
@@ -70,6 +73,18 @@ class CourseVideoList(generics.ListAPIView):
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
"""
permission_classes
=
(
DjangoModelPermissions
,)
serializer_class
=
VideoSerializer
queryset
=
Video
.
objects
.
all
()
def
get_queryset
(
self
):
return
Video
.
by_youtube_id
(
self
.
kwargs
[
'youtube_id'
])
class
ProfileList
(
generics
.
ListCreateAPIView
):
"""
GETs or POST video objects
...
...
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